[Android] Video player: prevent IllegalArgumentException

Geoffrey Métais git at videolan.org
Thu Oct 17 11:55:24 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 17 10:19:22 2019 +0200| [6c4c0dc5fc8b83dfa038f1a288455804adcd2144] | committer: Geoffrey Métais

Video player: prevent IllegalArgumentException

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

 vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
index 5dfdcfbf5..f3003c893 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
@@ -134,8 +134,11 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
                 val xgesturesize = xChanged / screenConfig.metrics.xdpi * 2.54f
                 val deltaY = ((abs(initTouchY - event.y) / screenConfig.metrics.xdpi + 0.5f) * 2f).coerceAtLeast(1f)
 
-                val xTouch = event.x.roundToInt()
-                val yTouch = event.y.roundToInt()
+                val (xTouch, yTouch) = try {
+                    Pair(event.x.roundToInt(), event.y.roundToInt())
+                } catch (e: IllegalArgumentException) {
+                    return false
+                }
 
                 val now = System.currentTimeMillis()
                 when (event.action) {



More information about the Android mailing list