wip: running download manager outside fdroid

This commit is contained in:
Toby Kurien 2015-09-04 09:20:21 +02:00 committed by Peter Serwylo
parent dbd4c467f8
commit 5f989739bb
4 changed files with 14 additions and 8 deletions

View File

@ -554,7 +554,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
protected void onDestroy() { protected void onDestroy() {
if (downloadHandler != null) { if (downloadHandler != null) {
if (!inProcessOfChangingConfiguration) { if (!inProcessOfChangingConfiguration) {
downloadHandler.cancel(); downloadHandler.cancel(false);
cleanUpFinishedDownload(); cleanUpFinishedDownload();
} }
} }
@ -1517,7 +1517,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
if (activity == null || activity.downloadHandler == null) if (activity == null || activity.downloadHandler == null)
return; return;
activity.downloadHandler.cancel(); activity.downloadHandler.cancel(true);
activity.cleanUpFinishedDownload(); activity.cleanUpFinishedDownload();
setProgressVisible(false); setProgressVisible(false);
updateViews(); updateViews();

View File

@ -289,11 +289,13 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener {
/** /**
* Attempts to cancel the download (if in progress) and also removes the progress * Attempts to cancel the download (if in progress) and also removes the progress
* listener (to prevent * listener
*
* @param userRequested - true if the user requested the cancel (via button click), otherwise false.
*/ */
public void cancel() { public void cancel(boolean userRequested) {
if (dlWrapper != null) { if (dlWrapper != null) {
dlWrapper.attemptCancel(); dlWrapper.attemptCancel(userRequested);
} }
} }

View File

@ -47,7 +47,7 @@ public class AsyncDownloadWrapper extends Handler {
downloadThread.start(); downloadThread.start();
} }
public void attemptCancel() { public void attemptCancel(boolean userRequested) {
if (downloadThread != null) { if (downloadThread != null) {
downloadThread.interrupt(); downloadThread.interrupt();
} }

View File

@ -85,8 +85,12 @@ public class AsyncDownloader extends AsyncDownloadWrapper {
} }
@Override @Override
public void attemptCancel() { public void attemptCancel(boolean userRequested) {
if (downloadId >= 0) dm.remove(downloadId); if (userRequested && downloadId >= 0) {
dm.remove(downloadId);
}
context.unregisterReceiver(downloadReceiver);
} }
// Broadcast receiver to receive broadcasts from the download manager // Broadcast receiver to receive broadcasts from the download manager