diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-10-17 16:59:35 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-10-17 16:59:35 -0700 |
commit | b53cff3acfb12980001c30cf262d8f74f4740e68 (patch) | |
tree | 3d1e9db60150c51aea5bfaf251ae281255b13a1b /app/src/main/java | |
parent | 811f2a397549ee8d819c39a75809f363d576d44e (diff) | |
download | dsub-b53cff3acfb12980001c30cf262d8f74f4740e68.tar.gz dsub-b53cff3acfb12980001c30cf262d8f74f4740e68.tar.bz2 dsub-b53cff3acfb12980001c30cf262d8f74f4740e68.zip |
Add some better error handling to saving playlists + log errors
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java | 24 |
1 files changed, 17 insertions, 7 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 e138f4dd..de230309 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -1135,16 +1135,24 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR final EditText playlistNameView = (EditText) layout.findViewById(R.id.save_playlist_name); final CheckBox overwriteCheckBox = (CheckBox) layout.findViewById(R.id.save_playlist_overwrite); if(getSuggestion) { - String playlistName = (getDownloadService() != null) ? getDownloadService().getSuggestedPlaylistName() : null; + DownloadService downloadService = getDownloadService(); + String playlistName = null; + String playlistId = null; + if(downloadService != null) { + playlistName = downloadService.getSuggestedPlaylistName(); + playlistId = downloadService.getSuggestedPlaylistId(); + } if (playlistName != null) { playlistNameView.setText(playlistName); - try { - if(ServerInfo.checkServerVersion(context, "1.8.0") && Integer.parseInt(getDownloadService().getSuggestedPlaylistId()) != -1) { - overwriteCheckBox.setChecked(true); - overwriteCheckBox.setVisibility(View.VISIBLE); + if(playlistId != null) { + try { + if (ServerInfo.checkServerVersion(context, "1.8.0") && Integer.parseInt(playlistId) != -1) { + overwriteCheckBox.setChecked(true); + overwriteCheckBox.setVisibility(View.VISIBLE); + } + } catch (Exception e) { + Log.i(TAG, "Playlist id isn't a integer, probably MusicCabinet", e); } - } catch(Exception e) { - Log.i(TAG, "Playlist id isn't a integer, probably MusicCabinet"); } } else { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); @@ -1205,6 +1213,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override protected void error(Throwable error) { String msg = context.getResources().getString(R.string.download_playlist_error) + " " + getErrorMessage(error); + Log.e(TAG, "Failed to create playlist", error); Util.toast(context, msg); } }.execute(); @@ -1234,6 +1243,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR msg = context.getResources().getString(R.string.download_playlist_error) + " " + getErrorMessage(error); } + Log.e(TAG, "Failed to overwrite playlist", error); Util.toast(context, msg, false); } }.execute(); |