6.7.0用户端更新:修复包裹礼物送礼数量不同步问题

This commit is contained in:
余前卫 2024-06-14 11:33:07 +08:00
parent 2cf10cc35a
commit bb49472817
4 changed files with 25 additions and 8 deletions

View File

@ -11,6 +11,7 @@ import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.event.LiveGiftItemEvent; import com.yunbao.live.event.LiveGiftItemEvent;
import com.yunbao.live.event.LiveParcelItemRefreshEvent;
import com.yunbao.live.views.LiveParcelItemViewHolder; import com.yunbao.live.views.LiveParcelItemViewHolder;
import java.util.ArrayList; import java.util.ArrayList;
@ -56,9 +57,11 @@ public class LiveParcelItemAdapter extends RecyclerView.Adapter {
notifyDataSetChanged(); 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++) { 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(); String giftNum = giftJson.get(i).getGiftNum();
@ -70,10 +73,11 @@ public class LiveParcelItemAdapter extends RecyclerView.Adapter {
number = 0; number = 0;
} }
if (number == 1) { if (number == 1) {
//如果礼物只剩一个直接移除礼物
giftJson.remove(i); giftJson.remove(i);
} else { } else {
giftJson.get(i).setGiftNum(String.valueOf(number - 1)); //设置送礼后的礼物数量
giftJson.get(i).setGiftNum(String.valueOf(number - sendCount));
} }
} }
} }

View File

@ -699,7 +699,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
} }
isGetNewWrap = true; isGetNewWrap = true;
if (isWrap) { if (isWrap) {
Bus.get().post(new LiveParcelItemRefreshEvent().setLiveGiftModel(liveGiftModel)); //刷新包裹中的礼物数量
Bus.get().post(new LiveParcelItemRefreshEvent().setLiveGiftModel(liveGiftModel).setSendCount(Integer.parseInt(mCount)));
} }
} }
} else { } else {
@ -1375,9 +1376,10 @@ public class LiveGiftPopup extends AbsDialogFragment {
// //刷新包裹列表wrap_gift_num -1:表示数量没有变化 // //刷新包裹列表wrap_gift_num -1:表示数量没有变化
// mObjGiftSendback = obj; // mObjGiftSendback = obj;
isGetNewWrap = true; isGetNewWrap = true;
//是包裹里的礼物
if (isWrap) { 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) { } else if (code == 1007 && mGiftBean.getType() != 0) {

View File

@ -6,6 +6,17 @@ import com.yunbao.common.bean.LiveGiftBean;
public class LiveParcelItemRefreshEvent extends BaseModel { public class LiveParcelItemRefreshEvent extends BaseModel {
private LiveGiftBean liveGiftModel; private LiveGiftBean liveGiftModel;
private int sendCount;
public int getSendCount() {
return sendCount;
}
public LiveParcelItemRefreshEvent setSendCount(int sendCount) {
this.sendCount = sendCount;
return this;
}
public LiveGiftBean getLiveGiftModel() { public LiveGiftBean getLiveGiftModel() {
return liveGiftModel; return liveGiftModel;
} }

View File

@ -77,6 +77,6 @@ public class LiveParcelItemFragment extends BaseFragment {
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveParcelItemRefreshEvent(LiveParcelItemRefreshEvent event) { public void onLiveParcelItemRefreshEvent(LiveParcelItemRefreshEvent event) {
frameGiftAdapter.refreshWrapListAfterSend(event.getLiveGiftModel()); frameGiftAdapter.refreshWrapListAfterSend(event);
} }
} }