android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Apache License 2.0
5.07k stars 3.01k forks source link

Motion Layout onTransitionCompleted() listener error #225

Open muhammad-hamza-shahid opened 3 years ago

muhammad-hamza-shahid commented 3 years ago

I am using swipe functionality to make a transition

onTransitionCompleted() listener of motion layout sometimes trigger twice I have set a check in current Id of transition to increment a value, but it sometimes trigger twice which increments the value 2 time.

muhammad-hamza-shahid commented 3 years ago

So I have used this to handle the problem hope it works for you as well, Just checked if the event occurs before 250 milli sec, you can customize it according to your need.

if (SystemClock.elapsedRealtime() - mLastSwipe < 250){
                    return
                }
                mLastSwipe = SystemClock.elapsedRealtime()

I have used it in start of onTransitionCompleted() listener and it worked.