mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
Fix downloaded item implementation
This commit is contained in:
parent
93d61be594
commit
b24903fd47
9 changed files with 25 additions and 22 deletions
|
|
@ -43,10 +43,12 @@ public class DownloadTracker {
|
|||
public DownloadTracker(Context context, HttpDataSource.Factory httpDataSourceFactory, DownloadManager downloadManager) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.httpDataSourceFactory = httpDataSourceFactory;
|
||||
|
||||
listeners = new CopyOnWriteArraySet<>();
|
||||
downloads = new HashMap<>();
|
||||
downloadIndex = downloadManager.getDownloadIndex();
|
||||
trackSelectorParameters = DownloadHelper.getDefaultTrackSelectorParameters(context);
|
||||
|
||||
downloadManager.addListener(new DownloadManagerListener());
|
||||
loadDownloads();
|
||||
}
|
||||
|
|
@ -80,11 +82,9 @@ public class DownloadTracker {
|
|||
@Nullable Download download = downloads.get(checkNotNull(mediaItem.playbackProperties).uri);
|
||||
|
||||
if (download != null && download.state != Download.STATE_FAILED) {
|
||||
song.setOffline(false);
|
||||
DownloadService.sendRemoveDownload(context, DownloaderService.class, download.request.id, false);
|
||||
downloadRepository.delete(MappingUtil.mapToDownload(song));
|
||||
} else {
|
||||
song.setOffline(true);
|
||||
DownloadService.sendAddDownload(context, DownloaderService.class, getDownloadRequest(song.getId(), mediaItem.playbackProperties.uri), false);
|
||||
downloadRepository.insert(MappingUtil.mapToDownload(song));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class DownloaderService extends DownloadService {
|
|||
@Override
|
||||
@NonNull
|
||||
protected Notification getForegroundNotification(@NonNull List<Download> downloads) {
|
||||
return DownloadUtil.getDownloadNotificationHelper(this).buildProgressNotification(this, R.drawable.ic_downloading, null, null, downloads);
|
||||
return DownloadUtil.getDownloadNotificationHelper(this).buildProgressNotification(this, R.drawable.ic_download, null, null, downloads);
|
||||
}
|
||||
|
||||
private static final class TerminalStateNotificationHelper implements DownloadManager.Listener {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue