2021-07-12 10:14:26 +02:00
|
|
|
package audio.funkwhale.ffa.views
|
2020-06-02 18:50:46 +02:00
|
|
|
|
|
|
|
import android.animation.ObjectAnimator
|
|
|
|
import android.content.Context
|
|
|
|
import android.graphics.drawable.Drawable
|
|
|
|
import android.view.View
|
|
|
|
import android.widget.ImageView
|
2021-07-12 10:14:26 +02:00
|
|
|
import audio.funkwhale.ffa.R
|
2020-06-02 18:50:46 +02:00
|
|
|
|
|
|
|
object LoadingImageView {
|
|
|
|
fun start(context: Context?, image: ImageView): ObjectAnimator? {
|
|
|
|
context?.let {
|
|
|
|
image.isEnabled = false
|
|
|
|
image.setImageDrawable(context.getDrawable(R.drawable.fab_spinner))
|
|
|
|
|
|
|
|
return ObjectAnimator.ofFloat(image, View.ROTATION, 0f, 360f).apply {
|
|
|
|
duration = 500
|
|
|
|
repeatCount = ObjectAnimator.INFINITE
|
|
|
|
start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
fun stop(context: Context?, original: Drawable, image: ImageView, animator: ObjectAnimator?) {
|
|
|
|
context?.let {
|
|
|
|
animator?.cancel()
|
|
|
|
|
|
|
|
image.isEnabled = true
|
|
|
|
image.setImageDrawable(original)
|
|
|
|
image.rotation = 0.0f
|
|
|
|
}
|
|
|
|
}
|
2021-07-02 13:55:49 +02:00
|
|
|
}
|