diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java index f61da4be3..650a3057b 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java @@ -27,12 +27,14 @@ import com.yunbao.common.custom.MyRadioButton; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.GiftCacheUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; import com.yunbao.live.custom.GiftMarkView; import com.yunbao.live.dialog.SendRendPacketPopup; +import com.yunbao.live.event.LiveGiftDialogEvent; import java.io.File; import java.util.List; @@ -244,8 +246,9 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { ViewClicksAntiShake.clicksAntiShake(mRadioButton, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { + Bus.get().post(new LiveGiftDialogEvent()); new XPopup.Builder(mContext) - .asCustom(new SendRendPacketPopup(mContext,mLiveUid )) + .asCustom(new SendRendPacketPopup(mContext, mLiveUid)) .show(); } }); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java index d77b1514a..fd3fd30e3 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java @@ -41,7 +41,6 @@ import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.lxj.xpopup.XPopup; import com.opensource.svgaplayer.SVGACallback; import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGAImageView; @@ -81,6 +80,7 @@ import com.yunbao.live.bean.GiftTopBean; import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.custom.GiftViewPager; import com.yunbao.live.event.LiveAudienceEvent; +import com.yunbao.live.event.LiveGiftDialogEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.utils.ToolsButton; @@ -532,7 +532,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On } } mGiftList = list; - mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list,mLiveUid); + mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list, mLiveUid); mLiveGiftPagerAdapter.setActionListener(this); mViewPager.setAdapter(mLiveGiftPagerAdapter); @@ -570,7 +570,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On private void showWrapList(List list) { mWrapList = list; - mLiveWrapPagerAdapter = new LiveGiftPagerAdapter(mContext, list,mLiveUid); + mLiveWrapPagerAdapter = new LiveGiftPagerAdapter(mContext, list, mLiveUid); mLiveWrapPagerAdapter.setActionListener(this); mVPWrapList.setAdapter(mLiveWrapPagerAdapter); LayoutInflater inflater = LayoutInflater.from(mContext); @@ -1110,6 +1110,11 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLiveGiftDialogEvent(LiveGiftDialogEvent event) { + dismiss(); + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onSendBlindGiftEvent(SendBlindGiftEvent event) { if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), event.getUid())) diff --git a/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java b/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java index 6432ac392..d18ff0d1c 100644 --- a/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java @@ -24,6 +24,7 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.TimeUtils; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.CircleProgress; import com.yunbao.common.views.weight.ClipPathCircleImage; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -165,13 +166,8 @@ public class ReceiveRendPacketPopup extends CenterPopupView { @Override public void onError(String error) { - dismiss(); - new XPopup.Builder(getContext()) - .asCustom(new ResultRendPacketPopup(getContext(), - true, - null, - isSuperJackpot)) - .show(); + ToastUtil.show(error); + } }); } else { @@ -193,7 +189,7 @@ public class ReceiveRendPacketPopup extends CenterPopupView { new XPopup.Builder(getContext()) .asCustom(new ResultRendPacketPopup(getContext(), true, - null, + data.setRedPacketId(redPacketId), isSuperJackpot)) .show(); } @@ -202,13 +198,7 @@ public class ReceiveRendPacketPopup extends CenterPopupView { @Override public void onError(String error) { - dismiss(); - new XPopup.Builder(getContext()) - .asCustom(new ResultRendPacketPopup(getContext(), - true, - null, - isSuperJackpot)) - .show(); + ToastUtil.show(error); } }); } diff --git a/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java b/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java index 4a2f92528..67a2484ba 100644 --- a/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java @@ -101,13 +101,13 @@ public class ResultRendPacketPopup extends CenterPopupView { new HttpCallback>() { @Override public void onSuccess(List data) { - if (data.size() > 0) { +// if (data.size() > 0) { new XPopup.Builder(getContext()) .asCustom(new LuckUserRedPacketPopup(getContext(), data)) .show(); - } else { - ToastUtil.show(R.string.no_data); - } +// } else { +// ToastUtil.show(R.string.no_data); +// } } @@ -122,13 +122,13 @@ public class ResultRendPacketPopup extends CenterPopupView { new HttpCallback>() { @Override public void onSuccess(List data) { - if (data.size()>0){ +// if (data.size() > 0) { new XPopup.Builder(getContext()) .asCustom(new LuckUserRedPacketPopup(getContext(), data)) .show(); - }else { - ToastUtil.show(R.string.no_data); - } +// } else { +// ToastUtil.show(R.string.no_data); +// } } @@ -139,6 +139,8 @@ public class ResultRendPacketPopup extends CenterPopupView { }); } + } else { + ToastUtil.show(R.string.no_data); } } }); diff --git a/live/src/main/java/com/yunbao/live/event/LiveGiftDialogEvent.java b/live/src/main/java/com/yunbao/live/event/LiveGiftDialogEvent.java new file mode 100644 index 000000000..cd0a65171 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/event/LiveGiftDialogEvent.java @@ -0,0 +1,4 @@ +package com.yunbao.live.event; + +public class LiveGiftDialogEvent { +} 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 253e2ba9f..1a8741966 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1393,11 +1393,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } else { timeHandler.removeCallbacks(timeRunnable); StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(mRedPacketModel.getRedPacketCount()) + stringBuffer.append(mRedPacketModel.getRedPacketRemain()) .append("/") .append(mRedPacketModel.getRedPacketQuantity()); redSchedule.setText(stringBuffer.toString()); - openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketRemain() + "")); + openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + "")); redPacketCountdown.setVisibility(View.GONE); redPacketQueue.setVisibility(View.VISIBLE); } @@ -1414,7 +1414,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mCountdown = mCountdown - 1; anchorTimeHandler.postDelayed(anchorTimeRunnable, 1000); Log.e("主播倒计时", String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(mCountdown))); - } else { + } else { redPacket.setVisibility(View.GONE); anchorTimeHandler.removeCallbacks(anchorTimeRunnable); LiveNetManager.get(mContext). @@ -1450,14 +1450,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis redPacketCountdown.setText(String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(redTimeCountdown))); timeHandler.post(timeRunnable); } else { + redTimeCountdown = 0; redPacketQueue.setVisibility(View.VISIBLE); redPacketCountdown.setVisibility(View.GONE); StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(mRedPacketModel.getRedPacketCount()) + stringBuffer.append(mRedPacketModel.getRedPacketRemain()) .append("/") .append(mRedPacketModel.getRedPacketQuantity()); redSchedule.setText(stringBuffer.toString()); - openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketRemain() + "")); + openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + "")); } if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && mContext instanceof LiveRyAnchorActivity) { anchorTimeHandler.removeCallbacks(anchorTimeRunnable); @@ -1482,7 +1483,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis .show(); } else if (TextUtils.equals(data.getReceiveStatus(), "1")) { new XPopup.Builder(mContext) - .asCustom(new ResultRendPacketPopup(mContext, true, null, false)) + .asCustom(new ResultRendPacketPopup(mContext, true, data.setRedPacketId(redPacketModel.getRedPacketId()), false)) .show(); } else { new XPopup.Builder(mContext) @@ -1494,9 +1495,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void onError(String error) { ToastUtil.show(error); - new XPopup.Builder(mContext) - .asCustom(new ResultRendPacketPopup(mContext, true, null, false)) - .show(); } }); }