|
@@ -10,7 +10,9 @@ import android.util.AttributeSet
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.widget.FrameLayout
|
|
|
-import android.widget.LinearLayout
|
|
|
+import com.opensource.svgaplayer.SVGADrawable
|
|
|
+import com.opensource.svgaplayer.SVGAParser
|
|
|
+import com.opensource.svgaplayer.SVGAVideoEntity
|
|
|
import com.swago.baseswago.model.im.GamePrize
|
|
|
import com.swago.baseswago.model.im.IPiaoTiao
|
|
|
import com.swago.baseswago.model.im.PiaoTiaoRewardsData
|
|
@@ -19,10 +21,8 @@ import com.swago.baseswago.util.AppContext
|
|
|
import com.swago.baseswago.util.DpPxUtil
|
|
|
import com.swago.baseswago.util.SwagoInfo
|
|
|
import com.swago.room.R
|
|
|
-import com.swago.room.databinding.ViewItemGiftBinding
|
|
|
import com.swago.room.databinding.ViewWaftBinding
|
|
|
-import com.swago.room.sound.SoundPoolPlayer
|
|
|
-import com.swago.room.widget.MarqueeTextView
|
|
|
+import java.net.URL
|
|
|
import java.util.*
|
|
|
|
|
|
/**
|
|
@@ -35,7 +35,7 @@ class WaftView : FrameLayout {
|
|
|
|
|
|
private val imGiftModelList = LinkedList<IPiaoTiao>()
|
|
|
private var binding : ViewWaftBinding? = null
|
|
|
-
|
|
|
+ private var svgaParser:SVGAParser? = null
|
|
|
constructor(context: Context) : super(context)
|
|
|
constructor(context: Context, mAttributeSet: AttributeSet?) : super(context, mAttributeSet){
|
|
|
initView(context)
|
|
@@ -43,6 +43,7 @@ class WaftView : FrameLayout {
|
|
|
|
|
|
private fun initView(context: Context) {
|
|
|
binding = ViewWaftBinding.inflate(LayoutInflater.from(context), this, true)
|
|
|
+ svgaParser = SVGAParser(context)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -121,6 +122,8 @@ class WaftView : FrameLayout {
|
|
|
val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
|
|
|
val giftName = "<font color='#FFDB43'>${localName}</font>"
|
|
|
val multiple = "<font color='#FFDB43'>${next.multiple}</font>"
|
|
|
+ binding?.ivFunction?.visibility = View.GONE
|
|
|
+ binding?.ivAvatar?.visibility = View.VISIBLE
|
|
|
binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_big_prize)
|
|
|
binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_big_prize)
|
|
|
binding?.tvPrize?.text = "${next.multiple}"
|
|
@@ -130,17 +133,36 @@ class WaftView : FrameLayout {
|
|
|
val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
|
|
|
val giftName = "<font color='#FFDB43'>${localName}</font>"
|
|
|
val receiverName = "<font color='#FFDB43'>${next.receiverName}</font>"
|
|
|
+ binding?.ivFunction?.visibility = View.GONE
|
|
|
+ binding?.ivAvatar?.visibility = View.VISIBLE
|
|
|
binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_send)
|
|
|
binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_send)
|
|
|
binding?.tvPrize?.text = ""
|
|
|
binding?.marqueeTextView?.text = Html.fromHtml("\u200E${AppContext.getContext().resources.getString(R.string.big_gift_msg).format(sendName,giftName,receiverName)}")
|
|
|
}
|
|
|
+ if (!next.headSpecial.isNullOrEmpty()){
|
|
|
+ binding?.svgAvatar?.visibility = View.VISIBLE
|
|
|
+ svgaParser?.decodeFromURL(URL(next.headSpecial), object : SVGAParser.ParseCompletion{
|
|
|
+ override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
|
+ val drawable = SVGADrawable(videoItem)
|
|
|
+ binding?.svgAvatar?.setImageDrawable(drawable)
|
|
|
+ binding?.svgAvatar?.startAnimation()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onError() {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ binding?.svgAvatar?.visibility = View.GONE
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
is GamePrize -> {
|
|
|
val sendName = "<font color='#FFDB43'>${next.senderName}</font>"
|
|
|
val gameName = "<font color='#FFDB43'>${next.gameName}</font>"
|
|
|
val coin = "<font color='#FFDB43'>${next.coin}</font>"
|
|
|
+ binding?.ivFunction?.visibility = View.GONE
|
|
|
+ binding?.ivAvatar?.visibility = View.VISIBLE
|
|
|
binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_game)
|
|
|
binding?.tvPrize?.setBackgroundResource(R.mipmap.ic_waft_game)
|
|
|
binding?.tvPrize?.text = ""
|
|
@@ -152,12 +174,26 @@ class WaftView : FrameLayout {
|
|
|
binding?.marqueeTextView?.text = Html.fromHtml("\u200E${AppContext.getContext().resources.getString(R.string.game_prize).format(sendName,gameName,coin)}")
|
|
|
}
|
|
|
}
|
|
|
+ if (next.headSpecial.isNotEmpty()){
|
|
|
+ svgaParser?.decodeFromURL(URL(next.headSpecial), object : SVGAParser.ParseCompletion{
|
|
|
+ override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
|
+ val drawable = SVGADrawable(videoItem)
|
|
|
+ binding?.svgAvatar?.setImageDrawable(drawable)
|
|
|
+ binding?.svgAvatar?.startAnimation()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onError() {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
is PiaoTiaoRewardsData -> {
|
|
|
when(next.type) {
|
|
|
505 -> {
|
|
|
val sendName = "<font color='#FFDB43'>${next.userName}</font>"
|
|
|
val coin = "<font color='#FFDB43'>${next.sort}</font>"
|
|
|
+ binding?.ivFunction?.visibility = View.VISIBLE
|
|
|
+ binding?.ivAvatar?.visibility = View.GONE
|
|
|
binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
|
|
|
binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
|
|
|
binding?.tvPrize?.text = ""
|
|
@@ -166,6 +202,8 @@ class WaftView : FrameLayout {
|
|
|
506 -> {
|
|
|
val sendName = "<font color='#FFDB43'>${next.userName}</font>"
|
|
|
val coin = "<font color='#FFDB43'>${next.sort}</font>"
|
|
|
+ binding?.ivFunction?.visibility = View.VISIBLE
|
|
|
+ binding?.ivAvatar?.visibility = View.GONE
|
|
|
binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
|
|
|
binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
|
|
|
binding?.tvPrize?.text = ""
|
|
@@ -174,6 +212,8 @@ class WaftView : FrameLayout {
|
|
|
507 -> {
|
|
|
val sendName = "<font color='#FFDB43'>${next.userName}</font>"
|
|
|
val coin = "<font color='#FFDB43'>${next.winCoin}</font>"
|
|
|
+ binding?.ivFunction?.visibility = View.VISIBLE
|
|
|
+ binding?.ivAvatar?.visibility = View.GONE
|
|
|
binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
|
|
|
binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
|
|
|
binding?.tvPrize?.text = ""
|
|
@@ -181,6 +221,8 @@ class WaftView : FrameLayout {
|
|
|
}
|
|
|
508 -> {
|
|
|
val coin = "<font color='#FFDB43'>${next.actCoin}</font>"
|
|
|
+ binding?.ivFunction?.visibility = View.VISIBLE
|
|
|
+ binding?.ivAvatar?.visibility = View.GONE
|
|
|
binding?.ll?.setBackgroundResource(R.mipmap.bg_waft_function)
|
|
|
binding?.ivPrize?.setImageResource(R.mipmap.ic_waft_function)
|
|
|
binding?.tvPrize?.text = ""
|
|
@@ -196,6 +238,7 @@ class WaftView : FrameLayout {
|
|
|
|
|
|
|
|
|
binding?.marqueeTextView?.post {
|
|
|
+ binding?.marqueeTextView?.stopScroll()
|
|
|
binding?.marqueeTextView?.startScroll()
|
|
|
}
|
|
|
binding?.let {
|