anastr / SpeedView

Dynamic Speedometer and Gauge for Android. amazing, powerful, and multi shape :zap:
Apache License 2.0
1.28k stars 321 forks source link

Reduce CPU usage when view isn't visible #212

Open anastr opened 3 years ago

anastr commented 3 years ago

Describe the issue On Android 6.0 (API 23) and lower, the animator object keeps running in the background even when the view goes invisible to the user (like open second activity). This isn't the case with Android 7.0 (API 24) or higher, because we cancel animation when the view becomes invisible inside onVisibilityAggregated method.

Additional context This isn't a big problem since Android OS wont draw view frames if that view isn't visible to the user. But it's not nice to keep an unnecessary thread running and consuming the system resources.