diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-01-24 08:06:23 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-01-24 08:06:23 -0800 |
commit | f7a1afb0155d957ffaac2af54ddb25860523bd82 (patch) | |
tree | cd3236e91af423ddefe6c6bccb3f150929e55a6c /src/github | |
parent | 11e9575df92b561e620a8b0a31dae5ec0a9b1c90 (diff) | |
download | dsub-f7a1afb0155d957ffaac2af54ddb25860523bd82.tar.gz dsub-f7a1afb0155d957ffaac2af54ddb25860523bd82.tar.bz2 dsub-f7a1afb0155d957ffaac2af54ddb25860523bd82.zip |
#265 Mass unstar artists/albums, fix unstarring artist from starred screen
Diffstat (limited to 'src/github')
6 files changed, 44 insertions, 22 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index eb782163..f96bf578 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -873,31 +873,43 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
public void unstarSelected() {
- if(getSelectedSongs().size() == 0) {
- selectAll(true, false);
+ List<MusicDirectory.Entry> selected = getSelectedSongs();
+ if(selected.size() == 0) {
+ selected = entries;
}
- final List<MusicDirectory.Entry> selected = getSelectedSongs();
if(selected.size() == 0) {
return;
}
+ final List<MusicDirectory.Entry> unstar = new ArrayList<MusicDirectory.Entry>();
+ unstar.addAll(selected);
new LoadingTask<Void>(context, true) {
@Override
protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
List<String> ids = new ArrayList<String>();
- for(MusicDirectory.Entry entry: selected) {
- ids.add(entry.getId());
+ List<String> artists = new ArrayList<String>();
+ List<String> albums = new ArrayList<String>();
+ for(MusicDirectory.Entry entry: unstar) {
+ if(entry.isDirectory()) {
+ if(entry.getArtist() == null || entry.getParent() == null) {
+ artists.add(entry.getId());
+ } else {
+ albums.add(entry.getId());
+ }
+ } else {
+ ids.add(entry.getId());
+ }
}
- musicService.setStarred(ids, null, null, false, context, this);
+ musicService.setStarred(ids, artists, albums, false, context, this);
return null;
}
@Override
protected void done(Void result) {
- Util.toast(context, context.getResources().getString(R.string.starring_content_unstarred, Integer.toString(selected.size())));
+ Util.toast(context, context.getResources().getString(R.string.starring_content_unstarred, Integer.toString(unstar.size())));
- for(MusicDirectory.Entry entry: selected) {
+ for(MusicDirectory.Entry entry: unstar) {
entries.remove(entry);
}
entryAdapter.notifyDataSetChanged();
@@ -910,7 +922,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter if (error instanceof OfflineException || error instanceof ServerTooOldException) {
msg = getErrorMessage(error);
} else {
- msg = context.getResources().getString(R.string.starring_content_error, Integer.toString(selected.size())) + " " + getErrorMessage(error);
+ msg = context.getResources().getString(R.string.starring_content_error, Integer.toString(unstar.size())) + " " + getErrorMessage(error);
}
Util.toast(context, msg, false);
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index c99d5d1c..3ec1471f 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -599,7 +599,11 @@ public class SubsonicFragment extends Fragment { protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
if(entry.isDirectory() && Util.isTagBrowsing(context) && !Util.isOffline(context)) {
- musicService.setStarred(null, null, entry.getId(), starred, context, null);
+ if(entry.getParent() == null || entry.getArtist() == null) {
+ musicService.setStarred(null, Arrays.asList(entry.getId()), null, starred, context, null);
+ } else {
+ musicService.setStarred(null, null, Arrays.asList(entry.getId()), starred, context, null);
+ }
} else {
musicService.setStarred(Arrays.asList(entry.getId()), null, null, starred, context, null);
}
@@ -642,7 +646,7 @@ public class SubsonicFragment extends Fragment { protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
- musicService.setStarred(null, entry.getId(), null, starred, context, null);
+ musicService.setStarred(null, Arrays.asList(entry.getId()), null, starred, context, null);
} else {
musicService.setStarred(Arrays.asList(entry.getId()), null, null, starred, context, null);
}
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index 048e2827..b8b440d7 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -349,7 +349,7 @@ public class CachedMusicService implements MusicService { } @Override - public void setStarred(List<String> id, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception { + public void setStarred(List<String> id, List<String> artistId, List<String> albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception { musicService.setStarred(id, artistId, albumId, starred, context, progressListener); } diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java index a88dd04a..3674fd01 100644 --- a/src/github/daneren2005/dsub/service/MusicService.java +++ b/src/github/daneren2005/dsub/service/MusicService.java @@ -117,7 +117,7 @@ public interface MusicService { RemoteStatus setJukeboxGain(float gain, Context context, ProgressListener progressListener) throws Exception; - void setStarred(List<String> id, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception; + void setStarred(List<String> id, List<String> artistId, List<String> albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception; List<Share> getShares(Context context, ProgressListener progressListener) throws Exception; diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java index 10d3c311..a3cdd437 100644 --- a/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -559,7 +559,7 @@ public class OfflineMusicService extends RESTMusicService { } @Override - public void setStarred(List<String> ids, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception { + public void setStarred(List<String> ids, List<String> artistId, List<String> albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception { SharedPreferences prefs = Util.getPreferences(context); String cacheLocn = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null); diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index f4816bcd..43b5f887 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -821,13 +821,13 @@ public class RESTMusicService implements MusicService { } @Override - public void setStarred(List<String> ids, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception { + public void setStarred(List<String> ids, List<String> artistId, List<String> albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception { checkServerVersion(context, "1.8", "Starring is not supported."); List<String> names = new ArrayList<String>(); List<Object> values = new ArrayList<Object>(); - if(ids != null) { + if(ids != null && ids.size() > 0) { if(ids.size() > 1) { for (String id : ids) { names.add("id"); @@ -837,12 +837,18 @@ public class RESTMusicService implements MusicService { names.add("id"); values.add(getOfflineSongId(ids.get(0), context, progressListener)); } - } else if(artistId != null) { - names.add("artistId"); - values.add(artistId); - } else if(albumId != null) { - names.add("albumId"); - values.add(albumId); + } + if(artistId != null && artistId.size() > 0) { + for (String id : artistId) { + names.add("artistId"); + values.add(id); + } + } + if(albumId != null && albumId.size() > 0) { + for (String id : albumId) { + names.add("albumId"); + values.add(id); + } } Reader reader = getReader(context, progressListener, starred ? "star" : "unstar", null, names, values); |