diff options
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 26 |
2 files changed, 11 insertions, 17 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 76a0bd41..5a17c19c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,7 +2,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="github.daneren2005.dsub"
android:installLocation="internalOnly"
- android:versionCode="61"
+ android:versionCode="62"
android:versionName="4.1.4">
<uses-permission android:name="android.permission.INTERNET"/>
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index e0019559..4e3ec29c 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -117,6 +117,16 @@ public class DownloadServiceLifecycleSupport { Looper.prepare(); eventLooper = Looper.myLooper(); eventHandler = new Handler(eventLooper); + + // Deserialize queue before starting looper + try { + lock.lock(); + deserializeDownloadQueueNow(); + setup.set(true); + } finally { + lock.unlock(); + } + Looper.loop(); } }).start(); @@ -176,8 +186,6 @@ public class DownloadServiceLifecycleSupport { commandFilter.addAction(DownloadServiceImpl.CMD_NEXT); downloadService.registerReceiver(intentReceiver, commandFilter); - deserializeDownloadQueue(); - new CacheCleaner(downloadService, downloadService).clean(); } @@ -248,20 +256,6 @@ public class DownloadServiceLifecycleSupport { FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER); } - private void deserializeDownloadQueue() { - eventHandler.post(new Runnable() { - @Override - public void run() { - try { - lock.lock(); - deserializeDownloadQueueNow(); - setup.set(true); - } finally { - lock.unlock(); - } - } - }); - } private void deserializeDownloadQueueNow() { State state = FileUtil.deserialize(downloadService, FILENAME_DOWNLOADS_SER); if (state == null) { |