ObjectAnimator Freezes UI

19 Views Asked by At

I have a BottomNavigationView with a few fragments. In the Main Activity that holds the fragments I have an ObjectAnimator that rotates an imageView. When the rotation slows down and stops (which I don't want but that's another issue), I notice the entire UI freezes meaning I can't switch menu items nor do anything else such a press buttons. After it restarts rotating again the UI works fine. Why is the ObjectAnimator freezing the UI?

val objectAnimator = ObjectAnimator()

fun showSpinner(value: Boolean) {


    if (value) {

        objectAnimator.target = binding.imageViewWithSpinner
        objectAnimator.setProperty(View.ROTATION)
        objectAnimator.setFloatValues(0.0f, 360.0f)
        objectAnimator.duration = 1200
        objectAnimator.interpolator = LinearInterpolator()
        objectAnimator.repeatMode = ObjectAnimator.RESTART
        objectAnimator.repeatCount = ObjectAnimator.INFINITE
        objectAnimator.start()

        return
    }

    objectAnimator.cancel()
}
0

There are 0 best solutions below