From cf34e73d3264f5b1cd90f22a0ac6b8adbb741efe Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 14 Mar 2024 18:21:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A5=9E=E9=BE=99=E5=88=97=E8=A1=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E6=8E=A5=EF=BC=8C=E7=A5=9E=E9=BE=99=E9=80=81?= =?UTF-8?q?=E8=B4=A2=E6=B4=BB=E5=8A=A8=E5=8F=82=E5=8A=A0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5=EF=BC=8Cui=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/DragonSendMoneyListAdapter.java | 21 ++++++- .../common/bean/SendMoneyLongModel.java | 12 ++++ .../views/DragonSendMoneyListViewHolder.java | 11 ++-- .../live/activity/LiveRyAnchorActivity.java | 9 +++ .../live/dialog/DragonSendMoneyListPopup.java | 6 +- .../yunbao/live/views/LiveRoomViewHolder.java | 55 ++++++++++++++++--- live/src/main/res/layout/view_live_room.xml | 1 + 7 files changed, 100 insertions(+), 15 deletions(-) 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 7278307bc..e96efca46 100644 --- a/common/src/main/java/com/yunbao/common/adapter/DragonSendMoneyListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/DragonSendMoneyListAdapter.java @@ -1,5 +1,7 @@ package com.yunbao.common.adapter; +import android.os.CountDownTimer; +import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -16,9 +18,17 @@ import java.util.List; public class DragonSendMoneyListAdapter extends RecyclerView.Adapter { RecyclerView send_money_list; + boolean isAnchor; + SparseArray countDownMap; + + public DragonSendMoneyListAdapter setAnchor(boolean anchor) { + isAnchor = anchor; + return this; + } public DragonSendMoneyListAdapter(RecyclerView send_money_list) { this.send_money_list = send_money_list; + countDownMap = new SparseArray<>(); } List moneyLongListModels = new ArrayList<>(); @@ -47,7 +57,16 @@ public class DragonSendMoneyListAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { DragonSendMoneyListViewHolder sendMoneyListViewHolder = (DragonSendMoneyListViewHolder) holder; - sendMoneyListViewHolder.setData(moneyLongListModels.get(position), callBack); +// sendMoneyLongListModel model = moneyLongListModels.get(position); +// long mPkTimeCount2 = Long.parseLong(model.getCountdown()); +// long time = mPkTimeCount2 * 1000; +// if (sendMoneyListViewHolder.countDownTimer != null) { +// sendMoneyListViewHolder.countDownTimer.cancel(); +// } +// if (time > 0) { +// +// } + sendMoneyListViewHolder.setData(moneyLongListModels.get(position), callBack, isAnchor); } 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 b296923e4..e823581e2 100644 --- a/common/src/main/java/com/yunbao/common/bean/SendMoneyLongModel.java +++ b/common/src/main/java/com/yunbao/common/bean/SendMoneyLongModel.java @@ -13,6 +13,7 @@ public class SendMoneyLongModel extends BaseModel { * "liveuid": "98889", * "add_time": 1710318757, * "gold_num": "5000" + * "countdown": 300 // 倒计时 * } */ @@ -32,6 +33,17 @@ public class SendMoneyLongModel extends BaseModel { private String addTime; @SerializedName("gold_num") private String goldNum; + @SerializedName("countdown") + private String countdown; + + public String getCountdown() { + return countdown; + } + + public SendMoneyLongModel setCountdown(String countdown) { + this.countdown = countdown; + return this; + } public String getMethod() { return method; 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 adbe6137b..0b4475e44 100644 --- a/common/src/main/java/com/yunbao/common/views/DragonSendMoneyListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/DragonSendMoneyListViewHolder.java @@ -1,5 +1,6 @@ package com.yunbao.common.views; +import android.os.CountDownTimer; import android.os.Handler; import android.text.TextUtils; import android.view.View; @@ -25,6 +26,7 @@ public class DragonSendMoneyListViewHolder extends RecyclerView.ViewHolder { TextView send_benefits; LinearLayout button_participate; long mPkTimeCount2; + public CountDownTimer countDownTimer; public DragonSendMoneyListViewHolder(@NonNull View itemView) { super(itemView); @@ -37,11 +39,12 @@ public class DragonSendMoneyListViewHolder extends RecyclerView.ViewHolder { send_benefits = itemView.findViewById(R.id.send_benefits); } - public void setData(sendMoneyLongListModel model, DragonSendMoneyListClicksCallBack callBack) { + public void setData(sendMoneyLongListModel model, DragonSendMoneyListClicksCallBack callBack,boolean isAnchor) { ImgLoader.display(itemView.getContext(), model.getUserAvatar(), live_avatar); user_nicename.setText(String.valueOf(model.getUserNicename())); gold_num.setText(String.valueOf(model.getGoldNum())); - if (TextUtils.equals("0", model.getParticipate())) { + + if (TextUtils.equals("0", model.getParticipate()) && !isAnchor) { participate.setVisibility(View.VISIBLE); send_benefits_time.setVisibility(View.GONE); send_benefits.setVisibility(View.GONE); @@ -54,15 +57,15 @@ public class DragonSendMoneyListViewHolder extends RecyclerView.ViewHolder { } if (send_benefits_time.getVisibility() == View.VISIBLE) { handler.removeCallbacks(runnable); + mPkTimeCount2 = Long.parseLong(model.getCountdown()); String s1 = StringUtil.getDurationText(mPkTimeCount2 * 1000); send_benefits_time.setText(s1); - mPkTimeCount2 = Long.parseLong(model.getCountdown()); handler.postDelayed(runnable, 1000); } ViewClicksAntiShake.clicksAntiShake(button_participate, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - if (callBack != null && TextUtils.equals("0", model.getParticipate())) { + if (!isAnchor && callBack != null && TextUtils.equals("0", model.getParticipate())) { callBack.onParticipate(model); handler.removeCallbacks(runnable); } 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 52545097d..371d4b674 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -48,6 +48,7 @@ import com.yunbao.common.bean.LiveAiRobotBean; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.MicUserBean; +import com.yunbao.common.bean.SendMoneyLongModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.NotCancelableDialog; import com.yunbao.common.event.GiftWallIlluminateEvent; @@ -1709,6 +1710,14 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl liveInputDialogFragment.setArguments(liveInputBundle); liveInputDialogFragment.show(getSupportFragmentManager(), "LiveInputDialogFragment"); break; + + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSendMoneyLongModel(SendMoneyLongModel sendMoneyLongModel) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.onSendMoneyLongModel(sendMoneyLongModel); } } 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 40bcf57fa..0f7003b41 100644 --- a/live/src/main/java/com/yunbao/live/dialog/DragonSendMoneyListPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/DragonSendMoneyListPopup.java @@ -26,11 +26,13 @@ public class DragonSendMoneyListPopup extends AbsDialogPopupWindow { String mLiveUid; DragonSendMoneyListAdapter dragonSendMoneyListAdapter; RecyclerView send_money_list; + boolean isAnchor; - public DragonSendMoneyListPopup(@NonNull Context context, String liveUid) { + public DragonSendMoneyListPopup(@NonNull Context context, String liveUid, boolean isAnchor) { super(context); activity = (FragmentActivity) context; mLiveUid = liveUid; + this.isAnchor = isAnchor; } @Override @@ -52,7 +54,7 @@ public class DragonSendMoneyListPopup extends AbsDialogPopupWindow { dragonSendMoneyListAdapter = new DragonSendMoneyListAdapter(send_money_list); send_money_list.setAdapter(dragonSendMoneyListAdapter); - + dragonSendMoneyListAdapter.setAnchor(isAnchor); dragonSendMoneyListAdapter.setCallBack(new DragonSendMoneyListViewHolder.DragonSendMoneyListClicksCallBack() { @Override public void onParticipate(sendMoneyLongListModel moneyLongListModel) { 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 ff55970d7..c42019cc4 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -165,7 +165,6 @@ import com.yunbao.live.custom.RightGradual; import com.yunbao.live.dialog.DragonSendMoneyListPopup; import com.yunbao.live.dialog.DragonSendsMoneyPopup; import com.yunbao.live.dialog.GiftWallDialog; -import com.yunbao.live.dialog.GuardUpgradePopup; import com.yunbao.live.dialog.LiveContactDetailsSendGiftDialog; import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; @@ -636,9 +635,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis // 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(); + new XPopup.Builder(mContext) + .asCustom(new DragonSendsMoneyPopup(mContext, mLiveUid)) + .show(); // } } @@ -1594,10 +1593,21 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis combo_layout.setVisibility(View.GONE); dragonImmediateParticipation = (LinearLayout) findViewById(R.id.dragon_immediate_participation); + dragonImmediateParticipationTime = (LinearLayout) findViewById(R.id.dragon_immediate_participation_time); + participation_time = (TextView) findViewById(R.id.participation_time); ViewClicksAntiShake.clicksAntiShake(dragonImmediateParticipation, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - new DragonSendMoneyListPopup(mContext, mLiveUid).showDialog(); + new DragonSendMoneyListPopup(mContext, mLiveUid, false).showDialog(); +// new XPopup.Builder(mContext) +// .asCustom(new GuardUpgradePopup(mContext, mLiveUid)) +// .show(); + } + }); + ViewClicksAntiShake.clicksAntiShake(dragonImmediateParticipationTime, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new DragonSendMoneyListPopup(mContext, mLiveUid, true).showDialog(); // new XPopup.Builder(mContext) // .asCustom(new GuardUpgradePopup(mContext, mLiveUid)) // .show(); @@ -1606,9 +1616,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis // dragonImmediateParticipation.setVisibility(View.GONE); } - private LinearLayout dragonImmediateParticipation; + private LinearLayout dragonImmediateParticipation, dragonImmediateParticipationTime; private FrameLayout redPacket; - private TextView redPacketCountdown, redSchedule, openRedPacket; + private TextView redPacketCountdown, redSchedule, openRedPacket, participation_time; private LinearLayout redPacketQueue; private int redTimeCountdown = 0; private RedPacketModel mRedPacketModel; @@ -3150,12 +3160,41 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis gift_svga.setVisibility(View.VISIBLE); } } + public void onSendMoneyLongModel(SendMoneyLongModel sendMoneyLongModel) { - dragonImmediateParticipation.setVisibility(View.VISIBLE); + + if (mLiveUid.contains(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()))) { + sendMoneyTime = Long.parseLong(sendMoneyLongModel.getCountdown()); + participation_time.removeCallbacks(sendMoneyRunnable); + dragonImmediateParticipationTime.setVisibility(View.VISIBLE); + String s1 = StringUtil.getDurationText(sendMoneyTime * 1000); + participation_time.setText(s1); + participation_time.post(sendMoneyRunnable); + } else { + dragonImmediateParticipation.setVisibility(View.VISIBLE); + } + } + + private long sendMoneyTime; + Runnable sendMoneyRunnable = new Runnable() { + @Override + public void run() { + sendMoneyTime--; + if (sendMoneyTime > 0) { + String s1 = StringUtil.getDurationText(sendMoneyTime * 1000); + participation_time.setText(s1); + participation_time.postDelayed(sendMoneyRunnable, 1000); + } else { + participation_time.removeCallbacks(sendMoneyRunnable); + } + } + }; + public void onSendMoneyLong() { dragonImmediateParticipation.setVisibility(View.VISIBLE); } + /** * 设置礼物墙和周星榜 */ diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 624c49422..cfde902a8 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -2589,6 +2589,7 @@ android:src="@mipmap/icon_live_dragon_money" />