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() {
if (downloadHandler != null) {
if (!inProcessOfChangingConfiguration) {
downloadHandler.cancel();
downloadHandler.cancel(false);
cleanUpFinishedDownload();
}
}
@ -1517,7 +1517,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
if (activity == null || activity.downloadHandler == null)
return;
activity.downloadHandler.cancel();
activity.downloadHandler.cancel(true);
activity.cleanUpFinishedDownload();
setProgressVisible(false);
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
* 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) {
dlWrapper.attemptCancel();
dlWrapper.attemptCancel(userRequested);
}
}

View File

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

View File

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