fix:修复飘屏findViewById导致偶发异常问题

This commit is contained in:
max
2024-04-29 10:14:34 +08:00
parent 3626d5708a
commit 1d399777b1
3 changed files with 8 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ class FindLoveImageNotify(context: Context, val isHeightLevel: Boolean) : BaseFl
requestRemoveSelf()
return
}
val textView = rootView.findViewById<TextView>(R.id.tv_text)
val textView = findViewById<TextView>(R.id.tv_text)
textView.textSize = 12f
textView.setTextColor(Color.WHITE)
val text = SpannableBuilder()
@@ -50,7 +50,7 @@ class FindLoveImageNotify(context: Context, val isHeightLevel: Boolean) : BaseFl
}
textView.text = text.build()
textView.setPadding(0, UiUtils.dip2px(2f), 0, 0)
val bgView = rootView.findViewById<ImageView>(R.id.iv_bg)
val bgView = findViewById<ImageView>(R.id.iv_bg)
if (isHeightLevel) {
bgView.setImageResource(R.drawable.smash_eggs_notity_bg_5)
} else {

View File

@@ -45,14 +45,14 @@ class TemplateImageNotify(context: Context) : BaseFloatView(context),
return
}
val textView = rootView.findViewById<TextView>(R.id.tv_text)
val textView = findViewById<TextView>(R.id.tv_text)
val textSize = data.fontSize?.toFloat() ?: 12f
val textColor =
templateMessageAdapter.parseColor(data.textColor) ?: Color.WHITE
textView.textSize = textSize
textView.setTextColor(textColor)
val bgView = rootView.findViewById<ImageView>(R.id.iv_bg)
val bgView = findViewById<ImageView>(R.id.iv_bg)
GlideApp.with(bgView)
.load(resourceContent).into(object : CustomTarget<Drawable>() {
override fun onResourceReady(
@@ -71,7 +71,7 @@ class TemplateImageNotify(context: Context) : BaseFloatView(context),
CommonJumpHelper.bannerJump(context, skipType, data.skipContent)
}
}
rootView.setOnClickListener(clickAction)
setOnClickListener(clickAction)
textView.setOnClickListener(clickAction)
}
startDelayRemove()

View File

@@ -46,14 +46,14 @@ class TemplateSvgaNotify(context: Context) : BaseFloatView(context),
requestRemoveSelf()
return
}
val textView = rootView.findViewById<TextView>(R.id.tv_text)
val textView = findViewById<TextView>(R.id.tv_text)
val textSize = data.fontSize?.toFloat() ?: 12f
val textColor =
templateMessageAdapter.parseColor(data.textColor) ?: Color.WHITE
textView.textSize = textSize
textView.setTextColor(textColor)
val svgaView = rootView.findViewById<SVGAImageView>(R.id.iv_bg)
val svgaView = findViewById<SVGAImageView>(R.id.iv_bg)
SVGAParser.shareParser().decodeFromURL(
URL(resourceContent),
object : SVGAParser.ParseCompletion {
@@ -78,7 +78,7 @@ class TemplateSvgaNotify(context: Context) : BaseFloatView(context),
CommonJumpHelper.bannerJump(context, skipType, data.skipContent)
}
}
rootView.setOnClickListener(clickAction)
setOnClickListener(clickAction)
textView.setOnClickListener(clickAction)
}
val drawable = SVGADrawable(videoItem)