Mark
12/27/2023, 12:04 PMephemient
12/27/2023, 12:22 PMephemient
12/27/2023, 12:22 PMephemient
12/27/2023, 12:25 PMMark
12/27/2023, 1:27 PM// NO-LONGER-RELEVANT LEGACY ANDROID VIEW-BASED WORKAROUND
fun fixAnimatorDurationScale(context: Context) {
val definitelyDisabled = !ValueAnimator.areAnimatorsEnabled()
val durationScale = if (definitelyDisabled) {
0f
} else {
try {
// possibly enabled but we want to make sure we are using scale 1f
Global.getFloat(context.contentResolver, Global.ANIMATOR_DURATION_SCALE)
} catch (t: Throwable) {
// android.provider.Settings$SettingNotFoundException: animator_duration_scale
// this can happen if the user has never set this setting (confirmed on API27 emulator)
if (t is Settings.SettingNotFoundException) {
println("Unable to get animator duration scale system setting (probably user never set it)")
} else {
println("Unable to get animator duration scale system setting", t)
}
return
}
}
if (durationScale == 1f) {
return
}
println("fixing animator duration scale: $durationScale")
try {
ValueAnimator::class.java.getMethod("setDurationScale", Float::class.javaPrimitiveType).invoke(null, 1f)
} catch (t: Throwable) {
println("unable to fix animator duration scale", t)
}
}
ephemient
12/27/2023, 1:57 PM