[Android] Fix video grid context menu for groups

Geoffrey Métais git at videolan.org
Mon Sep 24 17:23:17 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 24 17:22:48 2018 +0200| [ec14f4ee976de9b75caac6293b426ae73e13eb1b] | committer: Geoffrey Métais

Fix video grid context menu for groups

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

 .../org/videolan/vlc/gui/video/VideoGridFragment.java    | 16 +++++++++-------
 vlc-android/src/org/videolan/vlc/util/Constants.kt       |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

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 dbcba700f..105ae2478 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -31,7 +31,6 @@ import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.preference.PreferenceManager;
 import android.support.annotation.MainThread;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
@@ -356,8 +355,9 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
     @Override
     public void onCtxClick(View v, int position, MediaLibraryItem item) {
         final MediaWrapper mw = (MediaWrapper) item;
-        int flags = mw.getType() == MediaWrapper.TYPE_GROUP ? Constants.CTX_VIDEO_GOUP_FLAGS : Constants.CTX_VIDEO_FLAGS;
-        if (mw.getTime() != 0l) flags |= Constants.CTX_PLAY_FROM_START;
+        final boolean group = mw.getType() == MediaWrapper.TYPE_GROUP;
+        int flags = group ? Constants.CTX_VIDEO_GOUP_FLAGS : Constants.CTX_VIDEO_FLAGS;
+        if (mw.getTime() != 0l && !group) flags |= Constants.CTX_PLAY_FROM_START;
         if (mActionMode == null) ContextSheetKt.showContext(requireActivity(), this, position, item.getTitle(), flags);
     }
 
@@ -379,6 +379,8 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
         if (position >= mAdapter.getItemCount()) return;
         final MediaWrapper media = mAdapter.getItem(position);
         if (media == null) return;
+        final Activity activity = getActivity();
+        if (activity == null) return;
         switch (option){
             case Constants.CTX_PLAY_FROM_START:
                 playVideo(media, true);
@@ -388,7 +390,7 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
                 break;
             case Constants.CTX_PLAY_ALL:
                 final List<MediaWrapper> playList = new ArrayList<>();
-                MediaUtils.INSTANCE.openList(getActivity(), playList, viewModel.getListWithPosition(playList, position));
+                MediaUtils.INSTANCE.openList(activity, playList, viewModel.getListWithPosition(playList, position));
                 break;
             case Constants.CTX_INFORMATION:
                 showInfoDialog(media);
@@ -397,11 +399,11 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
                 removeItem(media);
                 break;
             case Constants.CTX_PLAY_GROUP:
-                MediaUtils.INSTANCE.openList(getActivity(), ((MediaGroup) media).getAll(), 0);
+                MediaUtils.INSTANCE.openList(activity, ((MediaGroup) media).getAll(), 0);
                 break;
             case Constants.CTX_APPEND:
-                if (media instanceof MediaGroup) MediaUtils.INSTANCE.appendMedia(getActivity(), ((MediaGroup)media).getAll());
-                else MediaUtils.INSTANCE.appendMedia(getActivity(), media);
+                if (media instanceof MediaGroup) MediaUtils.INSTANCE.appendMedia(activity, ((MediaGroup)media).getAll());
+                else MediaUtils.INSTANCE.appendMedia(activity, media);
                 break;
             case Constants.CTX_DOWNLOAD_SUBTITLES:
                 MediaUtils.INSTANCE.getSubs(requireActivity(), media);
diff --git a/vlc-android/src/org/videolan/vlc/util/Constants.kt b/vlc-android/src/org/videolan/vlc/util/Constants.kt
index 2f46cbe2c..b81bf84e3 100644
--- a/vlc-android/src/org/videolan/vlc/util/Constants.kt
+++ b/vlc-android/src/org/videolan/vlc/util/Constants.kt
@@ -160,7 +160,7 @@ const val CTX_TRACK_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_INF
 const val CTX_AUDIO_FLAGS = CTX_PLAY or CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST
 const val CTX_PLAYLIST_FLAGS = CTX_AUDIO_FLAGS or CTX_DELETE
 const val CTX_PLAYLIST_ITEM_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION or CTX_DELETE or CTX_SET_RINGTONE
-const val CTX_VIDEO_GOUP_FLAGS = CTX_APPEND or CTX_PLAY
+const val CTX_VIDEO_GOUP_FLAGS = CTX_APPEND or CTX_PLAY_GROUP
 
 // Database
 const val TYPE_NETWORK_FAV = 0



More information about the Android mailing list