[Android] History: fix double click outOfBoundsException
Duncan McNamara
git at videolan.org
Wed Jan 5 13:04:48 UTC 2022
vlc-android | branch: 3.4.x | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Jan 4 14:18:29 2022 +0100| [79d173ed39cc9094f1f9c579212fa4ead26ed88c] | committer: Nicolas Pomepuy
History: fix double click outOfBoundsException
When pressing on two history items at the same time, it sometimes tries
to access an item with position -1 which causes an outOfBoundsException.
Closes #2294
(cherry picked from commit 33116907613a30ac83517c81ea76019daa071f0e)
> https://code.videolan.org/videolan/vlc-android/commit/79d173ed39cc9094f1f9c579212fa4ead26ed88c
---
.../vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
index c74187655..69e68987a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
@@ -268,13 +268,15 @@ class MoreFragment : BaseFragment(), IRefreshable, IHistory, IDialogManager,
}
private fun Click.process() {
- val item = viewModel.dataset.get(position)
- when (this) {
- is SimpleClick -> onClick(position, item)
- is LongClick -> onLongClick(position, item)
- is ImageClick -> {
- if (actionMode != null) onClick(position, item)
- else onLongClick(position, item)
+ if (position >= 0) {
+ val item = viewModel.dataset.get(position)
+ when (this) {
+ is SimpleClick -> onClick(position, item)
+ is LongClick -> onLongClick(position, item)
+ is ImageClick -> {
+ if (actionMode != null) onClick(position, item)
+ else onLongClick(position, item)
+ }
}
}
}
More information about the Android
mailing list