Closed shreelakshmijoshi closed 3 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.
ℹ️ Googlers: Go here for more info.
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.
ℹ️ Googlers: Go here for more info.
@googlebot I signed it!
We should also destroy the object associated with the view when back button is pressed.
What object does this code destroy?
@yaraki my bad ! this code doesn't destroy any object , it will perform click on the stop button.. and end the animation, when the AnimatedFragment View gets destroyed.. I have updated the earlier comment to reflect this.
@yaraki , this is the error stack trace this is a clip 👇 to shows that would be no errors after pressing the back button
OK, I see what you mean. But this should be fixed by unregistering the callback when the fragment's view is destroyed. Could you do it that way? Otherwise I can do it.
@yaraki , Yes that would work too, I did that change to un-register / clear all callbacks , during view destruction . Please review and approve the latest change in the newer PR here I will be closing this PR at this point because we have a newer pull request.
Thank You!
The animated fragment is set to null after the animation is completed. When we press the back button , the view gets destroyed but the animated fragment which is bound to the view is still running. As a result of the animation running even after back button is pressed, once this running animation completes, it invokes callbacks which try to access the destroyed view and its objects like the start and stop buttons at this place in the code
So ,since we are accessing a destroyed view in callbacks ( after pressing back button) , android framework throws an illegal state exception That's why
OnBackPressedCallback
function is added which implements the operation of thestop button