catching a weird exception

This commit is contained in:
tibbi 2022-11-09 14:44:53 +01:00
parent 25b7521b46
commit c05874b8d1
1 changed files with 6 additions and 2 deletions

View File

@ -384,8 +384,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun initModeSwitcher() {
val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() {
override fun onFling(event1: MotionEvent, event2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
// these can be null even if the docs say they cannot
if (event1 == null || event2 == null) {
// these can be null even if the docs say they cannot, getting event1.x in itself can cause crashes
try {
if (event1 == null || event2 == null || event1.x == null || event2.x == null) {
return true
}
} catch (e: NullPointerException) {
return true
}