From df93b9495aa6a22fca2ea789c62369d34626ad52 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Sat, 28 Oct 2023 17:13:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=8A=E6=88=B2bug=E4=BF=AE=E5=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/bean/CreateSudRoomModel.java | 10 +++-- .../common/dialog/CreateSudGamePopup.java | 9 ++-- .../common/dialog/SudGameListPopup.java | 9 ++-- .../dialog/SudGameSearchDialogPopup.java | 10 ++--- .../LiveSudGamePopupShowOrHideEvent.java | 26 ++++++++++++ .../yunbao/common/views/LiveSudGamePopup.java | 13 +++--- .../common/views/SudGameListViewHolder.java | 8 +--- .../live/activity/LiveAudienceActivity.java | 42 +++++++++++++++++++ .../yunbao/live/views/LiveRoomViewHolder.java | 31 +++++++------- .../live/views/PortraitLiveManager.java | 18 ++++---- 10 files changed, 118 insertions(+), 58 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/event/LiveSudGamePopupShowOrHideEvent.java diff --git a/common/src/main/java/com/yunbao/common/bean/CreateSudRoomModel.java b/common/src/main/java/com/yunbao/common/bean/CreateSudRoomModel.java index 6d53a777e..3afcad115 100644 --- a/common/src/main/java/com/yunbao/common/bean/CreateSudRoomModel.java +++ b/common/src/main/java/com/yunbao/common/bean/CreateSudRoomModel.java @@ -47,10 +47,14 @@ public class CreateSudRoomModel extends BaseModel { } public long getLongSudGameId() { - if (TextUtils.isEmpty(sudGameId)) { + try { + if (TextUtils.isEmpty(sudGameId)) { + return 0; + } else { + return Long.parseLong(sudGameId); + } + } catch (NumberFormatException e) { return 0; - } else { - return Long.parseLong(sudGameId); } } diff --git a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java index bb29c3695..c8ff09ae8 100644 --- a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java @@ -21,6 +21,7 @@ import com.yunbao.common.activity.SudGameActivity; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.event.CreateSudGameEvent; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.SudGameListDissMissEvent; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; @@ -205,12 +206,8 @@ public class CreateSudGamePopup extends BottomPopupView { intent.putExtra("CreateSudRoom", new Gson().toJson(data)); getContext().startActivity(intent); } else { - new XPopup.Builder(getContext()) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(getContext(), data)) - .show(); + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(data)); + dialog.dismiss(); Bus.get().post(new SudGameListDissMissEvent()); } diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java index 0d6b68779..7ce57a4bd 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java @@ -22,6 +22,7 @@ import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.SudGameListDissMissEvent; import com.yunbao.common.event.SudGameListEvent; @@ -161,12 +162,8 @@ public class SudGameListPopup extends BottomPopupView { @Override public void onSuccess(CreateSudRoomModel data) { if (data != null) { - new XPopup.Builder(getContext()) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(getContext(), data)) - .show(); + + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(data)); dialog.dismiss(); }else { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java index 5f0ba505b..4237c5acf 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java @@ -22,9 +22,11 @@ import com.yunbao.common.R; import com.yunbao.common.adapter.SudHomeGameListAdapter; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.SudRoomListModel; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.SudRoomListModelEvent; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.views.FlowLayout; @@ -234,12 +236,8 @@ public class SudGameSearchDialogPopup extends AbsDialogPopupWindow { createSudRoomModel.setAvatar(event.getModel().getAvatar()); createSudRoomModel.setRoomName(event.getModel().getRoomName()); createSudRoomModel.setSudGameName(event.getModel().getSudGameName()); - new XPopup.Builder(getContext()) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(getContext(), createSudRoomModel)) - .show(); + + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(createSudRoomModel)); dialog.dismiss(); } } diff --git a/common/src/main/java/com/yunbao/common/event/LiveSudGamePopupShowOrHideEvent.java b/common/src/main/java/com/yunbao/common/event/LiveSudGamePopupShowOrHideEvent.java new file mode 100644 index 000000000..2479fc6de --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/LiveSudGamePopupShowOrHideEvent.java @@ -0,0 +1,26 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.CreateSudRoomModel; + +public class LiveSudGamePopupShowOrHideEvent { + private int type = 0;//0展示,1hide隱藏,2dismiss關閉 + private CreateSudRoomModel createSudRoomModel; + + public CreateSudRoomModel getCreateSudRoomModel() { + return createSudRoomModel; + } + + public LiveSudGamePopupShowOrHideEvent setCreateSudRoomModel(CreateSudRoomModel createSudRoomModel) { + this.createSudRoomModel = createSudRoomModel; + return this; + } + + public int getType() { + return type; + } + + public LiveSudGamePopupShowOrHideEvent setType(int type) { + this.type = type; + return this; + } +} 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 7c653f465..72c05b779 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java @@ -17,6 +17,7 @@ import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CreateSudRoomModel; 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.glide.ImgLoader; import com.yunbao.common.http.base.HttpCallback; @@ -92,14 +93,14 @@ public class LiveSudGamePopup extends BottomPopupView { @Override public void onViewClicks() { gameViewModel.onDestroy(); - dialog.dismiss(); + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(2)); } }); ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.min_game), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { if (IMLoginManager.get(getContext()).getSudGameMin()) { - dialog.hide(); + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(1)); Bus.get().post(new ShowHideEvent()); } else { IMLoginManager.get(getContext()).setSudGameMin(); @@ -112,8 +113,7 @@ public class LiveSudGamePopup extends BottomPopupView { .setCallBack(new HintCustomPopup.HintCustomCallBack() { @Override public void onSure() { - - dialog.hide(); + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(1)); Bus.get().post(new ShowHideEvent()); } @@ -162,15 +162,16 @@ public class LiveSudGamePopup extends BottomPopupView { super.onDismiss(); } + @Subscribe(threadMode = ThreadMode.MAIN) public void onHideShow(HideShowEvent event) { if (event.isClose()) { - dialog.dismiss(); + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(2)); } else { if (event.isHide()) { findViewById(R.id.min_game).setVisibility(GONE); } - dialog.show(); + } } diff --git a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java index 3092a1341..11252d5eb 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java @@ -20,6 +20,7 @@ import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.event.LiveOpenSudRoomEvent; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.SudGameListDissMissEvent; import com.yunbao.common.event.SudGameListRefreshEvent; import com.yunbao.common.glide.ImgLoader; @@ -160,13 +161,8 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { } } else { - new XPopup.Builder(itemView.getContext()) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(itemView.getContext(), createSudRoomModel)) - .show(); + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(createSudRoomModel)); Bus.get().post(new SudGameListDissMissEvent()); } } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 74bf1aa8a..d3501ad08 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -69,6 +69,7 @@ import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.event.LiveErrorEvent; import com.yunbao.common.event.LiveOpenSudRoomEvent; import com.yunbao.common.event.LiveRoomChangeEvent; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.NewRoleCustomDrawerPopupEvent; import com.yunbao.common.event.ShowHideEvent; import com.yunbao.common.glide.ImgLoader; @@ -98,6 +99,7 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.CustomDrawerPopupView; import com.yunbao.common.views.HintCustomPopup; +import com.yunbao.common.views.LiveSudGamePopup; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.common.views.weight.VerticalViewPager; import com.yunbao.live.R; @@ -1710,6 +1712,46 @@ public class LiveAudienceActivity extends LiveActivity { verticalViewPager.setEnableScroll(true); } + private LiveSudGamePopup liveSudGamePopupXPopup = null; + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLiveSudGamePopupShowOrHideEvent(LiveSudGamePopupShowOrHideEvent event) { + switch (event.getType()) { + case 0: + if (liveSudGamePopupXPopup == null) { + liveSudGamePopupXPopup = new LiveSudGamePopup(mContext, event.getCreateSudRoomModel()); + new XPopup.Builder(mContext) + .enableDrag(false) + .dismissOnTouchOutside(false) + .dismissOnBackPressed(false) + .asCustom(liveSudGamePopupXPopup).show(); + }else { + if (liveSudGamePopupXPopup != null) { + liveSudGamePopupXPopup.dialog.show(); + } + } + + + + break; + + case 1: + if (liveSudGamePopupXPopup != null) { + liveSudGamePopupXPopup.dialog.hide(); + } + + break; + case 2: + if (liveSudGamePopupXPopup != null) { + liveSudGamePopupXPopup.dialog.dismiss(); + liveSudGamePopupXPopup = null; + } + break; + } + + + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveOpenSudRoomEvent(LiveOpenSudRoomEvent liveOpenSudRoomEvent) { if (manager != null) { diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 0e78bf66b..3a323f41d 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -101,6 +101,7 @@ import com.yunbao.common.event.AnchorInfoEvent; import com.yunbao.common.event.CustomFullServiceNotifyEvent; import com.yunbao.common.event.HideShowEvent; import com.yunbao.common.event.LiveRoomChangeEvent; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.API; import com.yunbao.common.http.CommonHttpConsts; @@ -669,14 +670,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis createSudRoomModel.setAvatar(sudGameDateModel.getAvatar()); createSudRoomModel.setRoomName(sudGameDateModel.getRoomName()); createSudRoomModel.setSudGameName(sudGameDateModel.getSudGameName()); - new XPopup.Builder(mContext) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(mContext, createSudRoomModel)) - .show(); - } + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(createSudRoomModel)); + } + sud_layout_name.setVisibility(View.GONE); } }); sudNameHandler.removeCallbacks(sudNameRunnable); @@ -691,15 +688,19 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private View sudGameMin; public void onShowHideEvent() { - sudGameMin = findViewById(R.id.sud_game_min); + if (sudGameMin == null) { + sudGameMin = findViewById(R.id.sud_game_min); + ViewClicksAntiShake.clicksAntiShake(sudGameMin, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0)); + sudGameMin.setVisibility(View.GONE); + } + }); + } + sudGameMin.setVisibility(View.VISIBLE); - ViewClicksAntiShake.clicksAntiShake(sudGameMin, new ViewClicksAntiShake.ViewClicksCallBack() { - @Override - public void onViewClicks() { - Bus.get().post(new HideShowEvent().setClose(false)); - sudGameMin.setVisibility(View.GONE); - } - }); + } /** diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 498c2b59c..e5c1448d6 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -26,7 +26,6 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; -import com.lxj.xpopup.XPopup; import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.permission.PermissionUtils; import com.lzf.easyfloat.utils.LifecycleUtils; @@ -56,6 +55,7 @@ import com.yunbao.common.event.HideShowEvent; import com.yunbao.common.event.LiveFloatEvent; import com.yunbao.common.event.LiveGiftDialogEvent; import com.yunbao.common.event.LiveRoomChangeEvent; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.SendBlindGiftEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; @@ -77,7 +77,6 @@ import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; -import com.yunbao.common.views.LiveSudGamePopup; import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -722,9 +721,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } else { mLiveRoomViewHolder.hindeRedPacket(); } - if (TextUtils.equals(data.getSudGameRoomStatus(), "1")) { - mLiveRoomViewHolder.setSudName(WordUtil.isNewZh() ? data.getSudGameDateModel().getSudGameName() : data.getSudGameDateModel().getSud_game_name_en(), data.getSudGameDateModel()); + if (createSudRoomModel == null) { + if (TextUtils.equals(data.getSudGameRoomStatus(), "1")) { + mLiveRoomViewHolder.setSudName(WordUtil.isNewZh() ? data.getSudGameDateModel().getSudGameName() : data.getSudGameDateModel().getSud_game_name_en(), data.getSudGameDateModel()); + } } + } @Override @@ -1137,12 +1139,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe }, 3000); } if (createSudRoomModel != null) { - new XPopup.Builder(mContext) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(mContext, createSudRoomModel)) - .show(); + + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(createSudRoomModel)); createSudRoomModel = null; } // String jsonCreateSudRoom = IMLoginManager.get(mContext).getSudGame();