@@ -23,9 +23,22 @@ class SVGADrawable(val videoItem: SVGAVideoEntity, val dynamicItem: SVGADynamicE
23
23
constructor (videoItem: SVGAVideoEntity ): this (videoItem, SVGADynamicEntity ())
24
24
25
25
var cleared = true
26
+ internal set (value) {
27
+ if (field == value) {
28
+ return
29
+ }
30
+ field = value
31
+ invalidateSelf()
32
+ }
26
33
27
34
var currentFrame = 0
28
- internal set
35
+ internal set (value) {
36
+ if (field == value) {
37
+ return
38
+ }
39
+ field = value
40
+ invalidateSelf()
41
+ }
29
42
30
43
override fun draw (canvas : Canvas ? ) {
31
44
if (cleared) {
@@ -126,7 +139,6 @@ open class SVGAImageView : ImageView {
126
139
animator.repeatCount = if (loops <= 0 ) 99999 else loops - 1
127
140
animator.addUpdateListener {
128
141
drawable.currentFrame = animator.animatedValue as Int
129
- drawable.invalidateSelf()
130
142
callback?.onStep(drawable.currentFrame, ((drawable.currentFrame + 1 ).toDouble() / drawable.videoItem.frames.toDouble()))
131
143
}
132
144
animator.addListener(object : Animator .AnimatorListener {
@@ -138,7 +150,6 @@ open class SVGAImageView : ImageView {
138
150
if (! clearsAfterStop) {
139
151
if (fillMode == FillMode .Backward ) {
140
152
drawable.currentFrame = 0
141
- drawable.invalidateSelf()
142
153
}
143
154
}
144
155
callback?.onFinished()
@@ -164,7 +175,6 @@ open class SVGAImageView : ImageView {
164
175
animator?.cancel()
165
176
(drawable as ? SVGADrawable )?.let {
166
177
it.cleared = clear
167
- it.invalidateSelf()
168
178
}
169
179
}
170
180
@@ -182,7 +192,6 @@ open class SVGAImageView : ImageView {
182
192
pauseAnimation()
183
193
val drawable = drawable as ? SVGADrawable ? : return
184
194
drawable.currentFrame = frame
185
- drawable.invalidateSelf()
186
195
if (andPlay) {
187
196
startAnimation()
188
197
animator?.let {
0 commit comments