fix:礼物名称 动态适配多语言

This commit is contained in:
max
2024-07-11 11:24:18 +08:00
parent e7b73a2961
commit bc48cc86a9
9 changed files with 44 additions and 10 deletions

View File

@@ -11,6 +11,18 @@ import java.io.Serializable
**/
@Keep
class I18N : HashMap<String, String>(), Serializable {
companion object {
@JvmStatic
fun getFirstOrDefault(i18N: I18N?, default: String?): String? {
val text = i18N?.getFirstText()
if (text.isNullOrEmpty()) {
return default
}
return text
}
}
/**
* 获取优先显示文本
*/

View File

@@ -2,11 +2,11 @@ package com.chwl.core.gift.bean;
import android.text.TextUtils;
import com.chwl.core.bean.I18N;
import com.google.gson.annotations.SerializedName;
import com.netease.nim.uikit.common.util.string.StringUtil;
import java.io.Serializable;
import java.net.MalformedURLException;
import lombok.Data;
@@ -107,6 +107,12 @@ public class GiftInfo implements Serializable {
//免费礼物倒计时进度
private long mFreeGiftProgress = 0;
private I18N i18nGiftNameMap;
public String getFirstGiftName() {
return I18N.getFirstOrDefault(i18nGiftNameMap, giftName);
}
public long getFreeGiftProgress() {
return mFreeGiftProgress;
}

View File

@@ -1,5 +1,6 @@
package com.chwl.core.gift.bean;
import com.chwl.core.bean.I18N;
import com.chwl.core.room.giftvalue.bean.IndexGiftValue;
import java.io.Serializable;
@@ -13,12 +14,13 @@ public class LuckyBagGifts implements Serializable {
private GiftReceiver user;
private String nick;
private String giftName;
private I18N i18nGiftNameMap;
private int giftNum;
private List<GiftInfo> displayGift;
private boolean isShowAnimation = true;
private String targetNick;
private long targetUid;
// private List<GiftReceiver> targetUsers;
// private List<GiftReceiver> targetUsers;
private List<Long> targetUids;
private long uid;
private int giftId;
@@ -27,4 +29,11 @@ public class LuckyBagGifts implements Serializable {
private String luckyGiftSvgaUrl;
private LuckyGiftList luckyGiftList;
public String getFirstGiftName() {
String name = I18N.getFirstOrDefault(i18nGiftNameMap, giftName);
if (name == null) {
return "";
}
return name;
}
}

View File

@@ -350,6 +350,7 @@ public class GiftToolbox {
luckyBagGifts.setLuckyGiftSvgaUrl(giftReceiveInfo.getGift().getLuckyGiftSvgaUrl());
luckyBagGifts.setDisplayGift(giftReceiveInfo.getDisplayGift());
luckyBagGifts.setGiftName(giftReceiveInfo.getGift().getGiftName());
luckyBagGifts.setI18nGiftNameMap(giftReceiveInfo.getGift().getI18nGiftNameMap());
luckyBagGifts.setCurrentTime(giftReceiveInfo.getCurrentTime());
luckyBagGifts.setGiftNum(giftReceiveInfo.getGiftNum());
luckyBagGifts.setTargetNick(giftReceiveInfo.getTargetUsers().get(0).getNick());
@@ -405,6 +406,7 @@ public class GiftToolbox {
luckyBagGifts.setLuckyGiftSvgaUrl(giftReceiveInfo.getGift().getLuckyGiftSvgaUrl());
luckyBagGifts.setDisplayGift(giftReceiveInfo.getDisplayGift());
luckyBagGifts.setGiftName(giftReceiveInfo.getGift().getGiftName());
luckyBagGifts.setI18nGiftNameMap(giftReceiveInfo.getGift().getI18nGiftNameMap());
luckyBagGifts.setCurrentTime(giftReceiveInfo.getCurrentTime());
List<Long> targetUids = new ArrayList<>();
for (GiftReceiver targetUser : giftReceiveInfo.getTargetUsers()) {

View File

@@ -57,6 +57,7 @@ public class MultiLuckyGiftAttachment extends CustomAttachment {
}
object.put("giftId", multiLuckyGiftReceiveInfo.getGiftId());
object.put("giftName", multiLuckyGiftReceiveInfo.getGiftName());
object.put("i18nGiftNameMap", multiLuckyGiftReceiveInfo.getI18nGiftNameMap());
object.put("targetNick", multiLuckyGiftReceiveInfo.getUser().getNick());
object.put("giftNum", multiLuckyGiftReceiveInfo.getGiftNum());
object.put("isShowAnimation", multiLuckyGiftReceiveInfo.isShowAnimation());

View File

@@ -3,6 +3,7 @@ package com.chwl.core.noble.bean;
import androidx.annotation.Keep;
import com.chwl.core.bean.BaseProtocol;
import com.chwl.core.bean.I18N;
/**
* Created by MadisonRong on 09/04/2018.
@@ -31,6 +32,7 @@ public class AllServiceGiftProtocol extends BaseProtocol<AllServiceGiftProtocol.
private String sendUserNick;
private int giftId;
private String giftName;
private I18N i18nGiftNameMap;
private int giftNum;
private String recvUserNick;
private int recvUserUid;
@@ -76,11 +78,7 @@ public class AllServiceGiftProtocol extends BaseProtocol<AllServiceGiftProtocol.
}
public String getGiftName() {
return giftName;
}
public void setGiftName(String giftName) {
this.giftName = giftName;
return I18N.getFirstOrDefault(i18nGiftNameMap, giftName);
}
public int getGiftNum() {