Added view rotation animator extension to Utilities.kt

This commit is contained in:
Arty Bishop committed 2020-10-06 23:24:17 +01:00
1 parent 8164384498
commit 704dac6a75
1 file changed
+11
@@ -1,7 +1,9 @@
package com.rtbishop.look4sat.utility
import android.animation.ObjectAnimator
import android.content.SharedPreferences
import android.view.View
import android.view.animation.LinearInterpolator
import com.google.android.material.snackbar.Snackbar
import java.util.concurrent.TimeUnit
import kotlin.math.round
@@ -26,6 +28,15 @@ object Utilities {
return round(this * multiplier) / multiplier
}
fun View.getRotationAnimator(): ObjectAnimator {
return ObjectAnimator.ofFloat(this, "rotation", 0f, 360f).apply {
duration = 800
repeatCount = ObjectAnimator.INFINITE
repeatMode = ObjectAnimator.RESTART
interpolator = LinearInterpolator()
}
}
fun SharedPreferences.Editor.putDouble(key: String, double: Double) {
putLong(key, double.toRawBits())
}