android / views-widgets-samples

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

Reproduce onTransitionCompleted bug #134

Open alexvanyo opened 4 years ago

alexvanyo commented 4 years ago

This PR reproduces an issue with MotionLayout.TransitionListener in 2.0.0-beta5 and 2.0.0-beta6.

In Complex Motion Example (4/4), the onTransitionCompleted method is called multiple times, and sometimes with a currentId of -1, which is unexpected:

Clicking the button once results in an output of

2020-05-19 15:02:44.355 30563-30563/com.google.androidstudio.motionlayoutexample D/DemoActivity: 2131230886: currentId is start: false, currentId is end: true
2020-05-19 15:02:44.355 30563-30563/com.google.androidstudio.motionlayoutexample D/DemoActivity: -1: currentId is start: false, currentId is end: false
2020-05-19 15:02:44.355 30563-30563/com.google.androidstudio.motionlayoutexample D/DemoActivity: 2131230886: currentId is start: false, currentId is end: true

Reverting to 2.0.0-beta4 gives the expected output:

2020-05-19 15:03:58.180 30885-30885/com.google.androidstudio.motionlayoutexample D/DemoActivity: 2131230883: currentId is start: false, currentId is end: true

This reproduces https://issuetracker.google.com/issues/157003182

googlebot commented 4 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

muhammad-hamza-shahid commented 3 years ago

Hi, @alexvanyo @codingjeremy I am facing the exact same problem, is there any way to deal with this problem because I saw googleBot declared it as Status: Won't Fix (Not Reproducible)

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.