fix:修复SVGA飘屏不能展示问题
This commit is contained in:
@@ -11,14 +11,17 @@ import com.nnbc123.core.im.custom.bean.RoomTemplateNotifyMsgBean
|
||||
* Desc:
|
||||
**/
|
||||
class NotifyAdapter : FloatViewAdapter {
|
||||
override fun onCreateFloatView(context: Context, item: Any): FloatView {
|
||||
override fun onCreateFloatView(context: Context, item: Any): FloatView? {
|
||||
if (item is RoomTemplateNotifyMsgBean) {
|
||||
return TemplateImageNotifyView(context)
|
||||
if (item.resourceType == "IMAGE") {
|
||||
return TemplateImageNotifyView(context)
|
||||
} else if (item.resourceType == "SVGA") {
|
||||
return TemplateSvgaNotifyView(context)
|
||||
}
|
||||
} else if (item is String) {
|
||||
return GlobalGiftNotifyView(context)
|
||||
} else {
|
||||
return TemplateNotifyView(context)
|
||||
return TestNotifyView(context)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onBindFloatView(window: FloatWindow, floatView: FloatView, item: Any) {
|
||||
|
@@ -1,56 +0,0 @@
|
||||
package com.nnbc123.app.notify.global
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.TextView
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.support.float.BaseFloatView
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/3/22 14:52
|
||||
* Desc:
|
||||
**/
|
||||
class TemplateNotifyView(context: Context) : BaseFloatView(context) {
|
||||
private val view = TextView(context)
|
||||
|
||||
init {
|
||||
addView(
|
||||
view,
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
)
|
||||
setBackgroundColor(Color.parseColor("#44FFFFFF"))
|
||||
view.gravity = Gravity.END
|
||||
view.setTextColor(Color.GREEN)
|
||||
view.textSize = 30f
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
view.text = item.toString()
|
||||
val inAnimation = AnimationUtils.loadAnimation(context, R.anim.anim_right_in)
|
||||
this.startAnimation(inAnimation)
|
||||
postDelayed({
|
||||
val outAnimation = AnimationUtils.loadAnimation(context, R.anim.anim_left_out)
|
||||
outAnimation.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation?) {
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
post {
|
||||
requestRemoveSelf()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animation?) {
|
||||
}
|
||||
})
|
||||
this.startAnimation(outAnimation)
|
||||
}, 5000)
|
||||
}
|
||||
}
|
@@ -43,7 +43,7 @@ class TemplateSvgaNotifyView(context: Context) : BaseFloatView(context) {
|
||||
init {
|
||||
svgaView.loops = 1
|
||||
svgaView.clearsAfterDetached = true
|
||||
addView(svgaView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
||||
addView(svgaView, LayoutParams(LayoutParams.MATCH_PARENT, 0))
|
||||
}
|
||||
|
||||
override fun onBind(item: Any) {
|
||||
@@ -61,9 +61,9 @@ class TemplateSvgaNotifyView(context: Context) : BaseFloatView(context) {
|
||||
requestRemoveSelf()
|
||||
return
|
||||
}
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, 0)
|
||||
val params = svgaView.layoutParams as ConstraintLayout.LayoutParams
|
||||
params.dimensionRatio = data.getDimensionRatio() ?: "75:11"
|
||||
this.layoutParams = params
|
||||
svgaView.layoutParams = params
|
||||
svgaView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
requestRemoveSelf()
|
||||
|
@@ -13,7 +13,7 @@ import com.nnbc123.app.support.float.BaseFloatView
|
||||
* Created by Max on 2024/3/21 17:52
|
||||
* Desc:
|
||||
**/
|
||||
class GlobalGiftNotifyView(context: Context) : BaseFloatView(context) {
|
||||
class TestNotifyView(context: Context) : BaseFloatView(context) {
|
||||
private val view = TextView(context)
|
||||
|
||||
init {
|
@@ -7,7 +7,7 @@ import android.content.Context
|
||||
* Desc:
|
||||
**/
|
||||
interface FloatViewAdapter {
|
||||
fun onCreateFloatView(context: Context, item: Any): FloatView
|
||||
fun onCreateFloatView(context: Context, item: Any): FloatView?
|
||||
|
||||
fun onBindFloatView(window: FloatWindow, floatView: FloatView, item: Any)
|
||||
}
|
Reference in New Issue
Block a user