Fix issues with downloading files without titles (in artists, albums, movie titles or TV Show titles)

This commit is contained in:
Synced Synapse 2016-10-11 20:05:23 +01:00
parent 034b969f3b
commit 83ed7b3cb6
3 changed files with 16 additions and 5 deletions

View File

@ -338,6 +338,11 @@ public class ArtistOverviewFragment extends AbstractDetailsFragment
} while (cursor.moveToNext());
}
if (songInfoList.size() == 0) {
Toast.makeText(getActivity(), R.string.no_songs_to_download, Toast.LENGTH_LONG);
return;
}
// Check if the directory exists and whether to overwrite it
File file = new File(songInfoList.get(0).getAbsoluteDirectoryPath());
if (file.exists()) {

View File

@ -45,6 +45,10 @@ public class FileDownloadHelper {
public static final int OVERWRITE_FILES = 0,
DOWNLOAD_WITH_NEW_NAME = 1;
public static final String NO_ARTIST_DIR = "No artist",
NO_MOVIE_TITLE_DIR = "No title",
NO_TVSHOW_TITLE_DIR = "No title";
public static abstract class MediaInfo {
public final String fileName;
@ -120,8 +124,8 @@ public class FileDownloadHelper {
}
public String getRelativeDirectoryPath() {
return (TextUtils.isEmpty(album) || TextUtils.isEmpty(artist)) ?
null : artist + "/" + album;
return (TextUtils.isEmpty(artist) ? NO_ARTIST_DIR :
TextUtils.isEmpty(album) ? artist : artist + "/" + album);
}
public String getDownloadFileName() {
@ -153,7 +157,7 @@ public class FileDownloadHelper {
public String getRelativeDirectoryPath() {
return (TextUtils.isEmpty(title)) ?
null : title;
NO_MOVIE_TITLE_DIR : title;
}
public String getDownloadFileName() {
@ -193,10 +197,10 @@ public class FileDownloadHelper {
public String getRelativeDirectoryPath() {
if (season > 0) {
return (TextUtils.isEmpty(tvshowTitle)) ?
null : tvshowTitle + "/Season" + String.valueOf(season);
NO_TVSHOW_TITLE_DIR : tvshowTitle + "/Season" + String.valueOf(season);
} else {
return (TextUtils.isEmpty(tvshowTitle)) ?
null : tvshowTitle;
NO_TVSHOW_TITLE_DIR : tvshowTitle;
}
}

View File

@ -387,4 +387,6 @@
<string name="read_phone_state_permission_denied">Permission denied. Won\'t be able to pause playback during calls.</string>
<string name="write_storage_permission_denied">Permission denied. Won\'t be able to download files.</string>
<string name="no_songs_to_download">No songs to download</string>
</resources>