[Modify]SVGA动画多语言适配

This commit is contained in:
wushaocheng
2023-06-01 15:39:40 +08:00
parent 8e659b1d29
commit f2995f9683
11 changed files with 64 additions and 12 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -62,6 +62,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import java.net.MalformedURLException
import java.net.URL
import java.util.*
import java.util.concurrent.TimeUnit
/**
@@ -249,7 +250,7 @@ class RoomEffectView @JvmOverloads constructor(
}
/**
* 幸运池飘屏
* 夺宝精灵飘屏
*
* @param chatRoomMessage
*/
@@ -270,6 +271,9 @@ class RoomEffectView @JvmOverloads constructor(
}
}
/**
* 夺宝精灵SVGA
*/
private fun showFairyNotify(pair: Pair<Int, ChatRoomMessage>) {
val attachment = pair.second.attachment as FairyMsgAttachment
when (pair.first) {
@@ -291,13 +295,38 @@ class RoomEffectView @JvmOverloads constructor(
}
RoomEvent.FAIRY_DRAW_GIFT_L5,
RoomEvent.FAIRY_CONVERT_L3 -> {
showFairyNotifyBySVGA(pair)
when (Locale.getDefault().language) {
"ar" -> {
showFairyNotifyBySVGA(pair, "svga/all_fairy_ar.svga")
}
"en" -> {
showFairyNotifyBySVGA(pair, "svga/all_fairy_en.svga")
}
"in" -> {
showFairyNotifyBySVGA(pair, "svga/all_fairy_in.svga")
}
"tr" -> {
showFairyNotifyBySVGA(pair, "svga/all_fairy_tr.svga")
}
"zh" ->{
showFairyNotifyBySVGA(pair, "svga/all_fairy.svga")
}
"zh-rTW" ->{
showFairyNotifyBySVGA(pair, "svga/all_fairy.svga")
}
else -> {
showFairyNotifyBySVGA(pair, "svga/all_fairy_en.svga")
}
}
}
}
}
private fun showFairyNotifyBySVGA(pair: Pair<Int, ChatRoomMessage>) {
/**
* 夺宝精灵SVGA
*/
private fun showFairyNotifyBySVGA(pair: Pair<Int, ChatRoomMessage>, svgaName: String) {
val attachment = pair.second.attachment as FairyMsgAttachment
val text = MsgBuilder.buildFairyMsg(pair.first, attachment)
val svgaImageView = SVGAImageView(mContext)
@@ -316,7 +345,7 @@ class RoomEffectView @JvmOverloads constructor(
}
binding.flFairyNotify.addView(svgaImageView)
shareParser().decodeFromAssets(
"svga/all_fairy.svga",
svgaName,
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
val dynamicEntity = SVGADynamicEntity()
@@ -442,14 +471,34 @@ class RoomEffectView @JvmOverloads constructor(
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesLuckyGift.size > 0 }
.subscribe {
showLuckyBagNotify(
messagesLuckyGift.removeAt(0)
)
when (Locale.getDefault().language) {
"ar" -> {
showLuckyBagNotify(messagesLuckyGift.removeAt(0),"svga/lucky_gift_notify_ar.svga")
}
"en" -> {
showLuckyBagNotify(messagesLuckyGift.removeAt(0),"svga/lucky_gift_notify_en.svga")
}
"in" -> {
showLuckyBagNotify(messagesLuckyGift.removeAt(0),"svga/lucky_gift_notify_in.svga")
}
"tr" -> {
showLuckyBagNotify(messagesLuckyGift.removeAt(0),"svga/lucky_gift_notify_tr.svga")
}
"zh" ->{
showLuckyBagNotify(messagesLuckyGift.removeAt(0),"svga/lucky_gift_notify.svga")
}
"zh-rTW" ->{
showLuckyBagNotify(messagesLuckyGift.removeAt(0),"svga/lucky_gift_notify.svga")
}
else -> {
showLuckyBagNotify(messagesLuckyGift.removeAt(0),"svga/lucky_gift_notify_en.svga")
}
}
}
}
}
private fun showLuckyBagNotify(message: ChatRoomMessage?) {
private fun showLuckyBagNotify(message: ChatRoomMessage?, svgaName: String) {
val attachment = message?.attachment as? RoomReceivedLuckyGiftAttachment ?: return
val noticeInfo = attachment.luckyBagNoticeInfo ?: return
val text = SpannableBuilder()
@@ -490,7 +539,7 @@ class RoomEffectView @JvmOverloads constructor(
svgaImageView.loops = 1
svgaImageView.clearsAfterStop = true
shareParser().decodeFromAssets(
"svga/lucky_gift_notify.svga",
svgaName,
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
binding.flLuckyGiftNotify.addView(svgaImageView)
@@ -1654,7 +1703,10 @@ class RoomEffectView @JvmOverloads constructor(
ResUtil.getString(R.string.avroom_widget_roomeffectview_025),
ForegroundColorSpan(Color.WHITE)
)
.append("${msgBean.title}${ResUtil.getString(R.string.room)}", ForegroundColorSpan(Color.parseColor("#FFFC4C")))
.append(
"${msgBean.title}${ResUtil.getString(R.string.room)}",
ForegroundColorSpan(Color.parseColor("#FFFC4C"))
)
.append(msgBean.desc, ForegroundColorSpan(Color.WHITE))
.append("TOP1", ForegroundColorSpan(Color.parseColor("#FFFC4C")))
textView.text = text.build()

View File

@@ -1500,7 +1500,7 @@
<string name="avroom_fragment_homepartyfragment_02">遊戲中不可以切換遊戲或玩法!</string>
<string name="avroom_fragment_homepartyfragment_03">遊戲中不可以切換遊戲或玩法!</string>
<string name="avroom_fragment_homepartyfragment_04">請關閉其他模式再切換遊戲!</string>
<string name="avroom_fragment_homepartyfragment_05"></string>
<string name="avroom_fragment_homepartyfragment_05">擴列交友</string>
<string name="avroom_fragment_homepartyfragment_06">管理員已關閉聊天公屏</string>
<string name="avroom_fragment_homepartyfragment_07">禮物特效</string>
<string name="avroom_fragment_homepartyfragment_010">收藏成功!</string>

View File

@@ -1500,7 +1500,7 @@
<string name="avroom_fragment_homepartyfragment_02">遊戲中不可以切換遊戲或玩法!</string>
<string name="avroom_fragment_homepartyfragment_03">遊戲中不可以切換遊戲或玩法!</string>
<string name="avroom_fragment_homepartyfragment_04">請關閉其他模式再切換遊戲!</string>
<string name="avroom_fragment_homepartyfragment_05"></string>
<string name="avroom_fragment_homepartyfragment_05">擴列交友</string>
<string name="avroom_fragment_homepartyfragment_06">管理員已關閉聊天公屏</string>
<string name="avroom_fragment_homepartyfragment_07">禮物特效</string>
<string name="avroom_fragment_homepartyfragment_010">收藏成功!</string>