From bb494728177d37379da63f50180fd5f13006032d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=89=8D=E5=8D=AB?= <2298122580@qq.com> Date: Fri, 14 Jun 2024 11:33:07 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=E7=94=A8=E6=88=B7=E7=AB=AF=E6=9B=B4?= =?UTF-8?q?=E6=96=B0:=E4=BF=AE=E5=A4=8D=E5=8C=85=E8=A3=B9=E7=A4=BC?= =?UTF-8?q?=E7=89=A9=E9=80=81=E7=A4=BC=E6=95=B0=E9=87=8F=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/adapter/LiveParcelItemAdapter.java | 12 ++++++++---- .../java/com/yunbao/live/dialog/LiveGiftPopup.java | 8 +++++--- .../live/event/LiveParcelItemRefreshEvent.java | 11 +++++++++++ .../yunbao/live/views/LiveParcelItemFragment.java | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveParcelItemAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveParcelItemAdapter.java index dad11e84a..d05fb0dcb 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveParcelItemAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveParcelItemAdapter.java @@ -11,6 +11,7 @@ import com.yunbao.common.bean.LiveGiftBean; import com.yunbao.common.utils.Bus; import com.yunbao.live.R; import com.yunbao.live.event.LiveGiftItemEvent; +import com.yunbao.live.event.LiveParcelItemRefreshEvent; import com.yunbao.live.views.LiveParcelItemViewHolder; import java.util.ArrayList; @@ -56,9 +57,11 @@ public class LiveParcelItemAdapter extends RecyclerView.Adapter { notifyDataSetChanged(); } - public void refreshWrapListAfterSend(LiveGiftBean model) { + public void refreshWrapListAfterSend(LiveParcelItemRefreshEvent refreshEvent) { + LiveGiftBean liveGiftBean = refreshEvent.getLiveGiftModel(); + int sendCount = refreshEvent.getSendCount();//赠送礼物数量 for (int i = 0; i < giftJson.size(); i++) { - if (giftJson.get(i).getId() == model.getId()) { + if (giftJson.get(i).getId() == liveGiftBean.getId()) { String giftNum = giftJson.get(i).getGiftNum(); @@ -70,10 +73,11 @@ public class LiveParcelItemAdapter extends RecyclerView.Adapter { number = 0; } if (number == 1) { - + //如果礼物只剩一个,直接移除礼物 giftJson.remove(i); } else { - giftJson.get(i).setGiftNum(String.valueOf(number - 1)); + //设置送礼后的礼物数量 + giftJson.get(i).setGiftNum(String.valueOf(number - sendCount)); } } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java index f1069d325..6fc9e1a55 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java @@ -699,7 +699,8 @@ public class LiveGiftPopup extends AbsDialogFragment { } isGetNewWrap = true; if (isWrap) { - Bus.get().post(new LiveParcelItemRefreshEvent().setLiveGiftModel(liveGiftModel)); + //刷新包裹中的礼物数量 + Bus.get().post(new LiveParcelItemRefreshEvent().setLiveGiftModel(liveGiftModel).setSendCount(Integer.parseInt(mCount))); } } } else { @@ -1375,9 +1376,10 @@ public class LiveGiftPopup extends AbsDialogFragment { // //刷新包裹列表wrap_gift_num -1:表示数量没有变化 // mObjGiftSendback = obj; isGetNewWrap = true; - + //是包裹里的礼物 if (isWrap) { - Bus.get().post(new LiveParcelItemRefreshEvent().setLiveGiftModel(liveGiftModel)); + //刷新包裹中礼物的数量 + Bus.get().post(new LiveParcelItemRefreshEvent().setLiveGiftModel(liveGiftModel).setSendCount(Integer.parseInt(mCount))); } } } else if (code == 1007 && mGiftBean.getType() != 0) { diff --git a/live/src/main/java/com/yunbao/live/event/LiveParcelItemRefreshEvent.java b/live/src/main/java/com/yunbao/live/event/LiveParcelItemRefreshEvent.java index db6797e23..552397276 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveParcelItemRefreshEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveParcelItemRefreshEvent.java @@ -6,6 +6,17 @@ import com.yunbao.common.bean.LiveGiftBean; public class LiveParcelItemRefreshEvent extends BaseModel { private LiveGiftBean liveGiftModel; + private int sendCount; + + public int getSendCount() { + return sendCount; + } + + public LiveParcelItemRefreshEvent setSendCount(int sendCount) { + this.sendCount = sendCount; + return this; + } + public LiveGiftBean getLiveGiftModel() { return liveGiftModel; } diff --git a/live/src/main/java/com/yunbao/live/views/LiveParcelItemFragment.java b/live/src/main/java/com/yunbao/live/views/LiveParcelItemFragment.java index 7127f6753..0a75492bf 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveParcelItemFragment.java +++ b/live/src/main/java/com/yunbao/live/views/LiveParcelItemFragment.java @@ -77,6 +77,6 @@ public class LiveParcelItemFragment extends BaseFragment { @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveParcelItemRefreshEvent(LiveParcelItemRefreshEvent event) { - frameGiftAdapter.refreshWrapListAfterSend(event.getLiveGiftModel()); + frameGiftAdapter.refreshWrapListAfterSend(event); } }