onAnimationEnd and accessing UI elements within it

236
March 31, 2017, at 03:27 AM

I have looked through the the documentation of ValueAnimator but didn't notice specific guideline on accessing UI elements in onAnimatorEnd method. However in the application I have in google play, I see many crashlytics reports originating in onAnimationEnd. All of those crashes are mitigated by adding following code at the beginning of onAnimationEnd

if(getActivity() != null && !getActivity.isFinishing() ) { ... }

Does anyone know for sure if activity can be destroyed before animation ends? Also if activity is really destroyed why is onAnimationEnd getting called at all? I can certainly add above code to all my onAnimationEnd but want to make sure its not a incorrect solution.

Answer 1

Does anyone know for sure if activity can be destroyed before animation ends?

Sure it can. Assume you have 10000ms long animation and you press back button. What will happen? Activity will be finished regardless animation has finished or no.

Also if activity is really destroyed why is onAnimationEnd getting called at all?

It shouldn't. Instead, onAnimationCancel() will be called.

READ ALSO
Running a script pre-build in react-native

Running a script pre-build in react-native

I have some resource files that I need to copy from /app/resources to both /android/app/src/main/ress/raw and /ios/<project>/resources when I buildI assume there's a way to do this, but I'm not familiar with how react-native/Gradle/XCode builds

259
Detecting Intersections on Android Using Google Maps

Detecting Intersections on Android Using Google Maps

So, was hoping a more advanced developer would be able to give some insightI am developing an app, and trying to use real-time tracking for users

221