diff options
Diffstat (limited to 'app/src/main/java')
3 files changed, 24 insertions, 5 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java index 33d9bbff..bc2418eb 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -1694,7 +1694,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR MusicService musicService = MusicServiceFactory.getMusicService(context); musicService.deleteBookmark(entry, context, null); - new UpdateHelper.EntryInstanceUpdater(entry) { + new UpdateHelper.EntryInstanceUpdater(entry, DownloadService.METADATA_UPDATED_BOOKMARK) { @Override public void update(Entry found) { found.setBookmark(null); diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index ba473dfc..72e6064b 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1372,6 +1372,7 @@ public class DownloadService extends Service { if (playerState == PAUSED) { lifecycleSupport.serializeDownloadQueue(); + checkAddBookmark(true); } boolean show = playerState == PlayerState.STARTED; @@ -2423,8 +2424,11 @@ public class DownloadService extends Service { }.execute(); } } - + private void checkAddBookmark() { + checkAddBookmark(false); + } + private void checkAddBookmark(final boolean updateMetadata) { // Don't do anything if no current playing if(currentPlaying == null || !ServerInfo.canBookmark(this)) { return; @@ -2454,6 +2458,9 @@ public class DownloadService extends Service { if(found != null) { found.setBookmark(new Bookmark(position)); } + if(updateMetadata) { + onMetadataUpdate(METADATA_UPDATED_BOOKMARK); + } return null; } @@ -2637,6 +2644,7 @@ public class DownloadService extends Service { onSongsChanged(); onSongProgress(); onStateUpdate(); + onMetadataUpdate(METADATA_UPDATED_ALL); } }); } else { @@ -2749,10 +2757,10 @@ public class DownloadService extends Service { } } } - private void onMetadataUpdate() { + public void onMetadataUpdate() { onMetadataUpdate(METADATA_UPDATED_ALL); } - private void onMetadataUpdate(final int updateType) { + public void onMetadataUpdate(final int updateType) { synchronized(onSongChangedListeners) { for (final OnSongChangedListener listener : onSongChangedListeners) { handler.post(new Runnable() { diff --git a/app/src/main/java/github/daneren2005/dsub/util/UpdateHelper.java b/app/src/main/java/github/daneren2005/dsub/util/UpdateHelper.java index 725f0827..49d4f7b1 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/UpdateHelper.java +++ b/app/src/main/java/github/daneren2005/dsub/util/UpdateHelper.java @@ -255,10 +255,15 @@ public final class UpdateHelper { public static abstract class EntryInstanceUpdater { private Entry entry; + private int metadataUpdate = DownloadService.METADATA_UPDATED_ALL; public EntryInstanceUpdater(Entry entry) { this.entry = entry; } + public EntryInstanceUpdater(Entry entry, int metadataUpdate) { + this.entry = entry; + this.metadataUpdate = metadataUpdate; + } public abstract void update(Entry found); @@ -267,11 +272,17 @@ public final class UpdateHelper { if(downloadService != null && !entry.isDirectory()) { boolean serializeChanges = false; List<DownloadFile> downloadFiles = downloadService.getDownloads(); + DownloadFile currentPlaying = downloadService.getCurrentPlaying(); + for(DownloadFile file: downloadFiles) { Entry check = file.getSong(); if(entry.getId().equals(check.getId())) { - update(entry); + update(check); serializeChanges = true; + + if(currentPlaying != null && currentPlaying.getSong() != null && currentPlaying.getSong().getId().equals(entry.getId())) { + downloadService.onMetadataUpdate(metadataUpdate); + } } } |