Skip to content

Commit

Permalink
Fixed lessons bottom sheet while dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Pagini committed Jan 9, 2020
1 parent 374b9c8 commit 72e3481
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
/**
* A [BottomSheetBehavior] that helps to restrict touchable area depends on translationX
*/
class LessonBottomSheetBehavior<T : View>(context: Context, attrs: AttributeSet?) :
BottomSheetBehavior<T>(context, attrs) {
class LessonBottomSheetBehavior<T : View> (
context: Context,
attrs: AttributeSet?
) : BottomSheetBehavior<T>(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)
}

}

0 comments on commit 72e3481

Please sign in to comment.