[Android] History: fix double click outOfBoundsException
Duncan McNamara
git at videolan.org
Wed Jan 5 13:04:26 UTC 2022
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Jan 4 14:18:29 2022 +0100| [33116907613a30ac83517c81ea76019daa071f0e] | committer: Duncan McNamara
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
> https://code.videolan.org/videolan/vlc-android/commit/33116907613a30ac83517c81ea76019daa071f0e
---
.../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 3de51fd4b..ef90dcf67 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
@@ -269,13 +269,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