View ItemTouchInterceptor.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
class ItemTouchInterceptor : RecyclerView.OnItemTouchListener { | |
private var intercept = false | |
override fun onTouchEvent(rv: RecyclerView, e: MotionEvent) { | |
} | |
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent): Boolean { | |
return intercept | |
} |
View setTransitionListener
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
setTransitionListener(object : MotionLayout.TransitionListener { | |
override fun onTransitionTrigger( | |
p0: MotionLayout?, | |
p1: Int, | |
p2: Boolean, | |
p3: Float | |
) { | |
} |
View motionLayoutUpdate
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
motion.apply { | |
updateState(R.id.start, set) | |
setTransition(R.id.start, R.id.end) | |
transitionToEnd() | |
} |
View constraints
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
val set = motion.getConstraintSet(R.id.start) | |
set.clear(R.id.img_motion) | |
set.constrainWidth(R.id.img_motion, img.width) | |
set.constrainHeight(R.id.img_motion, img.height) | |
set.connect( | |
R.id.img_motion, | |
ConstraintSet.START, | |
ConstraintSet.PARENT_ID, | |
ConstraintSet.START, | |
rect.left |
View getLocalVisibleRect
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
img.getLocalVisibleRect(rect) | |
val clipType = when { | |
rect.height() == img.height -> NO_CLIP | |
rect.top > 0 -> CLIP_TOP | |
else -> CLIP_BOTTOM | |
} |
View activity_main.xml
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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/motion" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layoutDescription="@xml/scene_recyclerview_motion" | |
tools:context=".MainActivity"> |