diff --git a/app/src/main/java/org/xbmc/kore/ui/sections/file/MediaFileListFragment.java b/app/src/main/java/org/xbmc/kore/ui/sections/file/MediaFileListFragment.java index d06abd6..b2da5e6 100644 --- a/app/src/main/java/org/xbmc/kore/ui/sections/file/MediaFileListFragment.java +++ b/app/src/main/java/org/xbmc/kore/ui/sections/file/MediaFileListFragment.java @@ -323,7 +323,7 @@ public class MediaFileListFragment extends AbstractListFragment { Files.GetDirectory action = new Files.GetDirectory(dir.file, mediaType, - new ListType.Sort(ListType.Sort.SORT_METHOD_LABEL, true, true), + new ListType.Sort(ListType.Sort.SORT_METHOD_PATH, true, true), properties); action.execute(hostManager.getConnection(), new ApiCallback>() { @Override @@ -474,6 +474,27 @@ public class MediaFileListFragment extends AbstractListFragment { return p; } + /** + * return the filename of a given path, if path is a directory, return directory name + * @param path of the current file + * @return filename or directory name + */ + public static String getFilenameFromPath(final String path) { + String p = path; + String pathSymbol = "/"; // unix style + if (path.contains("\\")) { + pathSymbol = "\\"; // windows style + } + // if path ends with /, remove it + if (path.endsWith(pathSymbol)) { + p = path.substring(0, path.length() - 1); + } + if (p.lastIndexOf(pathSymbol) != -1) { + p = p.substring(p.lastIndexOf(pathSymbol)+1); + } + return p; + } + @Override public void onRefresh() { @@ -511,15 +532,14 @@ public class MediaFileListFragment extends AbstractListFragment { case R.id.action_play_from_this_item: mediaQueueFileLocation.clear(); FileLocation fl; + // start playing the selected one, then queue the rest + mediaQueueFileLocation.add(loc); for (int i = position + 1; i < fileLocationItems.size(); i++) { fl = fileLocationItems.get(i); if (!fl.isDirectory) { mediaQueueFileLocation.add(fl); } } - // start playing the selected one, then queue the rest make sure to queue - // the selected on last so the it does not lose its place in the queue - mediaQueueFileLocation.add(loc); playMediaFile(loc.file); return true; } @@ -717,9 +737,17 @@ public class MediaFileListFragment extends AbstractListFragment { artUrl = itemFile.thumbnail; break; case ListType.ItemBase.TYPE_ALBUM: + title = itemFile.displayartist + " | " + itemFile.album; + details = getFilenameFromPath(itemFile.file); + artUrl = itemFile.thumbnail; + sizeDuration = (itemFile.size > 0) && (itemFile.duration > 0) ? + UIUtils.formatFileSize(itemFile.size) + " | " + UIUtils.formatTime(itemFile.duration) : + (itemFile.size > 0) ? UIUtils.formatFileSize(itemFile.size) : + (itemFile.duration > 0)? UIUtils.formatTime(itemFile.duration) : null; + break; case ListType.ItemBase.TYPE_SONG: title = itemFile.label; - details = itemFile.displayartist + " | " + itemFile.album; + details = getFilenameFromPath(itemFile.file); artUrl = itemFile.thumbnail; sizeDuration = (itemFile.size > 0) && (itemFile.duration > 0) ? UIUtils.formatFileSize(itemFile.size) + " | " + UIUtils.formatTime(itemFile.duration) :