fix : 修复遗留bug

This commit is contained in:
eggmanQQQ
2024-12-05 17:38:24 +08:00
parent 521a0b0662
commit 6b9b1bc8ca
14 changed files with 1515 additions and 219 deletions

View File

@@ -1 +1,32 @@
[{"name":"Taiwan","abbr":"TW","mcc":"466","code":"886"},{"name":"Hong Kong","abbr":"HK","mcc":"454","code":"852"},{"name":"Singapore","abbr":"SG","mcc":"525","code":"65"},{"name":"Malaysia","abbr":"MY","mcc":"502","code":"60"},{"name":"China","abbr":"CN","mcc":"460","code":"86"}]
[
{
"name": "Taiwan",
"abbr": "TW",
"mcc": "466",
"code": "886"
},
{
"name": "Hong Kong",
"abbr": "HK",
"mcc": "454",
"code": "852"
},
{
"name": "Singapore",
"abbr": "SG",
"mcc": "525",
"code": "65"
},
{
"name": "Malaysia",
"abbr": "MY",
"mcc": "502",
"code": "60"
},
{
"name": "China",
"abbr": "CN",
"mcc": "460",
"code": "86"
}
]

File diff suppressed because one or more lines are too long

View File

@@ -4,22 +4,16 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import com.hjq.toast.ToastUtils;
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
import com.orhanobut.logger.Logger;
import com.chwl.app.R;
import com.chwl.app.UIHelper;
import com.chwl.app.avroom.widget.ViewItem;
import com.chwl.app.common.widget.dialog.DialogManager;
import com.chwl.app.room_chat.activity.RoomMsgActivity;
import com.chwl.app.ui.im.avtivity.NimFriendModel;
import com.chwl.app.ui.im.avtivity.NimP2PMessageActivity;
import com.chwl.app.ui.widget.ButtonItem;
import com.chwl.app.ui.widget.GiftDialog;
import com.chwl.app.vip.util.VipHelper;
import com.chwl.app.room_chat.activity.RoomMsgActivity;
import com.chwl.core.auth.AuthModel;
import com.chwl.core.bean.RoomQueueInfo;
import com.chwl.core.initial.InitialModel;
@@ -40,6 +34,12 @@ import com.chwl.library.utils.JavaUtil;
import com.chwl.library.utils.ResUtil;
import com.chwl.library.utils.SingleToastUtil;
import com.chwl.library.utils.config.BasicConfig;
import com.hjq.toast.ToastUtils;
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
import com.orhanobut.logger.Logger;
import java.util.ArrayList;
import java.util.HashMap;
@@ -194,16 +194,8 @@ public class ButtonItemFactory {
return buttonItems;
}
/**
* 踩TA当该人再房间中的时候进入他所在的房间
*
* @return
*/
private static ViewItem createFindMeItem() {
ViewItem viewItem = new ViewItem(ResUtil.getString(R.string.erban_avroom_buttonitemfactory_01), R.drawable.icon_dialog_find_ta, null);
viewItem.isFindTa = true;
return viewItem;
}
/**
* 根据account获取昵称
@@ -222,6 +214,19 @@ public class ButtonItemFactory {
}
/**
* 踩TA当该人再房间中的时候进入他所在的房间
*
* @return
*/
private static ViewItem createFindMeItem() {
ViewItem viewItem = new ViewItem(ResUtil.getString(R.string.erban_avroom_buttonitemfactory_01), R.drawable.icon_dialog_find_ta, null);
viewItem.isFindTa = true;
return viewItem;
}
/**
* 私聊
*/

View File

