Skip to content
Snippets Groups Projects
Commit f644ecef authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Sort media by type in TV Network Browser


Group by first letter, sort by name but folders first

(cherry picked from commit b6044fc2)
Signed-off-by: default avatarGeoffrey Métais <geoffrey.metais@gmail.com>
parent 5eb2f1ab
No related branches found
No related tags found
No related merge requests found
......@@ -160,7 +160,7 @@ public class NetworkBrowserFragment extends BrowseFragment implements BrowserFra
public void run() {
mMediaItemMap = new TreeMap<>(mMediaItemMap); //sort sections
for (ListItem item : mMediaItemMap.values()) {
Collections.sort(item.mediaList, MediaComparators.byName);
Collections.sort(item.mediaList, MediaComparators.byFileType);
}
mHandler.sendEmptyMessage(UPDATE_DISPLAY);
}
......
......@@ -35,6 +35,18 @@ public class MediaComparators {
return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
}
public static final Comparator<MediaWrapper> byFileType = new Comparator<MediaWrapper>() {
@Override
public int compare(MediaWrapper m1, MediaWrapper m2) {
int t1 = m1.getType(), t2= m2.getType();
if (t1 == MediaWrapper.TYPE_DIR && t2 != MediaWrapper.TYPE_DIR)
return -1;
if (t1 != MediaWrapper.TYPE_DIR && t2 == MediaWrapper.TYPE_DIR)
return 1;
return nullInsensitiveStringCompare(m1.getTitle(), m2.getTitle());
};
};
public static final Comparator<MediaWrapper> byName = new Comparator<MediaWrapper>() {
@Override
public int compare(MediaWrapper m1, MediaWrapper m2) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment