From 81823ee221961a32e6a2e1424da3f69ad5efc251 Mon Sep 17 00:00:00 2001 From: MatPag Date: Thu, 9 Jan 2020 11:56:37 +0100 Subject: [PATCH] Fixed lessons bottom sheet while dragging --- .../ui/lessons/LessonBottomSheetBehavior.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonBottomSheetBehavior.kt b/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonBottomSheetBehavior.kt index 3399854..c74cf50 100644 --- a/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonBottomSheetBehavior.kt +++ b/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonBottomSheetBehavior.kt @@ -10,13 +10,21 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior /** * A [BottomSheetBehavior] that helps to restrict touchable area depends on translationX */ -class LessonBottomSheetBehavior(context: Context, attrs: AttributeSet?) : - BottomSheetBehavior(context, attrs) { +class LessonBottomSheetBehavior ( + context: Context, + attrs: AttributeSet? +) : BottomSheetBehavior(context, attrs) { - override fun onTouchEvent(parent: CoordinatorLayout, child: T, event: MotionEvent): Boolean { - if (event.x < child.translationX) { - return false + override fun onTouchEvent( + parent: CoordinatorLayout, + child: T, + event: MotionEvent + ): Boolean { + return if (event.x < child.translationX && state != STATE_DRAGGING) { + false + } else { + super.onTouchEvent(parent, child, event) } - return super.onTouchEvent(parent, child, event) } + } \ No newline at end of file