feat: 游戏中奖飘屏,通用img飘屏,通用vga飘屏 添加dp68的 顶部间距

This commit is contained in:
eggmanQQQ
2024-10-15 11:01:09 +08:00
parent 20457a9bdf
commit 11e5271193
4 changed files with 45 additions and 6 deletions

View File

@@ -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<SVGAView>(R.id.iv_bg)
svgaView.loadFile("svga/baishun_notify_bg.svga")
val svgaView = findViewById<SVGAView>(R.id.iv_bg)
val textView = findViewById<TextView>(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<ImageView>(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) {

View File

@@ -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 @@
<ImageView
android:id="@+id/go"
android:layout_width="35dp"
android:visibility="invisible"
tools:visibility="visible"
android:layout_height="25dp"
android:layout_marginEnd="@dimen/dp_40"
android:src="@drawable/ic_notify_go"

View File

@@ -11,6 +11,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_marginTop="@dimen/dp_68"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/smash_eggs_notity_bg_4" />

View File

@@ -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" />