aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-17 12:21:02 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-17 12:21:02 -0700
commit60e43049fbf4577d02fd2334711db4ba7c8638e5 (patch)
treeddcad29fd7aa1ae8e973f0191988443eaa262fd2
parentcbd0c4b83ef5c5a32d859525841042c702e279b8 (diff)
parentb9959f41efe45548757d0a7f1b1c9eb4ec9f9e92 (diff)
downloaddsub-60e43049fbf4577d02fd2334711db4ba7c8638e5.tar.gz
dsub-60e43049fbf4577d02fd2334711db4ba7c8638e5.tar.bz2
dsub-60e43049fbf4577d02fd2334711db4ba7c8638e5.zip
Merge branch 'master' of https://github.com/daneren2005/Subsonic into Bookmarks
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java5
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java22
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java29
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java6
-rw-r--r--src/github/daneren2005/dsub/view/SongView.java4
-rw-r--r--src/github/daneren2005/dsub/view/UpdateView.java14
6 files changed, 80 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 09a2e42b..ef9a6163 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -1064,6 +1064,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
}
musicService.setStarred(ids, artists, albums, parents, false, this, context);
+
+ for(MusicDirectory.Entry entry: unstar) {
+ setEntryStarred(entry, false);
+ }
+
return null;
}
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 516c4c59..580016bb 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -665,6 +665,8 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
musicService.setStarred(Arrays.asList(entry.getId()), null, null, parents, starred, null, context);
}
+ setEntryStarred(entry, starred);
+
return null;
}
@@ -690,6 +692,26 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
}.execute();
}
+ protected void setEntryStarred(MusicDirectory.Entry entry, boolean starred) {
+ DownloadService downloadService = DownloadService.getInstance();
+ if(downloadService != null && !entry.isDirectory()) {
+ List<DownloadFile> files = downloadService.getDownloads();
+ for(DownloadFile file: files) {
+ MusicDirectory.Entry check = file.getSong();
+ if(entry.getId().equals(check.getId())) {
+ check.setStarred(starred);
+ downloadService.serializeQueue();
+ break;
+ }
+ }
+ }
+
+ MusicDirectory.Entry find = UpdateView.findEntry(entry);
+ if(find != null) {
+ find.setStarred(starred);
+ }
+ }
+
public void toggleStarred(final Artist entry) {
final boolean starred = !entry.isStarred();
entry.setStarred(starred);
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index 027f6694..e97ffe24 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -386,6 +386,11 @@ public class CachedMusicService implements MusicService {
private void updateStarredList(Context context, List<Entry> list, final boolean starred, final boolean isTagBrowsing) {
for(final Entry entry: list) {
+ // Don't waste time when status is the same
+ if(entry.isStarred() == starred) {
+ continue;
+ }
+
String cacheName, parent = null;
boolean isArtist = false;
if(isTagBrowsing) {
@@ -595,6 +600,30 @@ public class CachedMusicService implements MusicService {
}
}.execute();
}
+
+ // Update playlist caches if there is at least one song to be starred
+ if(ids != null && ids.size() > 0) {
+ List<Playlist> playlists = FileUtil.deserialize(context, getCacheName(context, "playlist"), ArrayList.class);
+ for(Playlist playlist: playlists) {
+ new MusicDirectoryUpdater(context, "playlist", playlist.getId()) {
+ @Override
+ public boolean checkResult(Entry check) {
+ for (String id : checkIds) {
+ if (id.equals(check.getId())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public void updateResult(List<Entry> objects, Entry result) {
+ result.setStarred(starred);
+ }
+ }.execute();
+ }
+ }
}
@Override
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 76e2dd89..b311df6b 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -1598,6 +1598,12 @@ public class DownloadService extends Service {
}
}
+ public synchronized void serializeQueue() {
+ if(playerState == PlayerState.PAUSED) {
+ lifecycleSupport.serializeDownloadQueue();
+ }
+ }
+
private void handleError(Exception x) {
Log.w(TAG, "Media player error: " + x, x);
if(mediaPlayer != null) {
diff --git a/src/github/daneren2005/dsub/view/SongView.java b/src/github/daneren2005/dsub/view/SongView.java
index 55eff6f1..d5b7c0f2 100644
--- a/src/github/daneren2005/dsub/view/SongView.java
+++ b/src/github/daneren2005/dsub/view/SongView.java
@@ -248,4 +248,8 @@ public class SongView extends UpdateView implements Checkable {
public void toggle() {
checkedTextView.toggle();
}
+
+ public MusicDirectory.Entry getEntry() {
+ return song;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/UpdateView.java b/src/github/daneren2005/dsub/view/UpdateView.java
index f30ec42a..5f34a765 100644
--- a/src/github/daneren2005/dsub/view/UpdateView.java
+++ b/src/github/daneren2005/dsub/view/UpdateView.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.WeakHashMap;
+import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.util.SilentBackgroundTask;
@@ -211,6 +212,19 @@ public class UpdateView extends LinearLayout {
public static void removeActiveActivity() {
activeActivities--;
}
+
+ public static MusicDirectory.Entry findEntry(MusicDirectory.Entry entry) {
+ for(UpdateView view: INSTANCES.keySet()) {
+ if(view instanceof SongView) {
+ MusicDirectory.Entry check = ((SongView) view).getEntry();
+ if(check != null && entry != check && check.getId().equals(entry.getId())) {
+ return check;
+ }
+ }
+ }
+
+ return null;
+ }
protected void updateBackground() {