Skip to content

Commit 24e47a9

Browse files
committed
layout.xml support remote url.
avoid crash.
1 parent a445642 commit 24e47a9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import android.view.Choreographer
1313
import android.view.ViewPropertyAnimator
1414
import android.view.animation.LinearInterpolator
1515
import android.widget.ImageView
16+
import java.net.URL
1617

1718
/**
1819
* Created by cuiminghui on 2017/3/29.
@@ -100,6 +101,19 @@ open class SVGAImageView : ImageView {
100101
typedArray.getString(R.styleable.SVGAImageView_source)?.let {
101102
val parser = SVGAParser(context)
102103
Thread({
104+
if(it.startsWith("http://") || it.startsWith("https://")) {
105+
URL(it)?.let {
106+
parser.parse(it)?.let {
107+
handler.post({
108+
setVideoItem(it)
109+
if (typedArray.getBoolean(R.styleable.SVGAImageView_autoPlay, true)) {
110+
startAnimation()
111+
}
112+
})
113+
}
114+
return@Thread
115+
}
116+
}
103117
parser.parse(it)?.let {
104118
handler.post({
105119
setVideoItem(it)

0 commit comments

Comments
 (0)