I've been fiddling around with MotionLayout, and noticed that while everything works nice and dandy otherwise, the TransitionListener does not get invoked if I scroll quickly enough.
The layout is something like this (irrelevant parts omitted):
<MotionLayout>
<TextView />
<TextView />
<NestedScrollView />
</MotionLayout>
The two TextViews are animated based on the NestedScrollViews scrolling, with a layout description like this:
<MotionScene>
<Transition
app:constraintSetEnd="@id/collapsed"
app:constraintSetStart="@id/expanded">
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/contentScroll"
app:touchAnchorSide="top />
</Transition>
<ConstraintSet android:id="@+id/expanded">
<!-- Set constraints for expanded state -->
</ConstraintSet>
<ConstraintSet android:id="@+id/collapsed">
<!-- Set constraints for expanded state -->
</ConstraintSet>
</MotionScene>
Now, this works OK so far. To listen to the transition's progress, I've set a listener like this:
motionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionTrigger(motionLayout: MotionLayout?, triggerId: Int, positive: Boolean, progress: Float) {
Timber.d("onTransitionTrigger")
}
override fun onTransitionStarted(motionLayout: MotionLayout?, startId: Int, endId: Int) {
Timber.d("onTransitionStarted")
}
override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
Timber.d("onTransitionCompleted")
}
override fun onTransitionChange(motionLayout: MotionLayout?, startId: Int, endId: Int, progress: Float) {
Timber.d("onTransitionChange: $progress")
}
})
This works correctly and prints out stuff as I scroll the NestedScrollView slowly, but making a quick swipe, the listener won't get invoked at all (none of the listener's methods are invoked). The layout itself updates correctly, though.
Is there something I'm missing here, or is there a bug in the MotionListener's invocation logic?