mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
Graphic and functional improvements in the synchronization section
This commit is contained in:
parent
fdc104f70b
commit
67803b9149
19 changed files with 991 additions and 215 deletions
|
|
@ -66,8 +66,8 @@ public class DownloadTracker {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public DownloadRequest getDownloadRequest(Uri uri) {
|
||||
return new DownloadRequest.Builder(uri.toString(), uri).build();
|
||||
public DownloadRequest getDownloadRequest(String id, Uri uri) {
|
||||
return new DownloadRequest.Builder(id, uri).build();
|
||||
}
|
||||
|
||||
public void toggleDownload(List<Song> songs) {
|
||||
|
|
@ -83,7 +83,7 @@ public class DownloadTracker {
|
|||
DownloadService.sendRemoveDownload(context, DownloaderService.class, download.request.id, false);
|
||||
} else {
|
||||
song.setOffline(true);
|
||||
DownloadService.sendAddDownload(context, DownloaderService.class, getDownloadRequest(mediaItem.playbackProperties.uri), false);
|
||||
DownloadService.sendAddDownload(context, DownloaderService.class, getDownloadRequest(song.getId(), mediaItem.playbackProperties.uri), false);
|
||||
}
|
||||
|
||||
songRepository.setOfflineStatus(song);
|
||||
|
|
@ -113,22 +113,19 @@ public class DownloadTracker {
|
|||
}
|
||||
|
||||
private class DownloadManagerListener implements DownloadManager.Listener {
|
||||
|
||||
@Override
|
||||
public void onDownloadChanged(
|
||||
@NonNull DownloadManager downloadManager,
|
||||
@NonNull Download download,
|
||||
@Nullable Exception finalException) {
|
||||
public void onDownloadChanged(@NonNull DownloadManager downloadManager, @NonNull Download download, @Nullable Exception finalException) {
|
||||
downloads.put(download.request.uri, download);
|
||||
|
||||
for (Listener listener : listeners) {
|
||||
listener.onDownloadsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadRemoved(
|
||||
@NonNull DownloadManager downloadManager, @NonNull Download download) {
|
||||
public void onDownloadRemoved(@NonNull DownloadManager downloadManager, @NonNull Download download) {
|
||||
downloads.remove(download.request.uri);
|
||||
|
||||
for (Listener listener : listeners) {
|
||||
listener.onDownloadsChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ public class DownloaderService extends DownloadService {
|
|||
}
|
||||
|
||||
private static final class TerminalStateNotificationHelper implements DownloadManager.Listener {
|
||||
|
||||
private final Context context;
|
||||
private final DownloadNotificationHelper notificationHelper;
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ public class DownloaderService extends DownloadService {
|
|||
Notification notification;
|
||||
|
||||
if (download.state == Download.STATE_COMPLETED) {
|
||||
notification = notificationHelper.buildDownloadCompletedNotification(context, R.drawable.ic_done, null, Util.fromUtf8Bytes(download.request.data));
|
||||
notification = notificationHelper.buildDownloadCompletedNotification(context, R.drawable.ic_check_circle, null, Util.fromUtf8Bytes(download.request.data));
|
||||
} else if (download.state == Download.STATE_FAILED) {
|
||||
notification = notificationHelper.buildDownloadFailedNotification(context, R.drawable.ic_error, null, Util.fromUtf8Bytes(download.request.data));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue