Fix gestureDectector on main crashing sometimes

This commit is contained in:
Jays2Kings 2021-04-10 02:04:35 -04:00
parent 2a8049fb18
commit 8f55dcc859

View File

@ -95,7 +95,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
private set private set
private var searchDrawable: Drawable? = null private var searchDrawable: Drawable? = null
private var dismissDrawable: Drawable? = null private var dismissDrawable: Drawable? = null
private lateinit var gestureDetector: GestureDetectorCompat private var gestureDetector: GestureDetectorCompat? = null
private var snackBar: Snackbar? = null private var snackBar: Snackbar? = null
private var extraViewForUndo: View? = null private var extraViewForUndo: View? = null
@ -591,7 +591,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
} }
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
gestureDetector.onTouchEvent(ev) gestureDetector?.onTouchEvent(ev)
if (ev?.action == MotionEvent.ACTION_DOWN) { if (ev?.action == MotionEvent.ACTION_DOWN) {
if (snackBar != null && snackBar!!.isShown) { if (snackBar != null && snackBar!!.isShown) {
val sRect = Rect() val sRect = Rect()