Skip to content
This repository was archived by the owner on Jul 11, 2025. It is now read-only.

PR for motion-layout onTransitionCompleted listener problem #226

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class FragmentExample2Activity: AppCompatActivity(), View.OnClickListener, Motio
private var lastProgress = 0f
private var fragment: Fragment? = null
private var last: Float = 0f
private var mLastSwipe: Long = 0


override fun onTransitionChange(p0: MotionLayout?, p1: Int, p2: Int, p3: Float) {
if (p3 - lastProgress > 0) {
Expand Down Expand Up @@ -70,6 +72,11 @@ class FragmentExample2Activity: AppCompatActivity(), View.OnClickListener, Motio
}

override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) {
//Using this way this listener will not let the execute before 250 milli seconds and the problem of multi-triggering will be solved
if (SystemClock.elapsedRealtime() - mLastSwipe < 250) {
return
}
mLastSwipe = SystemClock.elapsedRealtime()
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down