|
@@ -1,5 +1,6 @@
|
|
package com.swago.room.audio
|
|
package com.swago.room.audio
|
|
|
|
|
|
|
|
+import android.graphics.drawable.Drawable
|
|
import android.view.View
|
|
import android.view.View
|
|
import com.chad.library.adapter.base.BaseQuickAdapter
|
|
import com.chad.library.adapter.base.BaseQuickAdapter
|
|
import com.chad.library.adapter.base.BaseViewHolder
|
|
import com.chad.library.adapter.base.BaseViewHolder
|
|
@@ -9,6 +10,7 @@ import com.opensource.svgaplayer.SVGAParser
|
|
import com.opensource.svgaplayer.SVGAVideoEntity
|
|
import com.opensource.svgaplayer.SVGAVideoEntity
|
|
import com.swago.baseswago.cusview.SwagoImageView
|
|
import com.swago.baseswago.cusview.SwagoImageView
|
|
import com.swago.baseswago.model.live.audio.AudioSeatModel
|
|
import com.swago.baseswago.model.live.audio.AudioSeatModel
|
|
|
|
+import com.swago.baseswago.util.LogUtil
|
|
import com.swago.room.R
|
|
import com.swago.room.R
|
|
import java.net.URL
|
|
import java.net.URL
|
|
|
|
|
|
@@ -17,6 +19,18 @@ class AudioSeatAdapter :
|
|
private val svgaParser by lazy {
|
|
private val svgaParser by lazy {
|
|
SVGAParser(mContext)
|
|
SVGAParser(mContext)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private val svgaVideoEntityMap: MutableMap<Int, OldSeatModel?> = mutableMapOf(
|
|
|
|
+ 1 to null,
|
|
|
|
+ 2 to null,
|
|
|
|
+ 3 to null,
|
|
|
|
+ 4 to null,
|
|
|
|
+ 5 to null,
|
|
|
|
+ 6 to null,
|
|
|
|
+ 7 to null,
|
|
|
|
+ 8 to null
|
|
|
|
+ )
|
|
|
|
+
|
|
override fun convert(helper: BaseViewHolder?, item: AudioSeatModel?) {
|
|
override fun convert(helper: BaseViewHolder?, item: AudioSeatModel?) {
|
|
helper?.apply {
|
|
helper?.apply {
|
|
item?.let {
|
|
item?.let {
|
|
@@ -32,6 +46,7 @@ class AudioSeatAdapter :
|
|
itemView.findViewById<SwagoImageView>(R.id.ivImageView)
|
|
itemView.findViewById<SwagoImageView>(R.id.ivImageView)
|
|
.loadImage(R.mipmap.ic_audio_seat)
|
|
.loadImage(R.mipmap.ic_audio_seat)
|
|
}
|
|
}
|
|
|
|
+ svgaVideoEntityMap[adapterPosition] = null
|
|
svgAvatar.visibility = View.INVISIBLE
|
|
svgAvatar.visibility = View.INVISIBLE
|
|
} else {
|
|
} else {
|
|
itemView.findViewById<SwagoImageView>(R.id.ivImageView)
|
|
itemView.findViewById<SwagoImageView>(R.id.ivImageView)
|
|
@@ -58,20 +73,30 @@ class AudioSeatAdapter :
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (!it.head_special.isNullOrEmpty()){
|
|
|
|
|
|
+ if (!it.head_special.isNullOrEmpty() ){
|
|
svgAvatar.visibility = View.VISIBLE
|
|
svgAvatar.visibility = View.VISIBLE
|
|
- svgaParser.decodeFromURL(URL(it.head_special), object :SVGAParser.ParseCompletion{
|
|
|
|
- override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
|
|
- val drawable = SVGADrawable(videoItem)
|
|
|
|
- svgAvatar.setImageDrawable(drawable)
|
|
|
|
|
|
+ if (svgaVideoEntityMap[adapterPosition] == null || svgaVideoEntityMap[adapterPosition]?.url != item.head_special){
|
|
|
|
+ svgaParser.decodeFromURL(URL(it.head_special), object :SVGAParser.ParseCompletion{
|
|
|
|
+ override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
|
|
+ val drawable = SVGADrawable(videoItem)
|
|
|
|
+ svgaVideoEntityMap[adapterPosition] = OldSeatModel(drawable,it.head_special)
|
|
|
|
+ svgAvatar.setImageDrawable(drawable)
|
|
|
|
+ svgAvatar.startAnimation()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onError() {
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ svgaVideoEntityMap[adapterPosition]?.let { oldSeat ->
|
|
|
|
+ svgAvatar.setImageDrawable(oldSeat.drawable)
|
|
svgAvatar.startAnimation()
|
|
svgAvatar.startAnimation()
|
|
}
|
|
}
|
|
|
|
|
|
- override fun onError() {
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
|
|
+ svgaVideoEntityMap[adapterPosition] = null
|
|
svgAvatar.visibility = View.INVISIBLE
|
|
svgAvatar.visibility = View.INVISIBLE
|
|
}
|
|
}
|
|
|
|
|
|
@@ -80,4 +105,6 @@ class AudioSeatAdapter :
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ data class OldSeatModel(val drawable: SVGADrawable,val url:String?)
|
|
}
|
|
}
|