diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index d9ccd9be5..fcff8bdb7 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -38,6 +38,7 @@ import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.bean.AnchorStartLiveBean; import com.yunbao.common.bean.CrashSaveBean; +import com.yunbao.common.dialog.DebugDialog; import com.yunbao.common.event.SudGameSocketImEvent; import com.yunbao.common.manager.imrongcloud.InstructorSendReward; import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider; @@ -142,6 +143,7 @@ public class AppContext extends CommonAppContext { registerError(); registerFirebaseCrash(); LogUtils.start(this); + //DebugDialog.getInstance().setParams("初始化","启动"); sInstance = this; L.setDeBug(BuildConfig.DEBUG); AppEventsLogger.activateApp(this); diff --git a/common/src/main/java/com/yunbao/common/adapter/DebugDialogAdapter.java b/common/src/main/java/com/yunbao/common/adapter/DebugDialogAdapter.java new file mode 100644 index 000000000..478007151 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/DebugDialogAdapter.java @@ -0,0 +1,62 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.graphics.Color; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; +import java.util.List; +import java.util.TreeMap; + +public class DebugDialogAdapter extends RecyclerView.Adapter { + TreeMap paramMap = new TreeMap<>(); + private Context mContext; + + public DebugDialogAdapter(Context mContext) { + this.mContext = mContext; + } + + public void setParamMap(TreeMap paramMap) { + Log.i("debug弹窗", "setParamMap: 添加值到view " + paramMap.size()); + this.paramMap = paramMap; + notifyDataSetChanged(); + } + + @NonNull + @Override + public DebugViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new DebugViewHolder(new TextView(mContext)); + } + + @Override + public void onBindViewHolder(@NonNull DebugViewHolder holder, int position) { + List list = new ArrayList<>(paramMap.keySet()); + Log.i("debug弹窗", "onBindViewHolder: 添加值到view " + list.size() + "|" + paramMap.size()); + holder.setData(list.get(position), paramMap.get(list.get(position))); + } + + @Override + public int getItemCount() { + Log.i("debug弹窗", "getItemCount: " + paramMap.size()); + return paramMap.size(); + } + + public class DebugViewHolder extends RecyclerView.ViewHolder { + + public DebugViewHolder(@NonNull View itemView) { + super(itemView); + } + + public void setData(String tag, String msg) { + Log.i("debug弹窗", "setData: 添加值到view " + tag + "|" + msg); + ((TextView) itemView).setText(tag + ":" + msg); + ((TextView) itemView).setTextColor(Color.BLACK); + } + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/AiAutomaticSpeechModel.java b/common/src/main/java/com/yunbao/common/bean/AiAutomaticSpeechModel.java index 140e86000..428a79c84 100644 --- a/common/src/main/java/com/yunbao/common/bean/AiAutomaticSpeechModel.java +++ b/common/src/main/java/com/yunbao/common/bean/AiAutomaticSpeechModel.java @@ -1,6 +1,9 @@ package com.yunbao.common.bean; +import com.alibaba.fastjson.annotation.JSONField; import com.google.gson.annotations.SerializedName; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.WordUtil; /** * 机器人助手IM消息 @@ -21,6 +24,9 @@ public class AiAutomaticSpeechModel extends BaseModel { //标签图片 @SerializedName("icon") private String icon; + @SerializedName("icon_en") + @JSONField(name = "icon_en") + private String iconEn; //气泡背景 @SerializedName("system_bubble") private String systemBubble; @@ -35,7 +41,7 @@ public class AiAutomaticSpeechModel extends BaseModel { } public String getAiName() { - return aiName+":"; + return aiName + ":"; } public AiAutomaticSpeechModel setAiName(String aiName) { @@ -43,6 +49,14 @@ public class AiAutomaticSpeechModel extends BaseModel { return this; } + public String getIconEn() { + return iconEn; + } + + public void setIconEn(String iconEn) { + this.iconEn = iconEn; + } + public String getContent() { return content; } @@ -62,6 +76,9 @@ public class AiAutomaticSpeechModel extends BaseModel { } public String getIcon() { + if (!WordUtil.isNewZh() && !StringUtil.isEmpty(iconEn)) { + return iconEn; + } return icon; } diff --git a/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java b/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java new file mode 100644 index 000000000..900d421e9 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java @@ -0,0 +1,119 @@ +package com.yunbao.common.dialog; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Color; +import android.os.Handler; +import android.os.Looper; +import android.util.Log; +import android.view.ViewGroup; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.lzf.easyfloat.EasyFloat; +import com.lzf.easyfloat.enums.ShowPattern; +import com.lzf.easyfloat.interfaces.OnPermissionResult; +import com.lzf.easyfloat.permission.PermissionUtils; +import com.yunbao.common.adapter.DebugDialogAdapter; +import com.yunbao.common.utils.AppManager; +import com.yunbao.common.utils.ToastUtil; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeMap; + + +public class DebugDialog { + RecyclerView recyclerView; + TreeMap params; + DebugDialogAdapter adapter; + private static DebugDialog debugDialog; + Context mContext; + + public static DebugDialog getInstance() { + if (debugDialog == null) { + debugDialog = new DebugDialog(); + } + return debugDialog; + } + + public DebugDialog clear() { + params.clear(); + return this; + } + + public void setParams(String tag, String msg) { + Log.i("debug弹窗", "setParams: "+tag+"|"+msg); + params.put(tag, msg); + if (adapter != null) + adapter.setParamMap(params); + } + + private DebugDialog() { + if(params==null) { + Log.i("debug弹窗", "DebugDialog: 初始化参数"); + params = new TreeMap<>(); + } + init(); + } + private void init(){ + this.mContext = AppManager.getInstance().getMainActivity(); + if (mContext == null) { + startWaitMainActivity(); + return; + } + if (PermissionUtils.checkPermission(mContext)) { + createView(); + } else { + PermissionUtils.requestPermission((Activity) mContext, new OnPermissionResult() { + @Override + public void permissionResult(boolean b) { + ToastUtil.show("悬浮权限" + b); + if (b) { + createView(); + } + } + }); + } + // createView(); + } + + private void startWaitMainActivity() { + new Timer().schedule(new TimerTask() { + @Override + public void run() { + Log.i("debug弹窗", "run: "+AppManager.getInstance().getMainActivity()); + if (AppManager.getInstance().getMainActivity() != null) { + init(); + cancel(); + } + } + }, 0,1000); + } + + protected void createView() { + recyclerView = new RecyclerView(mContext); + adapter = new DebugDialogAdapter(mContext); + recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + recyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT)); + recyclerView.setAdapter(adapter); + recyclerView.setBackgroundColor(Color.WHITE); + EasyFloat.with(mContext) + .setTag("debug") + .setShowPattern(ShowPattern.FOREGROUND) + .setLayout(recyclerView) + .show(); + if(!params.isEmpty()){ + + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + adapter.setParamMap(params); + } + },1000); + Log.i("debug弹窗", "createView: 有值"); + } + Log.i("debug弹窗", "createView: 创建"); + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java index 40b01008b..1d46c8f71 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java @@ -19,6 +19,7 @@ import com.yunbao.common.event.LiveSudGameHistoryEvent; import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.SudGameListEvent; import com.yunbao.common.event.SudGameListSillEvent; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -87,6 +88,12 @@ public class SudGameListSelectPopup extends AttachPopupView { if (mType == 0 || mType == 4) { topSelect.setText(getContext().getString(R.string.interactive_game_room_all)); for (int i = 0; i < customSidebarChildModels.size(); i++) { + DebugDialog.getInstance().setParams("UserType", IMLoginManager.get(getContext()).getUserInfo().getUsersType()); + if (!IMLoginManager.get(getContext()).getUserInfo().anchorUserType()) { + if ("1490944230389182466".equals(customSidebarChildModels.get(i).getSrc())) {//友尽闯关 + continue; + } + } selectString.add(customSidebarChildModels.get(i).getTitle()); if (TextUtils.equals(String.valueOf(interactionID), customSidebarChildModels.get(i).getSrc())) { index = i; diff --git a/common/src/main/java/com/yunbao/common/utils/AppManager.java b/common/src/main/java/com/yunbao/common/utils/AppManager.java index 5bda4db57..f27c2815a 100644 --- a/common/src/main/java/com/yunbao/common/utils/AppManager.java +++ b/common/src/main/java/com/yunbao/common/utils/AppManager.java @@ -11,6 +11,7 @@ public class AppManager { private static Stack activityStack; public AppManager() { + activityStack=new Stack<>(); } /** @@ -20,6 +21,33 @@ public class AppManager { return SingleApp.INSTANCE; } + public static Activity getActivity(String activityName) { + for (Activity activity : activityStack) { + if (activity.getClass().getSimpleName().contains(activityName)) { + return activity; + } + } + return null; + } + + public Activity getMainActivity() { + for (Activity activity : activityStack) { + if (activity.getClass().getSimpleName().contains("MainActivity")) { + return activity; + } + } + return null; + } + + public Activity getLiveActivity() { + for (Activity activity : activityStack) { + if (activity.getClass().getSimpleName().contains("LiveAudienceActivity")) { + return activity; + } + } + return null; + } + public static class SingleApp { public static AppManager INSTANCE = new AppManager(); } @@ -58,7 +86,14 @@ public class AppManager { * 获取当前显示Activity(堆栈中最后一个传入的activity) */ public Activity getLastActivity() { + if (activityStack.isEmpty()) { + return null; + } Activity activity = activityStack.lastElement(); + if (activity == null || activity.isFinishing()) { + activityStack.remove(activity); + return getLastActivity(); + } return activity; } @@ -117,7 +152,7 @@ public class AppManager { } /** - *仅在debug下运行的代码 + * 仅在debug下运行的代码 */ public static void runDebugCode(Runnable runnable) { if (BuildConfig.DEBUG) { diff --git a/live/src/main/java/com/yunbao/live/bean/ImUserBean.java b/live/src/main/java/com/yunbao/live/bean/ImUserBean.java index d83fea755..9bc4ba7f9 100644 --- a/live/src/main/java/com/yunbao/live/bean/ImUserBean.java +++ b/live/src/main/java/com/yunbao/live/bean/ImUserBean.java @@ -2,8 +2,11 @@ package com.yunbao.live.bean; import android.text.TextUtils; +import com.alibaba.fastjson.annotation.JSONField; import com.google.gson.annotations.SerializedName; import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.WordUtil; import java.text.SimpleDateFormat; import java.util.Date; @@ -30,8 +33,21 @@ public class ImUserBean extends BaseModel { String _method_ = "";//融雲消息類型 @SerializedName("new_image") private String newImage; + @JSONField(name = "en_image") + private String newImageEn; + + public String getNewImageEn() { + return newImageEn; + } + + public void setNewImageEn(String newImageEn) { + this.newImageEn = newImageEn; + } public String getNewImage() { + if (!WordUtil.isNewZh() && !StringUtil.isEmpty(newImageEn)) { + return newImageEn; + } return newImage; } diff --git a/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java b/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java index 4a069856b..11ee058cc 100644 --- a/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java @@ -192,6 +192,8 @@ public class BattlePassRewardFragment extends BaseFragment { } if(data.getIs_received()>=2){ Bus.get().post(new BattlePassTypeEvent(1).setBean(data)); + }else{ + Bus.get().post(new BattlePassTypeEvent(2).setBean(data)); } Collection> values = data.getLive_battle_pass_rewards().values(); List> list = new ArrayList<>(values); diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml index fbc694a83..d505e8fc0 100644 --- a/main/src/main/res/values/strings.xml +++ b/main/src/main/res/values/strings.xml @@ -41,5 +41,5 @@ Today\'s feedback count has been used up Select from album Photo shoot - 一键领取 + Receive all