From ddc9bc344ed4495e68f9cd1a7b9ed571db2fe881 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 18 Mar 2024 10:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A5=9E=E9=BE=99=E9=80=81=E8=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9D=9FIm=E7=BB=93=E6=9D=9F=E8=B0=83=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E7=A5=9E=E9=BE=99=E5=88=97=E8=A1=A8=E5=80=92?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/DragonSendMoneyListAdapter.java | 4 ++ .../common/bean/SendMoneyLongModel.java | 12 ++++++ .../common/event/SendMoneyLongEndEvent.java | 6 +++ .../com/yunbao/common/http/PDLiveApi.java | 3 ++ .../common/http/live/LiveNetManager.java | 25 +++++++++++++ .../views/DragonSendMoneyListViewHolder.java | 36 +++++++++--------- .../live/activity/LiveAudienceActivity.java | 11 ++++++ .../live/activity/LiveRyAnchorActivity.java | 11 ++++++ .../live/dialog/DragonSendMoneyListPopup.java | 26 +++++++++++++ .../yunbao/live/socket/SocketRyClient.java | 8 +++- .../yunbao/live/views/LiveRoomViewHolder.java | 37 ++++++++++++++++--- .../live/views/PortraitLiveManager.java | 9 ++++- 12 files changed, 161 insertions(+), 27 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/event/SendMoneyLongEndEvent.java diff --git a/common/src/main/java/com/yunbao/common/adapter/DragonSendMoneyListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/DragonSendMoneyListAdapter.java index e96efca46..b51d454d3 100644 --- a/common/src/main/java/com/yunbao/common/adapter/DragonSendMoneyListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/DragonSendMoneyListAdapter.java @@ -26,6 +26,10 @@ public class DragonSendMoneyListAdapter extends RecyclerView.Adapter { return this; } + public List getMoneyLongListModels() { + return moneyLongListModels; + } + public DragonSendMoneyListAdapter(RecyclerView send_money_list) { this.send_money_list = send_money_list; countDownMap = new SparseArray<>(); diff --git a/common/src/main/java/com/yunbao/common/bean/SendMoneyLongModel.java b/common/src/main/java/com/yunbao/common/bean/SendMoneyLongModel.java index e823581e2..e363878eb 100644 --- a/common/src/main/java/com/yunbao/common/bean/SendMoneyLongModel.java +++ b/common/src/main/java/com/yunbao/common/bean/SendMoneyLongModel.java @@ -14,6 +14,7 @@ public class SendMoneyLongModel extends BaseModel { * "add_time": 1710318757, * "gold_num": "5000" * "countdown": 300 // 倒计时 + * "send_money_long_key": "1710384258446", * } */ @@ -35,6 +36,17 @@ public class SendMoneyLongModel extends BaseModel { private String goldNum; @SerializedName("countdown") private String countdown; + @SerializedName("send_money_long_key") + private String sendMoneyLongKey; + + public String getSendMoneyLongKey() { + return sendMoneyLongKey; + } + + public SendMoneyLongModel setSendMoneyLongKey(String sendMoneyLongKey) { + this.sendMoneyLongKey = sendMoneyLongKey; + return this; + } public String getCountdown() { return countdown; diff --git a/common/src/main/java/com/yunbao/common/event/SendMoneyLongEndEvent.java b/common/src/main/java/com/yunbao/common/event/SendMoneyLongEndEvent.java new file mode 100644 index 000000000..47b74e5d4 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/SendMoneyLongEndEvent.java @@ -0,0 +1,6 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class SendMoneyLongEndEvent extends BaseModel { +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index a10ae2ae5..518d83967 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -62,6 +62,7 @@ import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketListBean; import com.yunbao.common.bean.RoomMicStatusModel; import com.yunbao.common.bean.SearchModel; +import com.yunbao.common.bean.SendMoneyLongModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SlideInBannerModel; import com.yunbao.common.bean.StarChallengeStatusModel; @@ -1183,4 +1184,6 @@ public interface PDLiveApi { @GET("/api/public/?service=Guard.participateMoneyLong") Observable> participateMoneyLong(@Query("liveuid") String liveUid, @Query("send_money_long_key") String sendMoneyLongKey); + @GET("/api/public/?service=Guard.endSendMoneyLong") + Observable> endSendMoneyLong(@Query("liveuid") String liveUid, @Query("send_money_long_key") String sendMoneyLongKey); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index b5c93ac16..3c03572d2 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -59,6 +59,7 @@ import com.yunbao.common.bean.RedPacketGiftModel; import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketListBean; import com.yunbao.common.bean.RoomMicStatusModel; +import com.yunbao.common.bean.SendMoneyLongModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.SudGameUserModel; @@ -3054,6 +3055,30 @@ public class LiveNetManager { } + public void endSendMoneyLong(String liveUid, String sendMoneyLongKey, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .endSendMoneyLong(liveUid, sendMoneyLongKey) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel stringResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(stringResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + + } + public void sendMoneyLongList(String liveUid, HttpCallback> callback) { API.get().pdLiveApi(mContext) .sendMoneyLongList(liveUid) diff --git a/common/src/main/java/com/yunbao/common/views/DragonSendMoneyListViewHolder.java b/common/src/main/java/com/yunbao/common/views/DragonSendMoneyListViewHolder.java index 0b4475e44..0c714056d 100644 --- a/common/src/main/java/com/yunbao/common/views/DragonSendMoneyListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/DragonSendMoneyListViewHolder.java @@ -56,39 +56,39 @@ public class DragonSendMoneyListViewHolder extends RecyclerView.ViewHolder { button_participate.setBackgroundResource(R.mipmap.icon_send_benefits); } if (send_benefits_time.getVisibility() == View.VISIBLE) { - handler.removeCallbacks(runnable); +// handler.removeCallbacks(runnable); mPkTimeCount2 = Long.parseLong(model.getCountdown()); String s1 = StringUtil.getDurationText(mPkTimeCount2 * 1000); send_benefits_time.setText(s1); - handler.postDelayed(runnable, 1000); +// handler.postDelayed(runnable, 1000); } ViewClicksAntiShake.clicksAntiShake(button_participate, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { if (!isAnchor && callBack != null && TextUtils.equals("0", model.getParticipate())) { callBack.onParticipate(model); - handler.removeCallbacks(runnable); +// handler.removeCallbacks(runnable); } } }); } - Handler handler = new Handler(); - Runnable runnable = new Runnable() { - @Override - public void run() { - mPkTimeCount2--; - if (mPkTimeCount2 > 0) { - String s1 = StringUtil.getDurationText(mPkTimeCount2 * 1000); - send_benefits_time.setText(s1); - handler.postDelayed(runnable, 1000); - } else { - handler.removeCallbacks(runnable); - } - - } - }; +// Handler handler = new Handler(); +// Runnable runnable = new Runnable() { +// @Override +// public void run() { +// mPkTimeCount2--; +// if (mPkTimeCount2 > 0) { +// String s1 = StringUtil.getDurationText(mPkTimeCount2 * 1000); +// send_benefits_time.setText(s1); +// handler.postDelayed(runnable, 1000); +// } else { +// handler.removeCallbacks(runnable); +// } +// +// } +// }; public interface DragonSendMoneyListClicksCallBack { void onParticipate(sendMoneyLongListModel moneyLongListModel); 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 f16a24013..a4ee471ef 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -73,6 +73,7 @@ import com.yunbao.common.event.LiveRoomChangeEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.NewRoleCustomDrawerPopupEvent; import com.yunbao.common.event.QuickGiftingEvent; +import com.yunbao.common.event.SendMoneyLongEndEvent; import com.yunbao.common.event.ShowHideEvent; import com.yunbao.common.event.SlideEvent; import com.yunbao.common.glide.ImgLoader; @@ -1940,6 +1941,16 @@ public class LiveAudienceActivity extends LiveActivity { } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSendMoneyLongEndEvent(SendMoneyLongEndEvent sendMoneyLongModel) { + Log.e("DateRemindModel", sendMoneyLongModel.toString()); + if (manager != null) { + manager.onSendMoneyLongEndEvent(sendMoneyLongModel); + } + + } /** diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 371d4b674..e1445f947 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -55,6 +55,7 @@ import com.yunbao.common.event.GiftWallIlluminateEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.LoginInvalidEvent; import com.yunbao.common.event.SendBlindGiftEvent; +import com.yunbao.common.event.SendMoneyLongEndEvent; import com.yunbao.common.event.ShowHideEvent; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; @@ -1721,6 +1722,16 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl } } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSendMoneyLongEndEvent(SendMoneyLongEndEvent sendMoneyLongModel) { + Log.e("DateRemindModel", sendMoneyLongModel.toString()); + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.onSendMoneyLongEndEvent(sendMoneyLongModel); + } + + + } + @Subscribe(threadMode = ThreadMode.MAIN) public void GiftWallIlluminateEvent(GiftWallIlluminateEvent event) { if (mLiveRoomViewHolder != null) { diff --git a/live/src/main/java/com/yunbao/live/dialog/DragonSendMoneyListPopup.java b/live/src/main/java/com/yunbao/live/dialog/DragonSendMoneyListPopup.java index 0f7003b41..783dd31a0 100644 --- a/live/src/main/java/com/yunbao/live/dialog/DragonSendMoneyListPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/DragonSendMoneyListPopup.java @@ -7,6 +7,7 @@ import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.flyjingfish.gradienttextviewlib.GradientTextView; import com.lxj.xpopup.XPopup; import com.yunbao.common.adapter.DragonSendMoneyListAdapter; import com.yunbao.common.bean.sendMoneyLongListModel; @@ -19,6 +20,7 @@ import com.yunbao.common.views.DragonSendMoneyListViewHolder; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; +import java.util.ArrayList; import java.util.List; public class DragonSendMoneyListPopup extends AbsDialogPopupWindow { @@ -27,6 +29,7 @@ public class DragonSendMoneyListPopup extends AbsDialogPopupWindow { DragonSendMoneyListAdapter dragonSendMoneyListAdapter; RecyclerView send_money_list; boolean isAnchor; + GradientTextView title; public DragonSendMoneyListPopup(@NonNull Context context, String liveUid, boolean isAnchor) { super(context); @@ -49,6 +52,7 @@ public class DragonSendMoneyListPopup extends AbsDialogPopupWindow { protected void onCreate() { super.onCreate(); send_money_list = findViewById(R.id.send_money_list); + title = findViewById(R.id.title); send_money_list.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); dragonSendMoneyListAdapter = new DragonSendMoneyListAdapter(send_money_list); @@ -91,6 +95,8 @@ public class DragonSendMoneyListPopup extends AbsDialogPopupWindow { public void onSuccess(List data) { dragonSendMoneyListAdapter.setMoneyLongListModels(data); send_money_list.getRecycledViewPool().setMaxRecycledViews(0, data.size()); + title.removeCallbacks(refreshRunnable); + title.postDelayed(refreshRunnable, 1000); } @Override @@ -112,5 +118,25 @@ public class DragonSendMoneyListPopup extends AbsDialogPopupWindow { dismiss(); } }); + } + + Runnable refreshRunnable = new Runnable() { + @Override + public void run() { + List moneyLongListModels = dragonSendMoneyListAdapter.getMoneyLongListModels(); + List models = new ArrayList<>(); + for (sendMoneyLongListModel listModel : moneyLongListModels) { + String countdown = listModel.getCountdown(); + long countdownNumber = Long.parseLong(countdown); + countdownNumber = countdownNumber - 1; + if (countdownNumber > 0) { + listModel.setCountdown(String.valueOf(countdownNumber)); + models.add(listModel); + } + } + dragonSendMoneyListAdapter.setMoneyLongListModels(models); + title.postDelayed(refreshRunnable, 1000); + } + }; } diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 8bc7d7a82..a538671c3 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -42,6 +42,7 @@ import com.yunbao.common.event.CustomFullServiceNotifyEvent; import com.yunbao.common.event.GiftWallIlluminateEvent; import com.yunbao.common.event.QuickGiftingEvent; import com.yunbao.common.event.SendBlindGiftEvent; +import com.yunbao.common.event.SendMoneyLongEndEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.IMRTCManager; @@ -691,7 +692,7 @@ public class SocketRyClient { .setLiveReceiveGiftBean(JSON.parseObject(map.toString(), LiveReceiveGiftBean.class))); break; case "GuardSpecialEffect": - LiveReceiveGiftBean giftBean= JSON.parseObject(map.toString(), LiveReceiveGiftBean.class); + LiveReceiveGiftBean giftBean = JSON.parseObject(map.toString(), LiveReceiveGiftBean.class); giftBean.setMedal_name(map.getString("medal_name")); EventBus.getDefault().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.GuardSpecialEffect) @@ -804,9 +805,12 @@ public class SocketRyClient { Bus.get().post(maturityDateRemindModel); break; case "SendMoneyLong": - SendMoneyLongModel sendMoneyLongModel = GsonUtils.fromJson(map.toString(), SendMoneyLongModel.class); + SendMoneyLongModel sendMoneyLongModel = GsonUtils.fromJson(map.toString(), SendMoneyLongModel.class); Bus.get().post(sendMoneyLongModel); break; + case "SendMoneyLongEnd": + Bus.get().post(new SendMoneyLongEndEvent()); + break; } } 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 c42019cc4..0574d66c1 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -103,6 +103,7 @@ import com.yunbao.common.event.AnchorInfoEvent; import com.yunbao.common.event.CustomFullServiceNotifyEvent; import com.yunbao.common.event.LiveRoomChangeEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; +import com.yunbao.common.event.SendMoneyLongEndEvent; import com.yunbao.common.event.SlideEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.API; @@ -633,12 +634,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis liveReceiveGiftBean.setGiftId(liveReceiveGiftBean.getGiftName()); mLiveGiftAnimPresenter.showGifGift(liveReceiveGiftBean); -// if (TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), liveReceiveGiftBean.getUid()) -// && TextUtils.equals(liveReceiveGiftBean.getGuard_type(), "3")) { - new XPopup.Builder(mContext) - .asCustom(new DragonSendsMoneyPopup(mContext, mLiveUid)) - .show(); -// } + if (TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), liveReceiveGiftBean.getUid()) + && TextUtils.equals(liveReceiveGiftBean.getGuard_type(), "3")) { + new XPopup.Builder(mContext) + .asCustom(new DragonSendsMoneyPopup(mContext, mLiveUid)) + .show(); + } } @@ -3161,9 +3162,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + SendMoneyLongModel mSendMoneyLongModel; + public void onSendMoneyLongModel(SendMoneyLongModel sendMoneyLongModel) { if (mLiveUid.contains(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()))) { + mSendMoneyLongModel = sendMoneyLongModel; sendMoneyTime = Long.parseLong(sendMoneyLongModel.getCountdown()); participation_time.removeCallbacks(sendMoneyRunnable); dragonImmediateParticipationTime.setVisibility(View.VISIBLE); @@ -3176,6 +3180,14 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } + public void onSendMoneyLongEndEvent(SendMoneyLongEndEvent moneyLongEndEvent) { + if (mLiveUid.contains(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()))) { + dragonImmediateParticipationTime.setVisibility(View.GONE); + } else { + dragonImmediateParticipation.setVisibility(View.GONE); + } + } + private long sendMoneyTime; Runnable sendMoneyRunnable = new Runnable() { @Override @@ -3187,6 +3199,19 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis participation_time.postDelayed(sendMoneyRunnable, 1000); } else { participation_time.removeCallbacks(sendMoneyRunnable); + LiveNetManager.get(mContext) + .endSendMoneyLong(mLiveUid, mSendMoneyLongModel.getSendMoneyLongKey(), + new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(SendMoneyLongModel data) { + + } + + @Override + public void onError(String error) { + + } + }); } } }; 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 15010da59..244f71efc 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -58,6 +58,7 @@ 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.event.SendMoneyLongEndEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; @@ -763,7 +764,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } } mLiveAudienceViewHolder.upDataQuickGift(data.getQuickGiftRemainingQuantity(), data.getIfViewingDurationComplete()); - if (!TextUtils.isEmpty(data.getModel().getSendMoneyLongKey())){ + if (!TextUtils.isEmpty(data.getModel().getSendMoneyLongKey())) { mLiveRoomViewHolder.onSendMoneyLong(); } @@ -2214,4 +2215,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.onSendMoneyLongModel(sendMoneyLongModel); } } + + public void onSendMoneyLongEndEvent(SendMoneyLongEndEvent moneyLongEndEvent) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.onSendMoneyLongEndEvent(moneyLongEndEvent); + } + } }