diff --git a/app/src/main/java/com/chwl/app/notify/views/BaiShunGameNotify.kt b/app/src/main/java/com/chwl/app/notify/views/BaiShunGameNotify.kt index 492e7d8b2..551112c5c 100644 --- a/app/src/main/java/com/chwl/app/notify/views/BaiShunGameNotify.kt +++ b/app/src/main/java/com/chwl/app/notify/views/BaiShunGameNotify.kt @@ -23,6 +23,8 @@ import com.chwl.core.gift.event.NotifyEvent import com.chwl.core.home.bean.BannerInfo import com.chwl.core.im.custom.bean.RoomTemplateNotifyMsgBean import com.chwl.core.utils.extension.subAndReplaceDot +import com.chwl.library.common.util.isVerify +import com.chwl.library.common.util.setVis import com.chwl.library.rxbus.RxBus import com.chwl.library.widget.SVGAView import com.example.lib_utils.ktx.getColorById @@ -55,19 +57,52 @@ class BaiShunGameNotify(context: Context) : BaseFloatView(context), requestRemoveSelf() return } - val svgaView = findViewById(R.id.iv_bg) - svgaView.loadFile("svga/baishun_notify_bg.svga") + val svgaView = findViewById(R.id.iv_bg) val textView = findViewById(R.id.tv_text) + + if (data.resourceType == RoomTemplateNotifyMsgBean.TYPE_SVGA && data.resourceContent.isVerify()) { + SVGAParser.shareParser().decodeFromURL( + URL(data.resourceContent), + object : SVGAParser.ParseCompletion { + override fun onComplete(videoItem: SVGAVideoEntity) { + val width = videoItem.videoSize.width + val height = videoItem.videoSize.height + var dimensionRatio = "75:11" + if (width > 0 && height > 0) { + dimensionRatio = "$width:$height" + } + val params = svgaView.layoutParams as ConstraintLayout.LayoutParams + params.dimensionRatio = dimensionRatio + svgaView.layoutParams = params + val drawable = SVGADrawable(videoItem) + svgaView.setImageDrawable(drawable) + svgaView.startAnimation() + setView(data,textView) + } + + override fun onError() { + requestRemoveSelf() + } + }, + null + ) + } else { + svgaView.loadFile("svga/baishun_notify_bg.svga") + setView(data,textView) + } + + } + + private fun setView(data:RoomTemplateNotifyMsgBean,textView:TextView) { val textSize = data.fontSize?.toFloat() ?: 12f val textColor = templateMessageAdapter.parseColor(data.textColor) ?: Color.WHITE textView.textSize = textSize textView.setTextColor(textColor) - - - templateMessageAdapter.convert(textView, data) startEnterAnim() + templateMessageAdapter.convert(textView, data) val go = findViewById(R.id.go) + go.setVis(true) go.setOnClickListener { val event = NotifyEvent() event.action = NotifyEvent.Action.ACT_BAI_SHUN_GAME @@ -75,7 +110,6 @@ class BaiShunGameNotify(context: Context) : BaseFloatView(context), EventBus.getDefault().post(event) } startDelayRemove() - } override fun onShowUserCard(uid: String) { diff --git a/app/src/main/res/layout/layout_template_notify_baishun.xml b/app/src/main/res/layout/layout_template_notify_baishun.xml index 3c4e789af..38bbd6ceb 100644 --- a/app/src/main/res/layout/layout_template_notify_baishun.xml +++ b/app/src/main/res/layout/layout_template_notify_baishun.xml @@ -11,6 +11,7 @@ android:layout_width="match_parent" android:layout_height="70dp" app:clearsAfterDetached="true" + android:layout_marginTop="@dimen/dp_68" app:layout_constraintTop_toTopOf="parent" app:autoPlay="true" tools:src="@drawable/smash_eggs_notity_bg_4" /> @@ -39,6 +40,8 @@ diff --git a/app/src/main/res/layout/layout_template_notify_svga.xml b/app/src/main/res/layout/layout_template_notify_svga.xml index 781e12704..88eccff10 100644 --- a/app/src/main/res/layout/layout_template_notify_svga.xml +++ b/app/src/main/res/layout/layout_template_notify_svga.xml @@ -12,6 +12,7 @@ android:layout_height="0dp" app:clearsAfterDetached="true" app:layout_constraintTop_toTopOf="parent" + android:layout_marginTop="@dimen/dp_68" app:loopCount="1" tools:src="@drawable/smash_eggs_notity_bg_4" />