aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-06-18 20:44:09 -0700
committerScott Jackson <daneren2005@gmail.com>2013-06-18 20:44:09 -0700
commit9f7710955aaeba07cb727f01451c0b2ac922f88c (patch)
tree33c699b700e5cdd545ed49b2ba7b7b9896f943c8
parent87da78de824d57f0cd132dabcf9effa3d331faaf (diff)
parentc245eabd55a1238379f48966879aa02889ec254e (diff)
downloaddsub-9f7710955aaeba07cb727f01451c0b2ac922f88c.tar.gz
dsub-9f7710955aaeba07cb727f01451c0b2ac922f88c.tar.bz2
dsub-9f7710955aaeba07cb727f01451c0b2ac922f88c.zip
Merge branch 'master' of https://github.com/daneren2005/Subsonic.git
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index 98e86706..33c45a02 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -25,6 +25,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.atomic.AtomicBoolean;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -58,6 +59,7 @@ public class DownloadServiceLifecycleSupport {
private PhoneStateListener phoneStateListener;
private boolean externalStorageAvailable= true;
private ReentrantLock lock = new ReentrantLock();
+ private final AtomicBoolean setup = new AtomicBoolean(false);
/**
* This receiver manages the intent that could come from other applications.
@@ -185,6 +187,10 @@ public class DownloadServiceLifecycleSupport {
}
public void serializeDownloadQueue() {
+ if(!setup.get()) {
+ return;
+ }
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
new SerializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
@@ -328,6 +334,7 @@ public class DownloadServiceLifecycleSupport {
try {
lock.lock();
deserializeDownloadQueueNow();
+ setup.set(true);
} finally {
lock.unlock();
}