diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-08-14 20:30:28 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-08-14 20:30:28 -0700 |
commit | a717d2e6708561bec917758ef324172c72a0d3c9 (patch) | |
tree | 4880a6eab37e7cae88fb6f128a56be59ccc6fa99 /src | |
parent | 16bd7e7f76870c86c39e8fe8a0dae7f9fb13f090 (diff) | |
parent | 5034ab86a0663f4a4d81556bcf0f14069a33b7b3 (diff) | |
download | dsub-a717d2e6708561bec917758ef324172c72a0d3c9.tar.gz dsub-a717d2e6708561bec917758ef324172c72a0d3c9.tar.bz2 dsub-a717d2e6708561bec917758ef324172c72a0d3c9.zip |
Merge branch 'master' of https://github.com/daneren2005/Subsonic into CacheUpdate
Diffstat (limited to 'src')
5 files changed, 32 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 5f98d489..516c4c59 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -931,7 +931,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }.execute();
}
- protected void createNewPlaylist(final List<MusicDirectory.Entry> songs, boolean getSuggestion) {
+ protected void createNewPlaylist(final List<MusicDirectory.Entry> songs, final boolean getSuggestion) {
View layout = context.getLayoutInflater().inflate(R.layout.save_playlist, null);
final EditText playlistNameView = (EditText) layout.findViewById(R.id.save_playlist_name);
final CheckBox overwriteCheckBox = (CheckBox) layout.findViewById(R.id.save_playlist_overwrite);
@@ -963,10 +963,18 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR .setPositiveButton(R.string.common_save, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
+ String playlistName = String.valueOf(playlistNameView.getText());
if(overwriteCheckBox.isChecked()) {
- overwritePlaylist(songs, String.valueOf(playlistNameView.getText()), getDownloadService().getSuggestedPlaylistId());
+ overwritePlaylist(songs, playlistName, getDownloadService().getSuggestedPlaylistId());
} else {
- createNewPlaylist(songs, String.valueOf(playlistNameView.getText()));
+ createNewPlaylist(songs, playlistName);
+
+ if(getSuggestion) {
+ DownloadService downloadService = getDownloadService();
+ if(downloadService != null) {
+ downloadService.setSuggestedPlaylistName(playlistName, null);
+ }
+ }
}
}
})
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 5f58e7fa..76e2dd89 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -409,6 +409,9 @@ public class DownloadService extends Service { this.toDelete.add(forSong(entry)); } } + + suggestedPlaylistName = prefs.getString(Constants.PREFERENCES_KEY_PLAYLIST_NAME, null); + suggestedPlaylistId = prefs.getString(Constants.PREFERENCES_KEY_PLAYLIST_ID, null); } public synchronized void setRemovePlayed(boolean enabled) { @@ -1152,6 +1155,11 @@ public class DownloadService extends Service { public void setSuggestedPlaylistName(String name, String id) { this.suggestedPlaylistName = name; this.suggestedPlaylistId = id; + + SharedPreferences.Editor editor = Util.getPreferences(this).edit(); + editor.putString(Constants.PREFERENCES_KEY_PLAYLIST_NAME, name); + editor.putString(Constants.PREFERENCES_KEY_PLAYLIST_ID, id); + editor.commit(); } public String getSuggestedPlaylistName() { diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index 0f9d78b9..a11d2448 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -141,6 +141,8 @@ public final class Constants { public static final String PREFERENCES_KEY_PLAY_NOW_AFTER = "playNowAfter"; public static final String PREFERENCES_KEY_LARGE_ALBUM_ART = "largeAlbumArt"; public static final String PREFERENCES_KEY_ADMIN_ENABLED = "adminEnabled"; + public static final String PREFERENCES_KEY_PLAYLIST_NAME = "suggestedPlaylistName"; + public static final String PREFERENCES_KEY_PLAYLIST_ID = "suggestedPlaylistId"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 1db6e9c9..1ea1a3be 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -183,23 +183,30 @@ public final class Util { int newInstance = instance + 1; + // Get what the +1 server details are String server = prefs.getString(Constants.PREFERENCES_KEY_SERVER_KEY + newInstance, null); String serverName = prefs.getString(Constants.PREFERENCES_KEY_SERVER_NAME + newInstance, null); String serverUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_URL + newInstance, null); String userName = prefs.getString(Constants.PREFERENCES_KEY_USERNAME + newInstance, null); String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + newInstance, null); + String musicFolderId = prefs.getString(Constants.PREFERENCES_KEY_MUSIC_FOLDER_ID + newInstance, null); + // Store the +1 server details in the to be deleted instance editor.putString(Constants.PREFERENCES_KEY_SERVER_KEY + instance, server); editor.putString(Constants.PREFERENCES_KEY_SERVER_NAME + instance, serverName); editor.putString(Constants.PREFERENCES_KEY_SERVER_URL + instance, serverUrl); editor.putString(Constants.PREFERENCES_KEY_USERNAME + instance, userName); editor.putString(Constants.PREFERENCES_KEY_PASSWORD + instance, password); + editor.putString(Constants.PREFERENCES_KEY_MUSIC_FOLDER_ID + instance, musicFolderId); + // Delete the +1 server instance + // Calling method will loop up to fill this in if +2 server exists editor.putString(Constants.PREFERENCES_KEY_SERVER_KEY + newInstance, null); editor.putString(Constants.PREFERENCES_KEY_SERVER_NAME + newInstance, null); editor.putString(Constants.PREFERENCES_KEY_SERVER_URL + newInstance, null); editor.putString(Constants.PREFERENCES_KEY_USERNAME + newInstance, null); editor.putString(Constants.PREFERENCES_KEY_PASSWORD + newInstance, null); + editor.putString(Constants.PREFERENCES_KEY_MUSIC_FOLDER_ID + newInstance, null); editor.commit(); if (instance == activeInstance) { diff --git a/src/github/daneren2005/dsub/view/SongView.java b/src/github/daneren2005/dsub/view/SongView.java index e6156ceb..55eff6f1 100644 --- a/src/github/daneren2005/dsub/view/SongView.java +++ b/src/github/daneren2005/dsub/view/SongView.java @@ -90,8 +90,9 @@ public class SongView extends UpdateView implements Checkable { StringBuilder artist = new StringBuilder(40); - if(!song.isVideo()) { - if(song instanceof PodcastEpisode) { + boolean isPodcast = song instanceof PodcastEpisode; + if(!song.isVideo() || isPodcast) { + if(isPodcast) { String date = ((PodcastEpisode)song).getDate(); if(date != null) { int index = date.indexOf(" "); @@ -102,7 +103,7 @@ public class SongView extends UpdateView implements Checkable { artist.append(song.getArtist()); } - if(song instanceof PodcastEpisode) { + if(isPodcast) { String status = ((PodcastEpisode) song).getStatus(); int statusRes = -1; |