android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Motion Layout onTransitionCompleted() listener error

muhammad-hamza-shahid opened this issue · comments

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.

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.