[Android] Add video browser Play All FAB

Alexandre Perraud git at videolan.org
Wed Dec 7 16:31:43 CET 2016


vlc-android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Tue Dec  6 15:41:43 2016 +0100| [a13f91e42fa2c73ed2b2fb528e1b25513d3f584f] | committer: Alexandre Perraud

Add video browser Play All FAB

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

 .../videolan/vlc/gui/video/VideoGridFragment.java  | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index adea3a9..1f35441 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -33,6 +33,7 @@ import android.os.Handler;
 import android.os.Message;
 import android.preference.PreferenceManager;
 import android.support.annotation.MainThread;
+import android.support.design.widget.FloatingActionButton;
 import android.support.v4.content.LocalBroadcastManager;
 import android.support.v7.view.ActionMode;
 import android.util.DisplayMetrics;
@@ -88,6 +89,8 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
     private VideoListAdapter mVideoAdapter;
     private DividerItemDecoration mDividerItemDecoration;
 
+    private FloatingActionButton mFabPlayAll;
+
     /* All subclasses of Fragment must include a public empty constructor. */
     public VideoGridFragment() { }
 
@@ -136,6 +139,20 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
         }
     }
 
+
+    public void onStart() {
+        super.onStart();
+        mFabPlayAll = (FloatingActionButton)getActivity().findViewById(R.id.fab);
+        mFabPlayAll.setImageResource(R.drawable.ic_fab_play);
+        setFabPlayAllVisibility(true);
+        mFabPlayAll.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                onFabPlayAllClick(v);
+            }
+        });
+    }
+
     @Override
     public void onResume() {
         super.onResume();
@@ -316,6 +333,15 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
         }
     }
 
+    public void setFabPlayAllVisibility(boolean enable) {
+        mFabPlayAll.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
+    }
+
+    public void onFabPlayAllClick(View view) {
+        ArrayList<MediaWrapper> playList = new ArrayList<>();
+        MediaUtils.openList(getActivity(), playList, mVideoAdapter.getListWithPosition(playList, 0));
+    }
+
     @Override
     public void onMediaUpdated(final MediaWrapper[] mediaList) {
         updateItems(mediaList);
@@ -472,6 +498,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
             stopActionMode();
             return false;
         }
+        setFabPlayAllVisibility(false);
         boolean honeComb = AndroidUtil.isHoneycombOrLater();
         int count = mVideoAdapter.getSelectedPositions().size();
         menu.findItem(R.id.action_video_info).setVisible(count == 1);
@@ -516,6 +543,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
     @Override
     public void onDestroyActionMode(ActionMode mode) {
         mVideoAdapter.setActionMode(false);
+        setFabPlayAllVisibility(true);
     }
 
     private static final int UPDATE_LIST = 14;



More information about the Android mailing list