From 58508ca0ae1161c82a6595b44011dc6d41fb446e Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 3 Jul 2023 13:05:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E5=8C=85=E4=B8=AD=E5=A5=96=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/common/Constants.java | 1 + .../common/bean/RedPacketGiftModel.java | 42 ++++++--- .../common/bean/RedPacketInfoModel.java | 37 ++++++++ .../yunbao/common/bean/RedPacketModel.java | 2 + .../com/yunbao/common/http/PDLiveApi.java | 27 +++++- .../common/http/live/LiveNetManager.java | 71 ++++++++++++++- common/src/main/res/values/strings.xml | 1 + .../live/activity/LiveAudienceActivity.java | 5 ++ .../adapter/RedPacketLuckUserAdapter.java | 51 +++++++++++ .../live/dialog/LuckUserRedPacketPopup.java | 52 +++++++++++ .../live/dialog/ReceiveRendPacketPopup.java | 89 ++++++++++++++----- .../live/dialog/ResultRendPacketPopup.java | 49 +++++++++- .../yunbao/live/event/LiveAudienceEvent.java | 14 ++- .../yunbao/live/socket/SocketRyClient.java | 7 ++ .../yunbao/live/views/LiveRoomViewHolder.java | 17 +++- .../live/views/PortraitLiveManager.java | 6 ++ .../views/RedPacketLuckUserViewHolder.java | 30 +++++++ .../res/layout/view_red_packet_luck_user.xml | 38 ++++++++ .../res/layout/view_red_packet_user_list.xml | 39 ++++++++ 19 files changed, 535 insertions(+), 43 deletions(-) create mode 100644 live/src/main/java/com/yunbao/live/adapter/RedPacketLuckUserAdapter.java create mode 100644 live/src/main/java/com/yunbao/live/dialog/LuckUserRedPacketPopup.java create mode 100644 live/src/main/java/com/yunbao/live/views/RedPacketLuckUserViewHolder.java create mode 100644 live/src/main/res/layout/view_red_packet_luck_user.xml create mode 100644 live/src/main/res/layout/view_red_packet_user_list.xml diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 0df53f2ab..95dccdaf3 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -184,6 +184,7 @@ public class Constants { public static final String LIVE_VOTE_END = "endVote"; public static final String LIVE_PK_END = "endPK";//结束PK,以这个PK获取到的参数为准 public static final String RED_PACKET = "RedPacket";//红包通知 + public static final String RED_PACKET_SUPER_JACKPOT = "RedPacketSuperJackpot";//超级红包通知 //游戏socket public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 diff --git a/common/src/main/java/com/yunbao/common/bean/RedPacketGiftModel.java b/common/src/main/java/com/yunbao/common/bean/RedPacketGiftModel.java index a0fc6f54d..88f9ffe0c 100644 --- a/common/src/main/java/com/yunbao/common/bean/RedPacketGiftModel.java +++ b/common/src/main/java/com/yunbao/common/bean/RedPacketGiftModel.java @@ -24,15 +24,10 @@ public class RedPacketGiftModel extends BaseModel { private String gifticon; @SerializedName("gift_num") private String giftNum; - - public String getGiftNum() { - return "X" +giftNum; - } - - public RedPacketGiftModel setGiftNum(String giftNum) { - this.giftNum = giftNum; - return this; - } + @SerializedName("user_nicename") + private String userNicename; + @SerializedName("avatar") + private String avatar; public String getId() { return id; @@ -53,7 +48,7 @@ public class RedPacketGiftModel extends BaseModel { } public String getNeedcoin() { - return "X" + needcoin; + return needcoin; } public RedPacketGiftModel setNeedcoin(String needcoin) { @@ -69,4 +64,31 @@ public class RedPacketGiftModel extends BaseModel { this.gifticon = gifticon; return this; } + + public String getGiftNum() { + return giftNum; + } + + public RedPacketGiftModel setGiftNum(String giftNum) { + this.giftNum = giftNum; + return this; + } + + public String getUserNicename() { + return userNicename; + } + + public RedPacketGiftModel setUserNicename(String userNicename) { + this.userNicename = userNicename; + return this; + } + + public String getAvatar() { + return avatar; + } + + public RedPacketGiftModel setAvatar(String avatar) { + this.avatar = avatar; + return this; + } } diff --git a/common/src/main/java/com/yunbao/common/bean/RedPacketInfoModel.java b/common/src/main/java/com/yunbao/common/bean/RedPacketInfoModel.java index 888a0dd6d..49c05a3de 100644 --- a/common/src/main/java/com/yunbao/common/bean/RedPacketInfoModel.java +++ b/common/src/main/java/com/yunbao/common/bean/RedPacketInfoModel.java @@ -44,6 +44,43 @@ public class RedPacketInfoModel extends BaseModel { //0.未领取到 1.领取但是没抢过东西 2.已经领抢到东西 @SerializedName("receive_status") private String receiveStatus; + //超级红包ID + @SerializedName("super_jackpot_id") + private String superJackpotId; + + public String getSuperJackpotId() { + return superJackpotId; + } + + public RedPacketInfoModel setSuperJackpotId(String superJackpotId) { + this.superJackpotId = superJackpotId; + return this; + } + + //是否超级红包 + private boolean isSuperJackpot = false; + + public boolean isSuperJackpot() { + return isSuperJackpot; + } + + //红包id + @SerializedName("red_packet_id") + private String redPacketId; + + public String getRedPacketId() { + return redPacketId; + } + + public RedPacketInfoModel setRedPacketId(String redPacketId) { + this.redPacketId = redPacketId; + return this; + } + + public RedPacketInfoModel setSuperJackpot(boolean superJackpot) { + isSuperJackpot = superJackpot; + return this; + } public String getIsAttention() { return isAttention; diff --git a/common/src/main/java/com/yunbao/common/bean/RedPacketModel.java b/common/src/main/java/com/yunbao/common/bean/RedPacketModel.java index bf36f58cc..00be4b270 100644 --- a/common/src/main/java/com/yunbao/common/bean/RedPacketModel.java +++ b/common/src/main/java/com/yunbao/common/bean/RedPacketModel.java @@ -25,6 +25,8 @@ public class RedPacketModel extends BaseModel { @SerializedName("conditions") private int conditions; + + public int getIsShow() { return isShow; } 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 27634d90a..01579edd5 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -35,6 +35,7 @@ import com.yunbao.common.bean.PrankGiftBean; import com.yunbao.common.bean.PrankHttpTurntableBean; import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RankPkInfoBean; +import com.yunbao.common.bean.RedPacketGiftModel; import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.SearchModel; import com.yunbao.common.bean.SetAttentsModel; @@ -753,7 +754,6 @@ public interface PDLiveApi { ); - /** * 获取盲盒礼物当前数据 */ @@ -763,4 +763,29 @@ public interface PDLiveApi { @Query("stream") String stream, @Query("red_packet_id") String redPacketId ); + + /** + * 超级红包打开接口 + */ + @GET("/api/public/?service=Live.getRedPacketSuperPrize") + Observable> getRedPacketSuperPrize( + @Query("liveuid") String liveUid, + @Query("super_jackpot_id") String superJackpotId + ); + + /** + * 获取普通红包的领取记录 + */ + @GET("/api/public/?service=Live.getRedPacketReceive") + Observable>> getRedPacketReceive( + @Query("red_packet_id") String redPacketId + ); + + /** + * 获取普通红包的领取记录 + */ + @GET("/api/public/?service=Live.getRedPacketSuperPrizeReceive") + Observable>> getRedPacketSuperPrizeReceive( + @Query("super_jackpot_id") String superJackpotId + ); } 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 d4311ebe7..49aebd9a5 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 @@ -34,6 +34,7 @@ import com.yunbao.common.bean.PrankGiftBean; import com.yunbao.common.bean.PrankHttpTurntableBean; import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RankPkInfoBean; +import com.yunbao.common.bean.RedPacketGiftModel; import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; @@ -1609,9 +1610,9 @@ public class LiveNetManager { * @param liveUid 直播间id * @param redPacketId 红包id */ - public void getRedPacket(String liveUid,String stream, String redPacketId, HttpCallback callback) { + public void getRedPacket(String liveUid, String stream, String redPacketId, HttpCallback callback) { API.get().pdLiveApi(mContext) - .getRedPacket(liveUid, stream,redPacketId) + .getRedPacket(liveUid, stream, redPacketId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(redPacketInfoModelResponseModel -> { @@ -1625,6 +1626,72 @@ public class LiveNetManager { }).isDisposed(); } + public void getRedPacketSuperPrize(String liveUid, String superJackpotId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getRedPacketSuperPrize(liveUid, superJackpotId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel redPacketInfoModelResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(redPacketInfoModelResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void getRedPacketReceive(String redPacketId, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getRedPacketReceive(redPacketId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void getRedPacketSuperPrizeReceive(String redPacketId, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getRedPacketSuperPrizeReceive(redPacketId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 160c4e708..35f4a3517 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1228,4 +1228,5 @@ Limited ride And limited avatar frame 來自%s的獎勵,齊心協力連成目標 很遺憾 與紅包擦肩而過 + 查看大家手氣 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 9799974ff..ad2964c33 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1387,6 +1387,11 @@ public class LiveAudienceActivity extends LiveActivity { manager.redPacketManage(event.getRedPacketModel()); } break; + case RED_PACKET_SUPER_JACKPOT: + if (manager != null) { + manager.setRedPacketInfoModel(event.getRedPacketInfoModel()); + } + break; } diff --git a/live/src/main/java/com/yunbao/live/adapter/RedPacketLuckUserAdapter.java b/live/src/main/java/com/yunbao/live/adapter/RedPacketLuckUserAdapter.java new file mode 100644 index 000000000..667b6e22a --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/RedPacketLuckUserAdapter.java @@ -0,0 +1,51 @@ +package com.yunbao.live.adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.bean.RedPacketGiftModel; +import com.yunbao.live.R; +import com.yunbao.live.views.RedPacketLuckUserViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class RedPacketLuckUserAdapter extends RecyclerView.Adapter { + private List packetGiftModels = new ArrayList<>(); + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View redPacketGiftView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_red_packet_luck_user, parent, false); + return new RedPacketLuckUserViewHolder(redPacketGiftView); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof RedPacketLuckUserViewHolder) { + RedPacketLuckUserViewHolder redPacketGiftViewHolder = (RedPacketLuckUserViewHolder) holder; + redPacketGiftViewHolder.showData(packetGiftModels.get(position)); + } + } + + @Override + public int getItemCount() { + return packetGiftModels.size(); + } + + /** + * 添加数据 + * + * @param list + */ + public void addData(List list) { + if (list == null) return; + packetGiftModels.clear(); + packetGiftModels.addAll(list); + notifyDataSetChanged(); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LuckUserRedPacketPopup.java b/live/src/main/java/com/yunbao/live/dialog/LuckUserRedPacketPopup.java new file mode 100644 index 000000000..d371f3358 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LuckUserRedPacketPopup.java @@ -0,0 +1,52 @@ +package com.yunbao.live.dialog; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.bean.RedPacketGiftModel; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; +import com.yunbao.live.adapter.RedPacketLuckUserAdapter; + +import java.util.List; + +public class LuckUserRedPacketPopup extends CenterPopupView { + + private List packetGiftModels; + private RecyclerView userList; + private RedPacketLuckUserAdapter redPacketLuckUserAdapter; + + public LuckUserRedPacketPopup(@NonNull Context context, List packetGiftModels) { + super(context); + this.packetGiftModels = packetGiftModels; + } + + // 返回自定义弹窗的布局离开 + @Override + protected int getImplLayoutId() { + return R.layout.view_red_packet_user_list; + + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + initView(); + } + + + private void initView() { + userList = findViewById(R.id.user_list); + redPacketLuckUserAdapter = new RedPacketLuckUserAdapter(); + redPacketLuckUserAdapter.addData(packetGiftModels); + userList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); + userList.setAdapter(redPacketLuckUserAdapter); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.illustrate_close), () -> dismiss()); + } + +} 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 eb774e513..1b651018b 100644 --- a/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java @@ -36,16 +36,17 @@ public class ReceiveRendPacketPopup extends CenterPopupView { private Button redPacketOpen; private TextView redPacketTimeText, receiveRed, redPacketValue; private FrameLayout redPacketTimeLayout; - private String mLiveUid,stream, redPacketId, userID; + private String mLiveUid, stream, redPacketId, userID; private ClipPathCircleImage headPortrait; private RecyclerView redPacketGiftList; private RedPacketGiftAdapter redPacketGiftAdapter; private ImageView isAttention; private RedPacketInfoModel redPacketInfoModel; + private boolean isSuperJackpot; - - public ReceiveRendPacketPopup(@NonNull Context context, int time, String mLiveUid,String stream, - String redPacketId, RedPacketInfoModel redPacketInfoModel) { + public ReceiveRendPacketPopup(@NonNull Context context, int time, String mLiveUid, String stream, + String redPacketId, RedPacketInfoModel redPacketInfoModel, + boolean isSuperJackpot) { super(context); this.time = time; @@ -53,6 +54,7 @@ public class ReceiveRendPacketPopup extends CenterPopupView { this.stream = stream; this.redPacketId = redPacketId; this.redPacketInfoModel = redPacketInfoModel; + this.isSuperJackpot = isSuperJackpot; } @@ -71,10 +73,8 @@ public class ReceiveRendPacketPopup extends CenterPopupView { } private void initData() { + ImgLoader.displayAvatar(getContext(), redPacketInfoModel.getAvatar(), headPortrait); - receiveRed.setText(String.format(getContext() - .getString(R.string.together_to_achieve_goal), - redPacketInfoModel.getUserNicename())); redPacketValue.setText(redPacketInfoModel.getAmountDiamond()); redPacketGiftAdapter.addData(redPacketInfoModel.getPacketGiftModels()); IMLoginModel userInfo = IMLoginManager.get(getContext()).getUserInfo(); @@ -83,6 +83,13 @@ public class ReceiveRendPacketPopup extends CenterPopupView { } else { isAttention.setVisibility(TextUtils.equals(redPacketInfoModel.getIsAttention(), "0") ? VISIBLE : GONE); } + if (isSuperJackpot) { + receiveRed.setText(redPacketInfoModel.getUserNicename()); + } else { + receiveRed.setText(String.format(getContext() + .getString(R.string.together_to_achieve_goal), + redPacketInfoModel.getUserNicename())); + } userID = redPacketInfoModel.getUserId(); } @@ -141,24 +148,58 @@ public class ReceiveRendPacketPopup extends CenterPopupView { } ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet_open), () -> { - LiveNetManager.get(getContext()) - .getRedPacket(mLiveUid, stream,redPacketId, new HttpCallback() { - @Override - public void onSuccess(RedPacketInfoModel data) { - dismiss(); - new XPopup.Builder(getContext()) - .asCustom(new ResultRendPacketPopup(getContext(), false, data)) - .show(); - } + if (isSuperJackpot) { + LiveNetManager.get(getContext()) + .getRedPacketSuperPrize(mLiveUid, redPacketInfoModel.getSuperJackpotId(), new HttpCallback() { + @Override + public void onSuccess(RedPacketInfoModel data) { + dismiss(); + new XPopup.Builder(getContext()) + .asCustom(new ResultRendPacketPopup(getContext(), + false, + data.setSuperJackpotId(redPacketInfoModel.getSuperJackpotId()), + isSuperJackpot)) + .show(); + } + + @Override + public void onError(String error) { + dismiss(); + new XPopup.Builder(getContext()) + .asCustom(new ResultRendPacketPopup(getContext(), + true, + null, + isSuperJackpot)) + .show(); + } + }); + } else { + LiveNetManager.get(getContext()) + .getRedPacket(mLiveUid, stream, redPacketId, new HttpCallback() { + @Override + public void onSuccess(RedPacketInfoModel data) { + dismiss(); + new XPopup.Builder(getContext()) + .asCustom(new ResultRendPacketPopup(getContext(), + false, + data.setRedPacketId(redPacketId), + isSuperJackpot)) + .show(); + } + + @Override + public void onError(String error) { + dismiss(); + new XPopup.Builder(getContext()) + .asCustom(new ResultRendPacketPopup(getContext(), + true, + null, + isSuperJackpot)) + .show(); + } + }); + } - @Override - public void onError(String error) { - dismiss(); - new XPopup.Builder(getContext()) - .asCustom(new ResultRendPacketPopup(getContext(), true, null)) - .show(); - } - }); }); ViewClicksAntiShake.clicksAntiShake(isAttention, new ViewClicksAntiShake.ViewClicksCallBack() { 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 9571efe6b..b906133e0 100644 --- a/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java @@ -7,23 +7,35 @@ import android.widget.TextView; import androidx.annotation.NonNull; +import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.bean.RedPacketGiftModel; import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; import com.yunbao.live.event.LiveAudienceEvent; +import java.util.List; + public class ResultRendPacketPopup extends CenterPopupView { private boolean noData; private RedPacketInfoModel redPacketInfoModel; + private boolean isSuperJackpot; - public ResultRendPacketPopup(@NonNull Context context, boolean noData, RedPacketInfoModel redPacketInfoModel) { + public ResultRendPacketPopup(@NonNull Context context, + boolean noData, + RedPacketInfoModel redPacketInfoModel, + boolean isSuperJackpot) { super(context); this.redPacketInfoModel = redPacketInfoModel; this.noData = noData; + this.isSuperJackpot = isSuperJackpot; } // 返回自定义弹窗的布局离开 @@ -82,7 +94,42 @@ public class ResultRendPacketPopup extends CenterPopupView { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.view_lucky_viewers), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { + if (redPacketInfoModel != null) { + if (isSuperJackpot) { + LiveNetManager.get(getContext()). + getRedPacketSuperPrizeReceive(redPacketInfoModel.getSuperJackpotId(), + new HttpCallback>() { + @Override + public void onSuccess(List data) { + new XPopup.Builder(getContext()) + .asCustom(new LuckUserRedPacketPopup(getContext(), data)) + .show(); + } + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } else { + LiveNetManager.get(getContext()). + getRedPacketReceive(redPacketInfoModel.getRedPacketId(), + new HttpCallback>() { + @Override + public void onSuccess(List data) { + new XPopup.Builder(getContext()) + .asCustom(new LuckUserRedPacketPopup(getContext(), data)) + .show(); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + + } } }); } diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index 2e2e70a13..39bf9fb48 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -7,6 +7,7 @@ import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.MsgModel; +import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketModel; import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.XydCompleteModel; @@ -45,6 +46,16 @@ public class LiveAudienceEvent extends BaseModel { private LiveReceiveGiftBean liveReceiveGiftBean; private AllServerNotifyEvent allServerNotifyEvent; private RedPacketModel redPacketModel; + private RedPacketInfoModel redPacketInfoModel; + + public RedPacketInfoModel getRedPacketInfoModel() { + return redPacketInfoModel; + } + + public LiveAudienceEvent setRedPacketInfoModel(RedPacketInfoModel redPacketInfoModel) { + this.redPacketInfoModel = redPacketInfoModel; + return this; + } public RedPacketModel getRedPacketModel() { return redPacketModel; @@ -368,7 +379,8 @@ public class LiveAudienceEvent extends BaseModel { VOTE_UPDATE(66, "更新投票"), VOTE_END(67, "投票结束"), BLIND_BOX(68, "盲盒全服通知"), - RED_PACKET(69, "RedPacket"); + RED_PACKET(69, "RedPacket"), + RED_PACKET_SUPER_JACKPOT(70, "超级红包"); private int type; private String name; 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 297a1489f..ed4747caa 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -28,6 +28,7 @@ import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.PkRankBean; +import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketModel; import com.yunbao.common.bean.SocketModel; import com.yunbao.common.bean.UserBean; @@ -686,6 +687,12 @@ public class SocketRyClient { .setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET) .setRedPacketModel(redPacketModel)); break; + case Constants.RED_PACKET_SUPER_JACKPOT: + RedPacketInfoModel redPacketInfoModel = GsonUtils.fromJson(map.toString(), RedPacketInfoModel.class); + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET_SUPER_JACKPOT) + .setRedPacketInfoModel(redPacketInfoModel)); + 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 d64e7c4fd..dcf9709de 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1391,6 +1391,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis timeHandler.postDelayed(timeRunnable, 1000); redPacketCountdown.setText(String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(redTimeCountdown))); } else { + timeHandler.removeCallbacks(timeRunnable); StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(mRedPacketModel.getRedPacketCount()) .append("/") @@ -1434,15 +1435,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void onSuccess(RedPacketInfoModel data) { if (TextUtils.equals(data.getReceiveStatus(), "0")) { new XPopup.Builder(mContext) - .asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, mStream, redPacketModel.getRedPacketId(), data)) + .asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, mStream, redPacketModel.getRedPacketId(), data, false)) .show(); } else if (TextUtils.equals(data.getReceiveStatus(), "1")) { new XPopup.Builder(mContext) - .asCustom(new ResultRendPacketPopup(mContext, true, null)) + .asCustom(new ResultRendPacketPopup(mContext, true, null, false)) .show(); } else { new XPopup.Builder(mContext) - .asCustom(new ResultRendPacketPopup(mContext, false, data)) + .asCustom(new ResultRendPacketPopup(mContext, false, data.setRedPacketId(redPacketModel.getRedPacketId()), false)) .show(); } @@ -1452,7 +1453,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void onError(String error) { ToastUtil.show(error); new XPopup.Builder(mContext) - .asCustom(new ResultRendPacketPopup(mContext, true, null)) + .asCustom(new ResultRendPacketPopup(mContext, true, null, false)) .show(); } }); @@ -1465,6 +1466,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis redPacket.setVisibility(View.GONE); } + public void setRedPacketInfoModel(RedPacketInfoModel redPacket) { + new XPopup.Builder(mContext) + .asCustom(new ReceiveRendPacketPopup(mContext, 0, mLiveUid, mStream, redPacket.getRedPacketId(), redPacket, true)) + .show(); + } + /** * 隐藏女神说 */ @@ -1560,6 +1567,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * 重置数据 */ public void resetView() { + timeHandler.removeCallbacks(timeRunnable); resetViewGone(); visibility = false; pkUidTmp = ""; @@ -3672,6 +3680,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } public void clearData() { + timeHandler.removeCallbacks(timeRunnable); LiveHttpUtil.cancel(LiveHttpConsts.GET_USER_LIST); LiveHttpUtil.cancel(LiveHttpConsts.TIME_CHARGE); CommonHttpUtil.cancel(CommonHttpConsts.SET_ATTENTION); 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 fc2f4277a..dd57d3b2a 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -39,6 +39,7 @@ import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveRoomActivityModel; import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.MsgModel; +import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.UserBean; @@ -2040,4 +2041,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.redPacketManage(redPacket); } } + public void setRedPacketInfoModel(RedPacketInfoModel redPacket) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.setRedPacketInfoModel(redPacket); + } + } } diff --git a/live/src/main/java/com/yunbao/live/views/RedPacketLuckUserViewHolder.java b/live/src/main/java/com/yunbao/live/views/RedPacketLuckUserViewHolder.java new file mode 100644 index 000000000..f5d4abd96 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/views/RedPacketLuckUserViewHolder.java @@ -0,0 +1,30 @@ +package com.yunbao.live.views; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.bean.RedPacketGiftModel; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.live.R; + +public class RedPacketLuckUserViewHolder extends RecyclerView.ViewHolder { + private ImageView giftImage; + private TextView giftName, giftNumber; + + public RedPacketLuckUserViewHolder(@NonNull View itemView) { + super(itemView); + giftImage = itemView.findViewById(R.id.gift_image); + giftName = itemView.findViewById(R.id.gift_name); + giftNumber = itemView.findViewById(R.id.gift_number); + } + + public void showData(RedPacketGiftModel redPacketGiftModel) { + ImgLoader.displayAvatar(itemView.getContext(), redPacketGiftModel.getGifticon(), giftImage); + giftName.setText(redPacketGiftModel.getUserNicename()); + giftNumber.setText(redPacketGiftModel.getGiftNum()); + } +} diff --git a/live/src/main/res/layout/view_red_packet_luck_user.xml b/live/src/main/res/layout/view_red_packet_luck_user.xml new file mode 100644 index 000000000..c153a0b5d --- /dev/null +++ b/live/src/main/res/layout/view_red_packet_luck_user.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_red_packet_user_list.xml b/live/src/main/res/layout/view_red_packet_user_list.xml new file mode 100644 index 000000000..741b95ee0 --- /dev/null +++ b/live/src/main/res/layout/view_red_packet_user_list.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + \ No newline at end of file