Send an event when update are canceled

This allows to properly update the status of the application.
In particular, when an update is deleted:
 - Cancel the associated notification, if any.
 - Remove the entry from the controller if the update is no longer
   available online.
 - Disable the resume button if download is partially downloaded
   and is no longer available online.
This commit is contained in:
Gabriele M
2017-07-07 22:05:22 +02:00
parent 08a7dfade9
commit d327d61cc6
5 changed files with 65 additions and 6 deletions
@@ -81,6 +81,9 @@ public class UpdatesActivity extends AppCompatActivity {
UpdaterController.ACTION_INSTALL_PROGRESS.equals(intent.getAction())) {
String downloadId = intent.getStringExtra(UpdaterController.EXTRA_DOWNLOAD_ID);
mAdapter.notifyItemChanged(downloadId);
} else if (UpdaterController.ACTION_UPDATE_REMOVED.equals(intent.getAction())) {
String downloadId = intent.getStringExtra(UpdaterController.EXTRA_DOWNLOAD_ID);
mAdapter.removeItem(downloadId);
}
}
};
@@ -99,6 +102,7 @@ public class UpdatesActivity extends AppCompatActivity {
intentFilter.addAction(UpdaterController.ACTION_UPDATE_STATUS);
intentFilter.addAction(UpdaterController.ACTION_DOWNLOAD_PROGRESS);
intentFilter.addAction(UpdaterController.ACTION_INSTALL_PROGRESS);
intentFilter.addAction(UpdaterController.ACTION_UPDATE_REMOVED);
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, intentFilter);
}