mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
fix: Fix new download caching
This commit is contained in:
parent
ae82bcd7bf
commit
375501f282
2 changed files with 24 additions and 17 deletions
|
|
@ -53,6 +53,7 @@ public class DownloaderService extends androidx.media3.exoplayer.offline.Downloa
|
|||
private static final class TerminalStateNotificationHelper implements DownloadManager.Listener {
|
||||
private final Context context;
|
||||
private final DownloadNotificationHelper notificationHelper;
|
||||
private final DownloaderManager downloaderManager;
|
||||
|
||||
private final Notification successfulDownloadGroupNotification;
|
||||
private final Notification failedDownloadGroupNotification;
|
||||
|
|
@ -65,6 +66,7 @@ public class DownloaderService extends androidx.media3.exoplayer.offline.Downloa
|
|||
public TerminalStateNotificationHelper(Context context, DownloadNotificationHelper notificationHelper, int firstNotificationId) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.notificationHelper = notificationHelper;
|
||||
this.downloaderManager = DownloadUtil.getDownloadTracker(context);
|
||||
nextNotificationId = firstNotificationId;
|
||||
|
||||
successfulDownloadGroupNotification = DownloadUtil.buildGroupSummaryNotification(
|
||||
|
|
@ -95,7 +97,7 @@ public class DownloaderService extends androidx.media3.exoplayer.offline.Downloa
|
|||
notification = notificationHelper.buildDownloadCompletedNotification(context, R.drawable.ic_check_circle, null, DownloaderManager.getDownloadNotificationMessage(download.request.id));
|
||||
notification = Notification.Builder.recoverBuilder(context, notification).setGroup(DownloadUtil.DOWNLOAD_NOTIFICATION_SUCCESSFUL_GROUP).build();
|
||||
NotificationUtil.setNotification(this.context, successfulDownloadGroupNotificationId, successfulDownloadGroupNotification);
|
||||
DownloaderManager.updateDatabase(download.request.id);
|
||||
downloaderManager.updateRequestDownload(download);
|
||||
} else if (download.state == Download.STATE_FAILED) {
|
||||
notification = notificationHelper.buildDownloadFailedNotification(context, R.drawable.ic_error, null, DownloaderManager.getDownloadNotificationMessage(download.request.id));
|
||||
notification = Notification.Builder.recoverBuilder(context, notification).setGroup(DownloadUtil.DOWNLOAD_NOTIFICATION_FAILED_GROUP).build();
|
||||
|
|
@ -109,7 +111,7 @@ public class DownloaderService extends androidx.media3.exoplayer.offline.Downloa
|
|||
|
||||
@Override
|
||||
public void onDownloadRemoved(@NonNull DownloadManager downloadManager, Download download) {
|
||||
DownloaderManager.deleteDatabase(download.request.id);
|
||||
downloaderManager.removeRequestDownload(download);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue