From dd525cfd6624b0cc6d6b2ef3edce36a1939dc92c Mon Sep 17 00:00:00 2001 From: fudonghui Date: Fri, 20 Nov 2020 18:37:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=BF=AE=E6=94=B9ValueAnimat?= =?UTF-8?q?or#sDurationScale=E7=9A=84=E6=96=B9=E5=BC=8F=E3=80=82=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DtargetSdkVersion=3D29=EF=BC=8C=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E8=80=85=E9=80=89=E9=A1=B9=E5=85=B3=E9=97=AD=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=EF=BC=8C=E6=97=A0=E6=B3=95=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/opensource/svgaplayer/SVGAImageView.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/opensource/svgaplayer/SVGAImageView.kt b/library/src/main/java/com/opensource/svgaplayer/SVGAImageView.kt index 52d89145..3330ab25 100644 --- a/library/src/main/java/com/opensource/svgaplayer/SVGAImageView.kt +++ b/library/src/main/java/com/opensource/svgaplayer/SVGAImageView.kt @@ -149,17 +149,19 @@ open class SVGAImageView @JvmOverloads constructor(context: Context, attrs: Attr var scale = 1.0 try { val animatorClass = Class.forName("android.animation.ValueAnimator") ?: return scale - val field = animatorClass.getDeclaredField("sDurationScale") ?: return scale - field.isAccessible = true - scale = field.getFloat(animatorClass).toDouble() + val getMethod = animatorClass.getDeclaredMethod("getDurationScale") ?: return scale + scale = (getMethod.invoke(animatorClass) as Float).toDouble() if (scale == 0.0) { - field.setFloat(animatorClass, 1.0f) + val setMethod = animatorClass.getDeclaredMethod("setDurationScale",Float::class.java) ?: return scale + setMethod.isAccessible = true + setMethod.invoke(animatorClass,1.0f) scale = 1.0 LogUtils.info(TAG, "The animation duration scale has been reset to" + " 1.0x, because you closed it on developer options.") } } catch (ignore: Exception) { + ignore.printStackTrace() } return scale }