[Android] Sanity check on action menu events

Geoffrey Métais git at videolan.org
Tue Oct 1 14:44:44 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 30 15:30:19 2019 +0200| [1efdd35671464f04f5fb1dd37fc8b8db5f88766e] | committer: Geoffrey Métais

Sanity check on action menu events

(cherry picked from commit f2e3f20f0a7700799c2473ca8755ff1e0a402480)

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

 vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt                 | 2 ++
 vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt                | 1 +
 vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt          | 1 +
 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt     | 2 ++
 vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt         | 2 ++
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt         | 2 ++
 vlc-android/src/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt | 2 ++
 7 files changed, 12 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
index ffeaa4176..e7e9c1ecf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
@@ -36,6 +36,7 @@ import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.tools.KeyHelper
 import org.videolan.tools.MultiSelectHelper
+import org.videolan.tools.isStarted
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.browser.MediaBrowserFragment
 import org.videolan.vlc.gui.helpers.UiTools
@@ -169,6 +170,7 @@ class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHis
     }
 
     override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
+        if (!isStarted()) return false
         val selection = multiSelectHelper.getSelection()
         if (selection.isNotEmpty()) {
             when (item.itemId) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
index 4ab50356d..7d3743055 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.kt
@@ -275,6 +275,7 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler, IL
     }
 
     override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
+        if (!isStarted()) return false
         val list = audioBrowserAdapter.multiSelectHelper.getSelection()
         val tracks = ArrayList<AbstractMediaWrapper>()
         for (mediaItem in list)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
index 3d5e0424c..6ec608c7a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.kt
@@ -217,6 +217,7 @@ abstract class BaseAudioBrowser<T : SortableModel> : MediaBrowserFragment<T>(),
     }
 
     override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
+        if (!isStarted()) return false
         val list = getCurrentAdapter()?.multiSelectHelper?.getSelection()
         stopActionMode()
         if (!list.isNullOrEmpty()) launch {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index c36b9bf95..3d2ba8c4b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -41,6 +41,7 @@ import kotlinx.coroutines.*
 import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.tools.MultiSelectHelper
+import org.videolan.tools.isStarted
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.DirectoryBrowserBinding
 import org.videolan.vlc.gui.AudioPlayerContainerActivity
@@ -341,6 +342,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
     }
 
     override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
+        if (!isStarted()) return false
         val list = adapter.multiSelectHelper.getSelection() as? List<AbstractMediaWrapper> ?: return false
         if (list.isNotEmpty()) {
             when (item.itemId) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
index 07d85b764..2d52a65ff 100644
--- a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
@@ -12,6 +12,7 @@ import kotlinx.coroutines.*
 import kotlinx.coroutines.channels.actor
 import org.videolan.medialibrary.interfaces.media.AbstractFolder
 import org.videolan.tools.MultiSelectHelper
+import org.videolan.tools.isStarted
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.FoldersFragmentBinding
 import org.videolan.vlc.gui.SecondaryActivity
@@ -158,6 +159,7 @@ class FoldersFragment : MediaBrowserFragment<FoldersViewModel>(), CtxActionRecei
     }
 
     override fun onActionItemClicked(mode: ActionMode?, item: MenuItem) : Boolean {
+        if (!isStarted()) return false
         val selection = adapter.multiSelectHelper.getSelection()
         when (item.itemId) {
             R.id.action_folder_play -> viewModel.playSelection(selection)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index de116249d..e1f3844da 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -44,6 +44,7 @@ import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
 import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.tools.MultiSelectHelper
+import org.videolan.tools.isStarted
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.VideoGridBinding
 import org.videolan.vlc.gui.ContentActivity
@@ -291,6 +292,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
     }
 
     override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
+        if (!isStarted()) return false
         val list = ArrayList<AbstractMediaWrapper>()
         for (mw in multiSelectHelper.getSelection()) {
             list.add(mw)
diff --git a/vlc-android/src/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt b/vlc-android/src/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt
index fa87a0bd0..af141c89d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt
@@ -12,6 +12,7 @@ import kotlinx.coroutines.*
 import kotlinx.coroutines.channels.actor
 import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup
 import org.videolan.tools.MultiSelectHelper
+import org.videolan.tools.isStarted
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.VideogroupsFragmentBinding
 import org.videolan.vlc.gui.SecondaryActivity
@@ -122,6 +123,7 @@ class VideoGroupsFragment : MediaBrowserFragment<VideogroupsViewModel>(), CtxAct
     }
 
     override fun onActionItemClicked(mode: ActionMode?, item: MenuItem): Boolean {
+        if (!isStarted()) return false
         val selection = adapter.multiSelectHelper.getSelection()
         when (item.itemId) {
             R.id.action_folder_play -> viewModel.playSelection(selection)



More information about the Android mailing list