红包中奖列表

This commit is contained in:
18401019693
2023-07-03 13:05:29 +08:00
parent 5736265388
commit 58508ca0ae
19 changed files with 535 additions and 43 deletions

View File

@@ -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;
}

View File

@@ -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<RedPacketGiftModel> 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<RedPacketGiftModel> list) {
if (list == null) return;
packetGiftModels.clear();
packetGiftModels.addAll(list);
notifyDataSetChanged();
}
}

View File

@@ -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<RedPacketGiftModel> packetGiftModels;
private RecyclerView userList;
private RedPacketLuckUserAdapter redPacketLuckUserAdapter;
public LuckUserRedPacketPopup(@NonNull Context context, List<RedPacketGiftModel> 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());
}
}

View File

@@ -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<RedPacketInfoModel>() {
@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<RedPacketInfoModel>() {
@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<RedPacketInfoModel>() {
@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() {

View File

@@ -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<List<RedPacketGiftModel>>() {
@Override
public void onSuccess(List<RedPacketGiftModel> 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<List<RedPacketGiftModel>>() {
@Override
public void onSuccess(List<RedPacketGiftModel> data) {
new XPopup.Builder(getContext())
.asCustom(new LuckUserRedPacketPopup(getContext(), data))
.show();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
}
}
});
}

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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);
}
}
}

View File

@@ -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());
}
}

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/gift_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dadsad"
android:textColor="@color/white"
android:textSize="16sp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end|center_vertical">
<ImageView
android:id="@+id/gift_image"
android:layout_width="20dp"
android:layout_height="20dp" />
<TextView
android:id="@+id/gift_number"
android:layout_width="30dp"
android:gravity="end"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:textColor ="@color/white"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@mipmap/background_red_packet"
android:backgroundTintMode="src_over">
<ImageView
android:id="@+id/illustrate_close"
android:layout_width="19dp"
android:layout_height="19dp"
android:layout_gravity="end"
android:layout_margin="25dp"
android:src="@mipmap/meiyan_icon_close" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="58dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/check_out_your_luck"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/user_list"
android:layout_width="200dp"
android:layout_height="241dp"
android:layout_marginTop="26dp" />
</LinearLayout>
</FrameLayout>