Fix crash on some devices when browsing images and clicking on screen
Fixes #429
This commit is contained in:
parent
a683ba26e3
commit
7e201ba289
@ -0,0 +1,32 @@
|
|||||||
|
package org.cryptomator.presentation.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workaround for https://github.com/cryptomator/android/issues/429
|
||||||
|
* Source https://github.com/Baseflow/PhotoView/issues/31#issuecomment-19803926
|
||||||
|
*/
|
||||||
|
class ViewPagerWorkaround : ViewPager {
|
||||||
|
|
||||||
|
constructor(context: Context) : super(context)
|
||||||
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||||
|
|
||||||
|
override fun onTouchEvent(ev: MotionEvent?): Boolean {
|
||||||
|
return try {
|
||||||
|
super.onTouchEvent(ev)
|
||||||
|
} catch (ex: IllegalArgumentException) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
|
||||||
|
return try {
|
||||||
|
super.onInterceptTouchEvent(ev)
|
||||||
|
} catch (ex: IllegalArgumentException) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/colorBlack">
|
android:background="@color/colorBlack">
|
||||||
|
|
||||||
<androidx.viewpager.widget.ViewPager
|
<org.cryptomator.presentation.util.ViewPagerWorkaround
|
||||||
android:id="@+id/viewPager"
|
android:id="@+id/viewPager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user