[Android] Restore 'play all' vdeos for TV

Geoffrey Métais git at videolan.org
Thu Jan 21 15:10:26 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 21 11:33:13 2016 +0100| [cb13a855702dee7d27ae55e775b393cb857d9a01] | committer: Geoffrey Métais

Restore 'play all' vdeos for TV

> https://code.videolan.org/videolan/vlc-android/commit/cb13a855702dee7d27ae55e775b393cb857d9a01
---

 .../vlc/gui/tv/browser/SortedBrowserFragment.java   |  7 +++----
 .../vlc/gui/tv/browser/VideoBrowserFragment.java    | 21 +++++++++++++++++----
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
index 27bf0f4..05dd918 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
@@ -23,12 +23,12 @@
 
 package org.videolan.vlc.gui.tv.browser;
 
-import android.app.FragmentManager;
+import android.annotation.TargetApi;
 import android.content.Intent;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Message;
-import android.os.Parcelable;
 import android.support.v17.leanback.app.BrowseFragment;
 import android.support.v17.leanback.widget.ArrayObjectAdapter;
 import android.support.v17.leanback.widget.HeaderItem;
@@ -41,13 +41,11 @@ import android.support.v17.leanback.widget.Row;
 import android.support.v17.leanback.widget.RowPresenter;
 import android.support.v4.util.ArrayMap;
 import android.support.v4.util.SimpleArrayMap;
-import android.util.Log;
 
 import org.videolan.libvlc.Media;
 import org.videolan.libvlc.util.MediaBrowser;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
-import org.videolan.vlc.gui.browser.BaseBrowserFragment;
 import org.videolan.vlc.gui.helpers.MediaComparators;
 import org.videolan.vlc.gui.tv.CardPresenter;
 import org.videolan.vlc.gui.tv.DetailsActivity;
@@ -66,6 +64,7 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.TreeMap;
 
+ at TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 public abstract class SortedBrowserFragment extends BrowseFragment implements BrowserFragmentInterface, OnItemViewSelectedListener, OnItemViewClickedListener, IVideoBrowser, MediaBrowser.EventListener {
 
     public static final String TAG = "VLC/SortedBrowserFragment";
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 423b268..2ec1fc0 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
@@ -23,19 +23,26 @@
 
 package org.videolan.vlc.gui.tv.browser;
 
+import android.annotation.TargetApi;
+import android.os.Build;
 import android.os.Bundle;
+import android.support.v17.leanback.widget.Presenter;
+import android.support.v17.leanback.widget.Row;
+import android.support.v17.leanback.widget.RowPresenter;
 
-import org.videolan.libvlc.Media;
 import org.videolan.vlc.gui.tv.MainTvActivity;
 import org.videolan.vlc.media.MediaLibrary;
+import org.videolan.vlc.media.MediaUtils;
 import org.videolan.vlc.media.MediaWrapper;
 import org.videolan.vlc.media.Thumbnailer;
 
 import java.util.ArrayList;
 
+ at TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 public class VideoBrowserFragment extends SortedBrowserFragment {
 
     protected static Thumbnailer sThumbnailer;
+    private ArrayList<MediaWrapper> mVideos;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -69,10 +76,10 @@ public class VideoBrowserFragment extends SortedBrowserFragment {
 
     @Override
     protected void browse() {
-        ArrayList<MediaWrapper> videos = MediaLibrary.getInstance().getVideoItems();
+        mVideos = MediaLibrary.getInstance().getVideoItems();
         MediaWrapper media;
-        for (int i = 0 ; i < videos.size() ; ++i) {
-            media = videos.get(i);
+        for (int i = 0 ; i < mVideos.size() ; ++i) {
+            media = mVideos.get(i);
             String letter = media.getTitle().substring(0, 1).toUpperCase();
             if (mMediaItemMap.containsKey(letter)){
                 mMediaItemMap.get(letter).mediaList.add(media);
@@ -84,4 +91,10 @@ public class VideoBrowserFragment extends SortedBrowserFragment {
         }
         sort();
     }
+
+    @Override
+    public void onItemClicked(Presenter.ViewHolder viewHolder, Object item, RowPresenter.ViewHolder viewHolder1, Row row) {
+        MediaWrapper media = (MediaWrapper) item;
+        MediaUtils.openList(getActivity(), mVideos, mMediaIndex.get(media.getLocation()));
+    }
 }



More information about the Android mailing list