-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from HeyAlex/restrict-touchable-area
restrict touchable area depends on translationX
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonBottomSheetBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.materialstudies.owl.ui.lessons | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.MotionEvent | ||
import android.view.View | ||
import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
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) { | ||
|
||
override fun onTouchEvent(parent: CoordinatorLayout, child: T, event: MotionEvent): Boolean { | ||
if (event.x < child.translationX) { | ||
return false | ||
} | ||
return super.onTouchEvent(parent, child, event) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters