From 150bdba795142a2399c74f06d13dd2bea39d836d Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 26 Apr 2024 18:04:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B0=8F=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=97=B4=E5=8D=8A=E5=B1=8F=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LiveNewRoleInteractionGamesAdapter.java | 5 ++- .../common/dialog/LiveNewRolePopup.java | 1 + .../com/yunbao/common/event/SubGameEvent.java | 44 +++++++++++++++++++ .../sud/decorator/SudFSMMGDecorator.java | 1 + .../common/sud/decorator/game/JumpEvent.java | 8 +++- .../common/sud/state/SudMGPMGState.java | 1 + .../yunbao/common/views/LiveSudGamePopup.java | 18 ++++++++ .../yunbao/live/activity/SudGameActivity.java | 17 +++++++ 8 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/event/SubGameEvent.java diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveNewRoleInteractionGamesAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveNewRoleInteractionGamesAdapter.java index 38a531bce..3d17bf60e 100644 --- a/common/src/main/java/com/yunbao/common/adapter/LiveNewRoleInteractionGamesAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/LiveNewRoleInteractionGamesAdapter.java @@ -67,13 +67,14 @@ public class LiveNewRoleInteractionGamesAdapter extends RecyclerView.Adapter { public void updateData(List mChild) { child.clear(); - if (mChild.size() > 8) { + /* if (mChild.size() > 8) { for (int i = 0; i < 8; i++) { child.add(mChild.get(i)); } } else { child.addAll(mChild); - } + }*/ + child.addAll(mChild); notifyDataSetChanged(); } diff --git a/common/src/main/java/com/yunbao/common/dialog/LiveNewRolePopup.java b/common/src/main/java/com/yunbao/common/dialog/LiveNewRolePopup.java index 442bc2577..95fd1368d 100644 --- a/common/src/main/java/com/yunbao/common/dialog/LiveNewRolePopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/LiveNewRolePopup.java @@ -21,6 +21,7 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.List; +//游戏弹窗 public class LiveNewRolePopup extends BottomPopupView { private boolean showRed = false; diff --git a/common/src/main/java/com/yunbao/common/event/SubGameEvent.java b/common/src/main/java/com/yunbao/common/event/SubGameEvent.java new file mode 100644 index 000000000..d88b9f54c --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/SubGameEvent.java @@ -0,0 +1,44 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.HttpCallbackModel; + +public class SubGameEvent { + int type; + HttpCallbackModel model; + String dataJson; + + public SubGameEvent(int type, HttpCallbackModel model, String dataJson) { + this.type = type; + this.model = model; + this.dataJson = dataJson; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public HttpCallbackModel getModel() { + return model; + } + + public void setModel(HttpCallbackModel model) { + this.model = model; + } + + public String getDataJson() { + return dataJson; + } + + @Override + public String toString() { + return "SubGameEvent{" + + "type=" + type + + ", model=" + model + + ", dataJson='" + dataJson + '\'' + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java b/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java index 010d7c2f7..1bfba5b82 100644 --- a/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java +++ b/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java @@ -362,6 +362,7 @@ public class SudFSMMGDecorator implements ISudFSMMG { mgCommonGameCreateOrder.gameId = gameId; mgCommonGameCreateOrder.gameRoomId = gameRoomId; mgCommonGameCreateOrder.userId = userId; + mgCommonGameCreateOrder.dataJson = dataJson; } Log.i(TAG, "onGameStateChange: " + dataJson); diff --git a/common/src/main/java/com/yunbao/common/sud/decorator/game/JumpEvent.java b/common/src/main/java/com/yunbao/common/sud/decorator/game/JumpEvent.java index 0b5210b81..ba4a36aa9 100644 --- a/common/src/main/java/com/yunbao/common/sud/decorator/game/JumpEvent.java +++ b/common/src/main/java/com/yunbao/common/sud/decorator/game/JumpEvent.java @@ -1,10 +1,13 @@ package com.yunbao.common.sud.decorator.game; import com.yunbao.common.bean.HttpCallbackModel; +import com.yunbao.common.event.SubGameEvent; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.sud.state.SudMGPMGState; import com.yunbao.common.utils.AppManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; public class JumpEvent { private static long clickTimer = 0; @@ -35,7 +38,10 @@ public class JumpEvent { new HttpCallback() { @Override public void onSuccess(HttpCallbackModel data) { - + if (data.getCode() != 0) { + ToastUtil.show(data.getMsg()); + Bus.get().post(new SubGameEvent(0, data,order.dataJson)); + } } @Override diff --git a/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java b/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java index e8f76a0b2..dc358b332 100644 --- a/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java +++ b/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java @@ -500,6 +500,7 @@ public class SudMGPMGState implements Serializable { public long gameId; public String gameRoomId; public String userId; + public String dataJson; } /** diff --git a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java index 01776f158..e30bac901 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java @@ -2,6 +2,7 @@ package com.yunbao.common.views; import android.app.Activity; import android.content.Context; +import android.util.Log; import android.view.View; import android.widget.FrameLayout; import android.widget.TextView; @@ -9,6 +10,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.lifecycle.Observer; +import com.alibaba.fastjson.JSONObject; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BottomPopupView; import com.makeramen.roundedimageview.RoundedImageView; @@ -17,16 +19,19 @@ import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.dialog.DebugDialog; import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.event.HideShowEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.ShowHideEvent; +import com.yunbao.common.event.SubGameEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.sud.QuickStartGameViewModel; import com.yunbao.common.sud.model.GameConfigModel; +import com.yunbao.common.sud.state.SudMGPAPPState; import com.yunbao.common.sud.state.SudMGPMGState; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.ToastUtil; @@ -276,4 +281,17 @@ public class LiveSudGamePopup extends BottomPopupView { } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameStatus(SubGameEvent event) { + if (event.getType() == 0) { + DebugDialog.getInstance().setParams("游戏回调", event.getModel().getCode() + ""); + Log.i("游戏回调", "onGameStateChange: event :" + event.toString()); + if (event.getModel().getCode() == 1001 || event.getModel().getCode() == 1002) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("result", 0); + gameViewModel.sudFSTAPPDecorator.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_CREATE_ORDER_RESULT, jsonObject.toString()); + } + } + } } diff --git a/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java index 7c4122ed9..00abb5228 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java @@ -5,6 +5,7 @@ import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; @@ -15,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.alibaba.android.arouter.facade.annotation.Route; +import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.yunbao.common.Constants; @@ -32,6 +34,7 @@ import com.yunbao.common.bean.SudGameChatImModel; import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.dialog.SudGameInputPopupWindow; import com.yunbao.common.event.CheckRemainingBalanceEvent; +import com.yunbao.common.event.SubGameEvent; import com.yunbao.common.event.SudGameSocketImEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.base.HttpCallback; @@ -39,8 +42,10 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.imrongcloud.GameMicManager; import com.yunbao.common.sud.QuickStartGameViewModel; +import com.yunbao.common.sud.decorator.SudFSMMGDecorator; import com.yunbao.common.sud.model.GameConfigModel; import com.yunbao.common.sud.model.GameViewInfoModel; +import com.yunbao.common.sud.state.SudMGPAPPState; import com.yunbao.common.sud.state.SudMGPMGState; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; @@ -679,4 +684,16 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti } } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameStatus(SubGameEvent event) { + if (event.getType() == 0) { + Log.i("游戏回调", "onGameStateChange: event :" + event.toString()); + if (event.getModel().getCode() == 1001 || event.getModel().getCode() == 1002) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("result", 0); + gameViewModel.sudFSTAPPDecorator.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_CREATE_ORDER_RESULT, jsonObject.toString()); + } + } + } }