[Android] Prevent IndexOutOfBoundsException in Action Mode

Geoffrey Métais git at videolan.org
Thu Oct 12 11:12:57 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 12 10:56:33 2017 +0200| [47794006447b92f37f3f5958876a5d0d372268d6] | committer: Geoffrey Métais

Prevent IndexOutOfBoundsException in Action Mode

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

 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 32226b4cf..c041f31f3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -811,7 +811,8 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
             return false;
         }
         boolean single = this instanceof FileBrowserFragment && count == 1;
-        int type = single ? mAdapter.getSelection().get(0).getType() : -1;
+        final ArrayList<MediaWrapper> selection = single ? mAdapter.getSelection() : null;
+        int type = !Util.isListEmpty(selection) ? selection.get(0).getType() : -1;
         menu.findItem(R.id.action_mode_file_info).setVisible(single && (type == MediaWrapper.TYPE_AUDIO || type == MediaWrapper.TYPE_VIDEO));
         menu.findItem(R.id.action_mode_file_append).setVisible(mService.hasMedia());
         return true;



More information about the Android mailing list