diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-06-18 17:28:32 -0600 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-06-18 17:28:32 -0600 |
commit | c245eabd55a1238379f48966879aa02889ec254e (patch) | |
tree | 17631a86de1eabb0ba35ea40749b7bfacf32373f /subsonic-android/src/github/daneren2005 | |
parent | 364e0ba02e3344025ba174f73af303c6f777975f (diff) | |
download | dsub-c245eabd55a1238379f48966879aa02889ec254e.tar.gz dsub-c245eabd55a1238379f48966879aa02889ec254e.tar.bz2 dsub-c245eabd55a1238379f48966879aa02889ec254e.zip |
Add another condition to prevent serialize from running before deserialzie
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 7 |
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(); } |