Unregister receiver before stopping the executor that is called from there

This commit is contained in:
ByteHamster 2022-01-22 19:49:20 +01:00
parent 3393bcdf35
commit 6e0ff29e7b
1 changed files with 5 additions and 4 deletions

View File

@ -257,6 +257,11 @@ public class DownloadService extends Service {
reportQueue.clear(); reportQueue.clear();
} }
unregisterReceiver(cancelDownloadReceiver);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
connectionMonitor.disable(getApplicationContext());
}
EventBus.getDefault().postSticky(DownloadEvent.refresh(Collections.emptyList())); EventBus.getDefault().postSticky(DownloadEvent.refresh(Collections.emptyList()));
cancelNotificationUpdater(); cancelNotificationUpdater();
downloadHandleExecutor.shutdown(); downloadHandleExecutor.shutdown();
@ -266,10 +271,6 @@ public class DownloadService extends Service {
downloadPostFuture.cancel(true); downloadPostFuture.cancel(true);
} }
downloads.clear(); downloads.clear();
unregisterReceiver(cancelDownloadReceiver);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
connectionMonitor.disable(getApplicationContext());
}
// start auto download in case anything new has shown up // start auto download in case anything new has shown up
DBTasks.autodownloadUndownloadedItems(getApplicationContext()); DBTasks.autodownloadUndownloadedItems(getApplicationContext());