[Android] TV: Fix playlist sorting in videos
Geoffrey Métais
git at videolan.org
Mon Feb 15 10:06:35 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 15 10:06:06 2016 +0100| [4df7dc0271a29a6c55b511f915f6bfab87ba6868] | committer: Geoffrey Métais
TV: Fix playlist sorting in videos
> https://code.videolan.org/videolan/vlc-android/commit/4df7dc0271a29a6c55b511f915f6bfab87ba6868
---
.../vlc/gui/tv/browser/VideoBrowserFragment.java | 31 ++++++++++++++++------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VideoBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VideoBrowserFragment.java
index 4dbfec9..2532c63 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VideoBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VideoBrowserFragment.java
@@ -30,6 +30,8 @@ import android.support.v17.leanback.widget.Presenter;
import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.RowPresenter;
+import org.videolan.vlc.VLCApplication;
+import org.videolan.vlc.gui.helpers.MediaComparators;
import org.videolan.vlc.gui.tv.MainTvActivity;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
@@ -37,6 +39,7 @@ import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.media.Thumbnailer;
import java.util.ArrayList;
+import java.util.Collections;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class VideoBrowserFragment extends SortedBrowserFragment {
@@ -65,14 +68,26 @@ public class VideoBrowserFragment extends SortedBrowserFragment {
@Override
protected void browse() {
- mVideos = MediaLibrary.getInstance().getVideoItems();
- MediaWrapper media;
- for (int i = 0 ; i < mVideos.size() ; ++i) {
- media = mVideos.get(i);
- addMedia(media);
- mMediaIndex.put(media.getLocation(), Integer.valueOf(i));
- }
- sort();
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ mVideos = MediaLibrary.getInstance().getVideoItems();
+ Collections.sort(mVideos, MediaComparators.byName);
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ MediaWrapper media;
+ for (int i = 0; i < mVideos.size(); ++i) {
+ media = mVideos.get(i);
+ addMedia(media);
+ mMediaIndex.put(media.getLocation(), i);
+ }
+ mHandler.sendEmptyMessage(UPDATE_DISPLAY);
+ }
+ });
+ }
+ });
+
}
@Override
More information about the Android
mailing list