From 11e5271193e074048b98d9183e2a2f8796f8f216 Mon Sep 17 00:00:00 2001 From: eggmanQQQ <3671373519@qq.com> Date: Tue, 15 Oct 2024 11:01:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=20=E6=B8=B8=E6=88=8F=E4=B8=AD=E5=A5=96?= =?UTF-8?q?=E9=A3=98=E5=B1=8F,=E9=80=9A=E7=94=A8img=E9=A3=98=E5=B1=8F,?= =?UTF-8?q?=E9=80=9A=E7=94=A8vga=E9=A3=98=E5=B1=8F=20=E6=B7=BB=E5=8A=A0dp6?= =?UTF-8?q?8=E7=9A=84=20=E9=A1=B6=E9=83=A8=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/notify/views/BaiShunGameNotify.kt | 46 ++++++++++++++++--- .../layout/layout_template_notify_baishun.xml | 3 ++ .../layout/layout_template_notify_image.xml | 1 + .../layout/layout_template_notify_svga.xml | 1 + 4 files changed, 45 insertions(+), 6 deletions(-) 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" />