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); } }