Remove no longer available updates when refreshing the list

This commit is contained in:
Gabriele M
2017-07-07 22:05:23 +02:00
parent d327d61cc6
commit c90700d3d2
3 changed files with 24 additions and 0 deletions

View File

@@ -291,6 +291,24 @@ public class UpdaterController implements UpdaterControllerInt {
return true;
}
@Override
public void setUpdatesAvailableOnline(List<String> downloadIds, boolean purgeList) {
List<String> toRemove = new ArrayList<>();
for (DownloadEntry entry : mDownloads.values()) {
boolean online = downloadIds.contains(entry.mUpdate.getDownloadId());
entry.mUpdate.setAvailableOnline(online);
if (!online && purgeList &&
entry.mUpdate.getPersistentStatus() == UpdateStatus.Persistent.UNKNOWN) {
toRemove.add(entry.mUpdate.getDownloadId());
}
}
for (String downloadId : toRemove) {
Log.d(TAG, downloadId + " no longer available online, removing");
mDownloads.remove(downloadId);
notifyUpdateDelete(downloadId);
}
}
@Override
public boolean addUpdate(UpdateDownload update) {
return addUpdate(update, true);