Skip to content

Commit 5457b0a

Browse files
committed
add try catch for sDurationScale.
1 parent 994a4d4 commit 5457b0a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

library/src/main/java/com/opensource/svgaplayer/SVGAImageView.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,16 @@ open class SVGAImageView : ImageView {
145145
drawable.videoItem?.let {
146146
var durationScale = 1.0
147147
val animator = ValueAnimator.ofInt(0, it.frames - 1)
148-
Class.forName("android.animation.ValueAnimator")?.let {
149-
it.getDeclaredField("sDurationScale")?.let {
150-
it.isAccessible = true
151-
it.getFloat(Class.forName("android.animation.ValueAnimator"))?.let {
152-
durationScale = it.toDouble()
148+
try {
149+
Class.forName("android.animation.ValueAnimator")?.let {
150+
it.getDeclaredField("sDurationScale")?.let {
151+
it.isAccessible = true
152+
it.getFloat(Class.forName("android.animation.ValueAnimator"))?.let {
153+
durationScale = it.toDouble()
154+
}
153155
}
154156
}
155-
}
157+
} catch (e: Exception) {}
156158
animator.interpolator = LinearInterpolator()
157159
animator.duration = (it.frames * (1000 / it.FPS) / durationScale).toLong()
158160
animator.repeatCount = if (loops <= 0) 99999 else loops - 1

0 commit comments

Comments
 (0)