Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
fix: Remove unnecessary code.
Browse files Browse the repository at this point in the history
  • Loading branch information
PonyCui committed Jan 16, 2019
1 parent 957323d commit cd31b1b
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions library/src/main/java/com/opensource/svgaplayer/SVGAImageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,13 @@ open class SVGAImageView : ImageView {
}
}

private var detachedDrawable: WeakReference<Drawable>? = null

override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
this.drawable?.let {
this.detachedDrawable = WeakReference(it)
}
this.setImageDrawable(null)
animator?.cancel()
animator?.removeAllListeners()
animator?.removeAllUpdateListeners()
}

override fun onAttachedToWindow() {
super.onAttachedToWindow()
this.detachedDrawable?.get()?.let {
this.setImageDrawable(it)
this.detachedDrawable = null
}
}

private fun loadAttrs(attrs: AttributeSet) {
val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.SVGAImageView, 0, 0)
loops = typedArray.getInt(R.styleable.SVGAImageView_loopCount, 0)
Expand Down Expand Up @@ -213,12 +199,16 @@ open class SVGAImageView : ImageView {
}
}

fun setVideoItem(videoItem: SVGAVideoEntity) {
fun setVideoItem(videoItem: SVGAVideoEntity?) {
setVideoItem(videoItem, SVGADynamicEntity())
}

fun setVideoItem(videoItem: SVGAVideoEntity, dynamicItem: SVGADynamicEntity) {
val drawable = SVGADrawable(videoItem, dynamicItem)
fun setVideoItem(videoItem: SVGAVideoEntity?, dynamicItem: SVGADynamicEntity?) {
if (videoItem == null) {
setImageDrawable(null)
return
}
val drawable = SVGADrawable(videoItem, dynamicItem ?: SVGADynamicEntity())
drawable.cleared = clearsAfterStop
setImageDrawable(drawable)
}
Expand Down

0 comments on commit cd31b1b

Please sign in to comment.