@@ -56,6 +56,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import com.alibaba.fastjson.JSON;
import com.bumptech.glide.request.target.Target;
import com.chwl.app.R;
import com.chwl.app.UIHelper;
@@ -169,11 +170,13 @@ import com.chwl.core.treasurefairy.bean.FairyMsgInfoBean;
import com.chwl.core.user.UserModel;
import com.chwl.core.user.bean.UserInfo;
import com.chwl.core.utils.ExtensionUtil;
import com.chwl.core.utils.JsonUtils;
import com.chwl.core.utils.LogUtils;
import com.chwl.core.utils.extension.StringExtensionKt;
import com.chwl.core.utils.net.DontWarnObserver;
import com.chwl.core.utils.net.RxHelper;
import com.chwl.core.vip.bean.VipMessageInfo;
import com.chwl.library.common.util.OtherExtKt;
import com.chwl.library.common.util.Utils;
import com.chwl.library.rxbus.RxBus;
import com.chwl.library.utils.FormatUtils;
@@ -2809,6 +2812,28 @@ public class MessageView extends FrameLayout {
String senderNick = "";
List<String> nicks = attachment.getTargetNicks();
if (nicks != null && nicks.size() > 0) senderNick = RegexUtil.getPrintableString(attachment.getTargetNicks().get(0));
ArrayList<String> targets = attachment.getTargets();
if (OtherExtKt.isVerify(targets) && OtherExtKt.isVerify(0,targets)) {
String uid = targets.get(0);
ChatRoomMessageExtension chatRoomMessageExtension = chatRoomMessage.getChatRoomMessageExtension();
if (chatRoomMessageExtension != null) {
Map<String, Object> senderExtension = chatRoomMessageExtension.getSenderExtension();
if (senderExtension != null) {
Object o = ((Map<String, Object>) chatRoomMessage.getChatRoomMessageExtension().getSenderExtension()).get(uid);
if (o != null) {
String json = JSON.toJSONString(o);
OtherExtKt.doLog(json);
String nick = JsonUtils.getString(json, UserInfo.NICK, "");
if (OtherExtKt.isVerify(nick)) {
senderNick = nick;
}
}
}
}
}
if (attachment.getType() != NotificationType.ChatRoomMemberIn) return;
// 座駕

View File

@@ -23,6 +23,7 @@ import android.view.animation.AnimationUtils
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.alibaba.fastjson.JSON
import com.chwl.app.R
import com.chwl.app.avroom.activity.AVRoomActivity
import com.chwl.app.avroom.helper.AnimHelper
@@ -47,8 +48,11 @@ import com.chwl.core.room.bean.DatingNotifyInfo
import com.chwl.core.super_admin.util.SuperAdminUtil
import com.chwl.core.user.UserModel
import com.chwl.core.user.bean.UserInfo
import com.chwl.core.utils.JsonUtils
import com.chwl.core.utils.extension.subAndReplaceDot
import com.chwl.library.common.util.doLog
import com.chwl.library.common.util.isRtl
import com.chwl.library.common.util.isVerify
import com.chwl.library.utils.ListUtils
import com.chwl.library.utils.ResUtil
import com.coorchice.library.SuperTextView
@@ -714,10 +718,31 @@ class RoomEffectBoxView @JvmOverloads constructor(
val attachment = chatRoomMessage.attachment as ChatRoomNotificationAttachment
val remoteExtension = chatRoomMessage.remoteExtension ?: return
val experLevelSeq = remoteExtension["experLevelSeq"] as Int
val targetNicks: List<String?> = attachment.targetNicks
val targetNicks: MutableList<String?> = attachment.targetNicks
val targets: List<String?> = attachment.targets
if (ListUtils.isListEmpty(targetNicks)) {
return
}
if (targets.getOrNull(0).isVerify()) {
val uid = targets.getOrNull(0)
val chatRoomMessageExtension = chatRoomMessage.chatRoomMessageExtension
if (chatRoomMessageExtension != null) {
val senderExtension = chatRoomMessageExtension.senderExtension
if (senderExtension != null) {
val o = (chatRoomMessage.chatRoomMessageExtension.senderExtension as Map<String?, Any?>)[uid]
if (o != null) {
val json = JSON.toJSONString(o)
json.doLog()
val nick = JsonUtils.getString(json, UserInfo.NICK, "")
if (nick.isVerify()) {
targetNicks[0] = nick
}
}
}
}
}
val fromType = remoteExtension["fromType"] as Int
val fromNick = remoteExtension["fromNick"] as String?
val textView = LayoutInflater.from(mContext)

View File

@@ -25,6 +25,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import com.alibaba.fastjson.JSON
import com.chwl.app.R
import com.chwl.app.avroom.activity.AVRoomActivity
import com.chwl.app.avroom.bean.RoomPlayBean
@@ -68,8 +69,11 @@ import com.chwl.core.room.bean.DatingNotifyInfo
import com.chwl.core.super_admin.util.SuperAdminUtil
import com.chwl.core.user.UserModel
import com.chwl.core.user.bean.UserInfo
import com.chwl.core.utils.JsonUtils
import com.chwl.core.utils.extension.subAndReplaceDot
import com.chwl.library.common.util.doLog
import com.chwl.library.common.util.isRtl
import com.chwl.library.common.util.isVerify
import com.chwl.library.utils.ListUtils
import com.chwl.library.utils.ResUtil
import com.chwl.library.utils.StringUtils
@@ -1431,10 +1435,31 @@ class RoomEffectView @JvmOverloads constructor(
val attachment = chatRoomMessage.attachment as ChatRoomNotificationAttachment
val remoteExtension = chatRoomMessage.remoteExtension ?: return
val experLevelSeq = remoteExtension["experLevelSeq"] as Int
val targetNicks: List<String?> = attachment.targetNicks
val targetNicks: MutableList<String?> = attachment.targetNicks
val targets: List<String?> = attachment.targets
if (ListUtils.isListEmpty(targetNicks)) {
return
}
if (targets.getOrNull(0).isVerify()) {
val uid = targets.getOrNull(0)
val chatRoomMessageExtension = chatRoomMessage.chatRoomMessageExtension
if (chatRoomMessageExtension != null) {
val senderExtension = chatRoomMessageExtension.senderExtension
if (senderExtension != null) {
val o = (chatRoomMessage.chatRoomMessageExtension.senderExtension as Map<String?, Any?>)[uid]
if (o != null) {
val json = JSON.toJSONString(o)
json.doLog()
val nick = JsonUtils.getString(json, UserInfo.NICK, "")
if (nick.isVerify()) {
targetNicks[0] = nick
}
}
}
}
}
val fromType = remoteExtension["fromType"] as Int
val fromNick = remoteExtension["fromNick"] as String?
val textView = LayoutInflater.from(mContext)

View File

@@ -14,11 +14,9 @@ import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -1138,15 +1136,6 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
}
}
private TextView getTextView(String text) {
TextView textView = new TextView(getContext());
textView.setText(text);
textView.setTextColor(getContext().getResources().getColor(R.color.color_333333));
textView.setTextSize(14);
textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
textView.setGravity(Gravity.CENTER);
return textView;
}
private ViewItem createClearGiftValueItem() {
return new ViewItem(getString(R.string.ui_widget_userinfodialog_013), R.drawable.user_card_ic_clean_gift_value, true, new ViewItem.OnClickListener() {
@@ -1184,102 +1173,6 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
});
}
/**
* 下麦前需要判断是否是ktv模式或者龙珠
*/
private void showDownMicDialog() {
if (AvRoomDataManager.get().mCurrentRoomInfo == null) {
return;
}
if (AvRoomDataManager.get().isSelfGamePlaying()) {
SingleToastUtil.showToast(getString(R.string.ui_widget_userinfodialog_017));
return;
}
if (AvRoomDataManager.get().haveStartDragon) {
new DialogManager(context).showOkCancelDialog(getString(R.string.ui_widget_userinfodialog_018), false, new DialogManager.OkCancelDialogListener() {
@Override
public void onCancel() {
}
@Override
public void onOk() {
DragonBallModel.get()
.clearDragonBar()
.doOnSuccess(s -> {
AvRoomDataManager.get().haveStartDragon = false;
cancelDragon();
handleDownMicro();
})
.subscribe();
}
});
} else {
handleDownMicro();
}
}
private void handleDownMicro() {
if (AvRoomDataManager.get().isShowGiftValue()
&& GiftValueDialogUiHelper.get().isNeedConfirmDialog(GiftValueDialogUiHelper.TYPE_DOWN_MIC)) {
GiftValueDialogUiHelper.get().showGiftValueDialog(context, null, GiftValueDialogUiHelper.TYPE_DOWN_MIC,
this::downMicCode);
} else {
downMicCode();
}
}
/**
* 下麦的代码
*/
private void downMicCode() {
long currentUid = AuthModel.get().getCurrentUid();
int micPos = AvRoomDataManager.get().getMicPosition(currentUid);
IMNetEaseManager.get().downMicroPhoneBySdk(
micPos, null);
}
public void cancelDragon() {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo == null) return;
// 普通表情
final ChatRoomMessage message = getChatRoomMessage(roomInfo, AvRoomDataManager.get().dragons, CUSTOM_MSG_DRAGON_BAR_CANCEL);
IMNetEaseManager.get().sendChatRoomMessage(message, false)
.subscribe((chatRoomMessage, throwable) -> {
IMNetEaseManager.get().getChatRoomEventObservable().
onNext(new RoomEvent().setEvent(DRAGON_BAR_CANCEL)
.setChatRoomMessage(chatRoomMessage));
IMNetEaseManager.get().addMessages(chatRoomMessage);
});
}
private ChatRoomMessage getChatRoomMessage(RoomInfo roomInfo, List<Integer> integers, int second) {
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
List<FaceReceiveInfo> faceReceiveInfos = new ArrayList<>();
FaceReceiveInfo faceReceiveInfo = new FaceReceiveInfo();
faceReceiveInfo.setNick(userInfo.getNick());
faceReceiveInfo.setFaceId(Constants.DRAGON_BAR_ID);
faceReceiveInfo.setUid(userInfo.getUid());
faceReceiveInfo.setResultIndexes(integers);
faceReceiveInfos.add(faceReceiveInfo);
// 发送云信信息给所有人
FaceAttachment faceAttachment =
new FaceAttachment(CUSTOM_MSG_DRAGON_BAR, second);
faceAttachment.setUid(userInfo.getUid());
faceAttachment.setFaceReceiveInfos(faceReceiveInfos);
return ChatRoomMessageBuilder.createChatRoomCustomMessage(
// 聊天室id
roomInfo.getRoomId() + "",
// 自定义消息
faceAttachment
);
}
private ViewItem createBanMicItem(int micPosition) {
return new ViewItem(getString(R.string.ui_widget_userinfodialog_019), R.drawable.user_card_ic_close_mic, true, new ViewItem.OnClickListener() {
@Override
@@ -1474,6 +1367,103 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
});
}
/**
* 下麦前需要判断是否是ktv模式或者龙珠
*/
private void showDownMicDialog() {
if (AvRoomDataManager.get().mCurrentRoomInfo == null) {
return;
}
if (AvRoomDataManager.get().isSelfGamePlaying()) {
SingleToastUtil.showToast(getString(R.string.ui_widget_userinfodialog_017));
return;
}
if (AvRoomDataManager.get().haveStartDragon) {
new DialogManager(context).showOkCancelDialog(getString(R.string.ui_widget_userinfodialog_018), false, new DialogManager.OkCancelDialogListener() {
@Override
public void onCancel() {
}
@Override
public void onOk() {
DragonBallModel.get()
.clearDragonBar()
.doOnSuccess(s -> {
AvRoomDataManager.get().haveStartDragon = false;
cancelDragon();
handleDownMicro();
})
.subscribe();
}
});
} else {
handleDownMicro();
}
}
private void handleDownMicro() {
if (AvRoomDataManager.get().isShowGiftValue()
&& GiftValueDialogUiHelper.get().isNeedConfirmDialog(GiftValueDialogUiHelper.TYPE_DOWN_MIC)) {
GiftValueDialogUiHelper.get().showGiftValueDialog(context, null, GiftValueDialogUiHelper.TYPE_DOWN_MIC,
this::downMicCode);
} else {
downMicCode();
}
}
/**
* 下麦的代码
*/
private void downMicCode() {
long currentUid = AuthModel.get().getCurrentUid();
int micPos = AvRoomDataManager.get().getMicPosition(currentUid);
IMNetEaseManager.get().downMicroPhoneBySdk(
micPos, null);
}
public void cancelDragon() {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo == null) return;
// 普通表情
final ChatRoomMessage message = getChatRoomMessage(roomInfo, AvRoomDataManager.get().dragons, CUSTOM_MSG_DRAGON_BAR_CANCEL);
IMNetEaseManager.get().sendChatRoomMessage(message, false)
.subscribe((chatRoomMessage, throwable) -> {
IMNetEaseManager.get().getChatRoomEventObservable().
onNext(new RoomEvent().setEvent(DRAGON_BAR_CANCEL)
.setChatRoomMessage(chatRoomMessage));
IMNetEaseManager.get().addMessages(chatRoomMessage);
});
}
private ChatRoomMessage getChatRoomMessage(RoomInfo roomInfo, List<Integer> integers, int second) {
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
List<FaceReceiveInfo> faceReceiveInfos = new ArrayList<>();
FaceReceiveInfo faceReceiveInfo = new FaceReceiveInfo();
faceReceiveInfo.setNick(userInfo.getNick());
faceReceiveInfo.setFaceId(Constants.DRAGON_BAR_ID);
faceReceiveInfo.setUid(userInfo.getUid());
faceReceiveInfo.setResultIndexes(integers);
faceReceiveInfos.add(faceReceiveInfo);
// 发送云信信息给所有人
FaceAttachment faceAttachment =
new FaceAttachment(CUSTOM_MSG_DRAGON_BAR, second);
faceAttachment.setUid(userInfo.getUid());
faceAttachment.setFaceReceiveInfos(faceReceiveInfos);
return ChatRoomMessageBuilder.createChatRoomCustomMessage(
// 聊天室id
roomInfo.getRoomId() + "",
// 自定义消息
faceAttachment
);
}
@SuppressLint("CheckResult")
private void kickDownMicCode() {
int micPosition = AvRoomDataManager.get().getMicPosition(uid);

View File

@@ -151,17 +151,18 @@
android:id="@+id/tv_online_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:layout_marginBottom="15dp"
android:drawableStart="@drawable/home_ic_hot"
android:drawablePadding="3dp"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:layout_marginEnd="11dp"
android:textColor="#84868A"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/boomIcon"
app:layout_constraintStart_toStartOf="@id/boomIcon"
tools:text="266" />
app:layout_constraintEnd_toEndOf="parent"
tools:text="9999999" />
<com.tencent.qgame.animplayer.AnimView

View File

@@ -49,22 +49,24 @@
<TextView
android:id="@+id/gift_name"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/gift_image"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="3dp"
android:layout_marginTop="3dp"
android:gravity="center"
android:text="@{item.giftName}"
android:textColor="@{item.isSelect ? @color/color_ffb606 : @color/white}"
android:textSize="@dimen/dp_10"
android:maxLines="2"
android:maxLines="1"
android:ellipsize="end"
app:autoSizeMaxTextSize="@dimen/dp_10"
app:autoSizeMinTextSize="@dimen/dp_5"
app:autoSizeStepGranularity="1px"
app:autoSizeTextType="uniform"
tools:ignore="SpUsage"
tools:text="123" />
tools:text="123123123123123123123123123123123123123" />
<LinearLayout
android:id="@+id/layout_money"

View File

@@ -40,7 +40,7 @@
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/dp_2"
android:layout_marginHorizontal="@dimen/dp_3"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
@@ -52,7 +52,7 @@
app:autoSizeTextType="uniform"
app:layout_constraintBottom_toTopOf="@id/tv_count"
app:layout_constraintTop_toBottomOf="@id/iv_icon"
tools:text="Name" />
tools:text="NameNameNameNameNameNameNameNameNameNameNameNameNameNameNameNameNameNameNameName" />
<TextView
android:id="@+id/tv_count"

View File

@@ -41,9 +41,12 @@
android:layout_marginHorizontal="@dimen/dp_2"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_5"
tools:text="name"
tools:text="namenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename"
android:lines="1"
android:ellipsize="end"
android:gravity="center"
android:textColor="@color/white"
tools:textColor="@color/black"
android:textSize="@dimen/sp_12" />
</LinearLayout>

View File

@@ -1775,8 +1775,10 @@ public final class IMNetEaseManager {
}
if (!needToHideEnterMessage(msg)) {
// 添加消息到公屏
addMessagesImmediately(msg);
//需要稍微延遲點,否則有沖突
//通知播放 进场横幅动画
new Handler().postDelayed(() -> noticeMemBerInNotice(msg), 500);
} else {
if (Objects.equals(String.valueOf(AuthModel.get().getCurrentUid()), account)) {

View File

@@ -0,0 +1,256 @@
package com.chwl.core.utils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2019/01/07
* desc : utils about json
* </pre>
*/
public final class JsonUtils {
private static final byte TYPE_BOOLEAN = 0x00;
private static final byte TYPE_INT = 0x01;
private static final byte TYPE_LONG = 0x02;
private static final byte TYPE_DOUBLE = 0x03;
private static final byte TYPE_STRING = 0x04;
private static final byte TYPE_JSON_OBJECT = 0x05;
private static final byte TYPE_JSON_ARRAY = 0x06;
private JsonUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* Checks if a given input is a JSONObject.
*
* @param input Anything.
* @return true if it is a JSONObject.
*/
public static <T> boolean isJSONObject(final T input) {
return input instanceof JSONObject;
}
/**
* Checks if a given input is a JSONArray
*
* @param input Anything.
* @return true if it is a JSONArray.
*/
public static <T> boolean isJSONArray(final T input) {
return input instanceof JSONArray;
}
public static boolean getBoolean(final JSONObject jsonObject,
final String key) {
return getBoolean(jsonObject, key, false);
}
public static boolean getBoolean(final JSONObject jsonObject,
final String key,
final boolean defaultValue) {
return getValueByType(jsonObject, key, defaultValue, TYPE_BOOLEAN);
}
public static boolean getBoolean(final String json,
final String key) {
return getBoolean(json, key, false);
}
public static boolean getBoolean(final String json,
final String key,
final boolean defaultValue) {
return getValueByType(json, key, defaultValue, TYPE_BOOLEAN);
}
public static int getInt(final JSONObject jsonObject,
final String key) {
return getInt(jsonObject, key, -1);
}
public static int getInt(final JSONObject jsonObject,
final String key,
final int defaultValue) {
return getValueByType(jsonObject, key, defaultValue, TYPE_INT);
}
public static int getInt(final String json,
final String key) {
return getInt(json, key, -1);
}
public static int getInt(final String json,
final String key,
final int defaultValue) {
return getValueByType(json, key, defaultValue, TYPE_INT);
}
public static long getLong(final JSONObject jsonObject,
final String key) {
return getLong(jsonObject, key, -1);
}
public static long getLong(final JSONObject jsonObject,
final String key,
final long defaultValue) {
return getValueByType(jsonObject, key, defaultValue, TYPE_LONG);
}
public static long getLong(final String json,
final String key) {
return getLong(json, key, -1);
}
public static long getLong(final String json,
final String key,
final long defaultValue) {
return getValueByType(json, key, defaultValue, TYPE_LONG);
}
public static double getDouble(final JSONObject jsonObject,
final String key) {
return getDouble(jsonObject, key, -1);
}
public static double getDouble(final JSONObject jsonObject,
final String key,
final double defaultValue) {
return getValueByType(jsonObject, key, defaultValue, TYPE_DOUBLE);
}
public static double getDouble(final String json,
final String key) {
return getDouble(json, key, -1);
}
public static double getDouble(final String json,
final String key,
final double defaultValue) {
return getValueByType(json, key, defaultValue, TYPE_DOUBLE);
}
public static String getString(final JSONObject jsonObject,
final String key) {
return getString(jsonObject, key, "");
}
public static String getString(final JSONObject jsonObject,
final String key,
final String defaultValue) {
return getValueByType(jsonObject, key, defaultValue, TYPE_STRING);
}
public static String getString(final String json,
final String key) {
return getString(json, key, "");
}
public static String getString(final String json,
final String key,
final String defaultValue) {
return getValueByType(json, key, defaultValue, TYPE_STRING);
}
public static JSONObject getJSONObject(final JSONObject jsonObject,
final String key,
final JSONObject defaultValue) {
return getValueByType(jsonObject, key, defaultValue, TYPE_JSON_OBJECT);
}
public static JSONObject getJSONObject(final String json,
final String key,
final JSONObject defaultValue) {
return getValueByType(json, key, defaultValue, TYPE_JSON_OBJECT);
}
public static JSONArray getJSONArray(final JSONObject jsonObject,
final String key,
final JSONArray defaultValue) {
return getValueByType(jsonObject, key, defaultValue, TYPE_JSON_ARRAY);
}
public static JSONArray getJSONArray(final String json,
final String key,
final JSONArray defaultValue) {
return getValueByType(json, key, defaultValue, TYPE_JSON_ARRAY);
}
private static <T> T getValueByType(final JSONObject jsonObject,
final String key,
final T defaultValue,
final byte type) {
if (jsonObject == null || key == null || key.length() == 0) {
return defaultValue;
}
try {
Object ret;
if (type == TYPE_BOOLEAN) {
ret = jsonObject.getBoolean(key);
} else if (type == TYPE_INT) {
ret = jsonObject.getInt(key);
} else if (type == TYPE_LONG) {
ret = jsonObject.getLong(key);
} else if (type == TYPE_DOUBLE) {
ret = jsonObject.getDouble(key);
} else if (type == TYPE_STRING) {
ret = jsonObject.getString(key);
} else if (type == TYPE_JSON_OBJECT) {
ret = jsonObject.getJSONObject(key);
} else if (type == TYPE_JSON_ARRAY) {
ret = jsonObject.getJSONArray(key);
} else {
return defaultValue;
}
//noinspection unchecked
return (T) ret;
} catch (JSONException e) {
e.printStackTrace();
return defaultValue;
}
}
private static <T> T getValueByType(final String json,
final String key,
final T defaultValue,
final byte type) {
if (json == null || json.length() == 0
|| key == null || key.length() == 0) {
return defaultValue;
}
try {
return getValueByType(new JSONObject(json), key, defaultValue, type);
} catch (JSONException e) {
e.printStackTrace();
return defaultValue;
}
}
public static String formatJson(final String json) {
return formatJson(json, 4);
}
public static String formatJson(final String json, final int indentSpaces) {
try {
for (int i = 0, len = json.length(); i < len; i++) {
char c = json.charAt(i);
if (c == '{') {
return new JSONObject(json).toString(indentSpaces);
} else if (c == '[') {
return new JSONArray(json).toString(indentSpaces);
} else if (!Character.isWhitespace(c)) {
return json;
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return json;
}
}

110
mode.json
View File

@@ -1,83 +1,29 @@
{
"code": 200,
"message": "success",
"data": {
"totalPage": 1,
"nameplateList": [
{
"id": 406,
"uid": 3224,
"nameplateId": 101,
"isCustomWord": true,
"word": " 555",
"remark": " 555",
"expireTime": 1738663248000,
"createTime": 1731319248000,
"updateTime": 1731319248000,
"nameplateName": " 555",
"nameplateImage": "https://image.pekolive.com/11094f2f00fb491f963132463bab97ec.png",
"isExpired": false,
"expireDays": 62,
"isUsing": false,
"iconPic": "https://image.pekolive.com/gonghuizhangmingpaikaobei.png",
"fixedWord": " 555",
"nameplateType": "1",
"dressShopId": 33,
"dressPrice": 1000,
"discountPrice": 950,
"vipLevel": 5,
"discount": 95,
"dressDay": 9
},
{
"id": 529,
"uid": 3224,
"nameplateId": 100,
"isCustomWord": false,
"word": " ",
"remark": " ",
"expireTime": 1737195843000,
"createTime": 1733307843000,
"updateTime": 1733307843000,
"nameplateName": "schoolgirl-Advanced",
"nameplateImage": "https://image.pekolive.com/guanfangzhuli-bajisitan.png",
"isExpired": false,
"expireDays": 45,
"isUsing": true,
"iconPic": "https://image.pekolive.com/guanfangzhuli-bajisitan.png",
"nameplateType": "1",
"dressShopId": 84,
"dressPrice": 2233,
"discountPrice": 2121,
"vipLevel": 5,
"discount": 95,
"dressDay": 9
},
{
"id": 407,
"uid": 3224,
"nameplateId": 100,
"isCustomWord": false,
"word": " ",
"remark": " ",
"expireTime": 1733220061000,
"createTime": 1731319261000,
"updateTime": 1731319261000,
"nameplateName": "schoolgirl-Advanced",
"nameplateImage": "https://image.pekolive.com/guanfangzhuli-bajisitan.png",
"isExpired": true,
"expireDays": 0,
"isUsing": false,
"iconPic": "https://image.pekolive.com/guanfangzhuli-bajisitan.png",
"nameplateType": "1",
"dressShopId": 84,
"dressPrice": 2233,
"discountPrice": 2121,
"vipLevel": 5,
"discount": 95,
"dressDay": 9
}
]
},
"timestamp": 1733307990888
}
"enterRoomEffects": "https://image.molistar.xyz/v6_enter_effect.svga",
"charmUrl": "https://image.pekolive.com/Charm_52.png",
"gender": 1,
"carName": "boom11",
"official": false,
"officialAnchorCertificationIcon": "",
"pic": "https://image.pekolive.com/Vip6headdress.png",
"androidBubbleUrl": "https://image.molistar.xyz/v6_chatbubble_android.png",
"platformRole": 0,
"nick": "Molistar",
"fromType": 0,
"headWearUrl": "https://image.pekolive.com/Vip6headdress.svga",
"headWearType": 1,
"experUrl": "https://image.pekolive.com/Wealth_48.png",
"experLevelSeq": 48,
"inRoomNameplateWord": " ",
"hasPrettyErbanNo": false,
"iosBubbleUrl": "https://image.molistar.xyz/v6_chatbubble_ios.png",
"avatar": "https://image.pekolive.com/bfed3b08-1ebe-42dc-b9a4-619cb2da0e43.gif",
"enterHide": false,
"vipIcon": "https://image.molistar.xyz/VIP6_nameplate.png",
"inRoomNameplatePic": "https://image.pekolive.com/guanfangzhuli-bajisitan.png",
"newUser": false,
"effect": "https://image.pekolive.com/Vip6headdress.svga",
"fromSayHelloChannel": false,
"defUser": 1,
"officialAnchorCertificationName": ""
} at (RoomEffectView.kt:1453)