创建接口,红包展示接口

This commit is contained in:
18401019693 2023-06-30 10:17:33 +08:00
parent 40455fffc9
commit e68d20252a
29 changed files with 981 additions and 118 deletions

View File

@ -179,10 +179,11 @@ public class Constants {
public static final String CUSTOM_FULL_SERVICE_NOTIFY = "customFullServiceNotify";//全服通知 public static final String CUSTOM_FULL_SERVICE_NOTIFY = "customFullServiceNotify";//全服通知
public static final String XYD_COMPLETE = "XydComplete";//心愿单完成通知 public static final String XYD_COMPLETE = "XydComplete";//心愿单完成通知
public static final String WISH_LIST_PROGRESS = "wishListProgress";//心愿单进度通知 public static final String WISH_LIST_PROGRESS = "wishListProgress";//心愿单进度通知
public static final String LIVE_VOTE_CREATE="createVote"; public static final String LIVE_VOTE_CREATE = "createVote";
public static final String LIVE_VOTE_UPDATE="updateVote"; public static final String LIVE_VOTE_UPDATE = "updateVote";
public static final String LIVE_VOTE_END="endVote"; public static final String LIVE_VOTE_END = "endVote";
public static final String LIVE_PK_END="endPK";//结束PK以这个PK获取到的参数为准 public static final String LIVE_PK_END = "endPK";//结束PK以这个PK获取到的参数为准
public static final String RED_PACKET = "RedPacket";//红包通知
//游戏socket //游戏socket
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 public static final String SOCKET_GAME_ZJH = "startGame";//炸金花

View File

@ -103,9 +103,20 @@ public class EnterRoomInfoModel extends BaseModel {
@SerializedName("anchor_goodnum") @SerializedName("anchor_goodnum")
private String anchorGoodnum; private String anchorGoodnum;
@SerializedName("jackpot_level") @SerializedName("jackpot_level")
private String jackpotLevel="-1"; private String jackpotLevel = "-1";
@SerializedName("live_vote") @SerializedName("live_vote")
private LiveRoomVoteModel voteModel; private LiveRoomVoteModel voteModel;
@SerializedName("red_packet")
private RedPacketModel redPacketModel;
public RedPacketModel getRedPacketModel() {
return redPacketModel;
}
public EnterRoomInfoModel setRedPacketModel(RedPacketModel redPacketModel) {
this.redPacketModel = redPacketModel;
return this;
}
public String getJackpotLevel() { public String getJackpotLevel() {
@ -486,8 +497,8 @@ public class EnterRoomInfoModel extends BaseModel {
} }
public String getIsconnection() { public String getIsconnection() {
if(StringUtil.isEmpty(isconnection)){ if (StringUtil.isEmpty(isconnection)) {
isconnection="0"; isconnection = "0";
} }
return isconnection; return isconnection;
} }
@ -498,8 +509,8 @@ public class EnterRoomInfoModel extends BaseModel {
} }
public String getIsleave() { public String getIsleave() {
if(StringUtil.isEmpty(isleave)){ if (StringUtil.isEmpty(isleave)) {
isleave="0"; isleave = "0";
} }
return isleave; return isleave;
} }

View File

@ -357,4 +357,8 @@ public class MsgModel extends BaseModel {
public void setSystem_bubble(String system_bubble) { public void setSystem_bubble(String system_bubble) {
this.system_bubble = system_bubble; this.system_bubble = system_bubble;
} }
/**
* 红包
*/
} }

View File

@ -0,0 +1,72 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
/**
* 红包随机礼物
*/
public class RedPacketGiftModel extends BaseModel {
/**
* {
* "id": 210,
* "giftname": "玫瑰",
* "needcoin": 20,
* "gifticon": "https://downs.yaoulive.com/603f25d9aa969.png"
* }
*/
@SerializedName("id")
private String id;
@SerializedName("giftname")
private String giftname;
@SerializedName("needcoin")
private String needcoin;
@SerializedName("gifticon")
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;
}
public String getId() {
return id;
}
public RedPacketGiftModel setId(String id) {
this.id = id;
return this;
}
public String getGiftname() {
return giftname;
}
public RedPacketGiftModel setGiftname(String giftname) {
this.giftname = giftname;
return this;
}
public String getNeedcoin() {
return "X" + needcoin;
}
public RedPacketGiftModel setNeedcoin(String needcoin) {
this.needcoin = needcoin;
return this;
}
public String getGifticon() {
return gifticon;
}
public RedPacketGiftModel setGifticon(String gifticon) {
this.gifticon = gifticon;
return this;
}
}

View File

@ -0,0 +1,212 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* 红包信息
*/
public class RedPacketInfoModel extends BaseModel {
@SerializedName("liveuid")
private String liveuid;
@SerializedName("uid")
private String uid;
@SerializedName("amount_diamond")
private String amountDiamond;
@SerializedName("red_packet_money")
private String redPacketMoney;
@SerializedName("red_packet_quantity")
private String redPacketQuantity;
@SerializedName("conditions")
private String conditions;
@SerializedName("create_time")
private String createTime;
@SerializedName("start_time")
private String startTime;
@SerializedName("end_time")
private String endTime;
@SerializedName("user_id")
private String userId;
@SerializedName("user_nicename")
private String userNicename;
@SerializedName("avatar")
private String avatar;
@SerializedName("avatar_thumb")
private String avatarThumb;
@SerializedName("id")
private String id;
@SerializedName("user_exists")
private String userExists;
@SerializedName("is_attention")
private String isAttention;
public String getIsAttention() {
return isAttention;
}
public RedPacketInfoModel setIsAttention(String isAttention) {
this.isAttention = isAttention;
return this;
}
@SerializedName("user_golden_bean")
private String userGoldenBean;
@SerializedName("red_packet_gift")
private List<RedPacketGiftModel> packetGiftModels;
public List<RedPacketGiftModel> getPacketGiftModels() {
return packetGiftModels;
}
public RedPacketInfoModel setPacketGiftModels(List<RedPacketGiftModel> packetGiftModels) {
this.packetGiftModels = packetGiftModels;
return this;
}
public String getLiveuid() {
return liveuid;
}
public RedPacketInfoModel setLiveuid(String liveuid) {
this.liveuid = liveuid;
return this;
}
public String getUid() {
return uid;
}
public RedPacketInfoModel setUid(String uid) {
this.uid = uid;
return this;
}
public String getAmountDiamond() {
return amountDiamond;
}
public RedPacketInfoModel setAmountDiamond(String amountDiamond) {
this.amountDiamond = amountDiamond;
return this;
}
public String getRedPacketMoney() {
return redPacketMoney;
}
public RedPacketInfoModel setRedPacketMoney(String redPacketMoney) {
this.redPacketMoney = redPacketMoney;
return this;
}
public String getRedPacketQuantity() {
return redPacketQuantity;
}
public RedPacketInfoModel setRedPacketQuantity(String redPacketQuantity) {
this.redPacketQuantity = redPacketQuantity;
return this;
}
public String getConditions() {
return conditions;
}
public RedPacketInfoModel setConditions(String conditions) {
this.conditions = conditions;
return this;
}
public String getCreateTime() {
return createTime;
}
public RedPacketInfoModel setCreateTime(String createTime) {
this.createTime = createTime;
return this;
}
public String getStartTime() {
return startTime;
}
public RedPacketInfoModel setStartTime(String startTime) {
this.startTime = startTime;
return this;
}
public String getEndTime() {
return endTime;
}
public RedPacketInfoModel setEndTime(String endTime) {
this.endTime = endTime;
return this;
}
public String getUserId() {
return userId;
}
public RedPacketInfoModel setUserId(String userId) {
this.userId = userId;
return this;
}
public String getUserNicename() {
return userNicename;
}
public RedPacketInfoModel setUserNicename(String userNicename) {
this.userNicename = userNicename;
return this;
}
public String getAvatar() {
return avatar;
}
public RedPacketInfoModel setAvatar(String avatar) {
this.avatar = avatar;
return this;
}
public String getAvatarThumb() {
return avatarThumb;
}
public RedPacketInfoModel setAvatarThumb(String avatarThumb) {
this.avatarThumb = avatarThumb;
return this;
}
public String getId() {
return id;
}
public RedPacketInfoModel setId(String id) {
this.id = id;
return this;
}
public String getUserExists() {
return userExists;
}
public RedPacketInfoModel setUserExists(String userExists) {
this.userExists = userExists;
return this;
}
public String getUserGoldenBean() {
return userGoldenBean;
}
public RedPacketInfoModel setUserGoldenBean(String userGoldenBean) {
this.userGoldenBean = userGoldenBean;
return this;
}
}

View File

@ -0,0 +1,90 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class RedPacketModel extends BaseModel {
//是否展示
@SerializedName("is_show")
private int isShow;
//正在进行的红包数量
@SerializedName("red_packet_count")
private int redPacketCount;
//正在进行的红包总数量
@SerializedName("red_packet_quantity")
private int redPacketQuantity;
//当前红包剩余数量
@SerializedName("red_packet_remain")
private int redPacketRemain;
//红包倒计时
@SerializedName("countdown")
private int countdown;
//红包id
@SerializedName("red_packet_id")
private String redPacketId;
//红包领取条件
@SerializedName("conditions")
private int conditions;
public int getIsShow() {
return isShow;
}
public RedPacketModel setIsShow(int isShow) {
this.isShow = isShow;
return this;
}
public int getRedPacketCount() {
return redPacketCount;
}
public RedPacketModel setRedPacketCount(int redPacketCount) {
this.redPacketCount = redPacketCount;
return this;
}
public int getRedPacketQuantity() {
return redPacketQuantity;
}
public RedPacketModel setRedPacketQuantity(int redPacketQuantity) {
this.redPacketQuantity = redPacketQuantity;
return this;
}
public int getRedPacketRemain() {
return redPacketRemain;
}
public RedPacketModel setRedPacketRemain(int redPacketRemain) {
this.redPacketRemain = redPacketRemain;
return this;
}
public int getCountdown() {
return countdown;
}
public RedPacketModel setCountdown(int countdown) {
this.countdown = countdown;
return this;
}
public String getRedPacketId() {
return redPacketId;
}
public RedPacketModel setRedPacketId(String redPacketId) {
this.redPacketId = redPacketId;
return this;
}
public int getConditions() {
return conditions;
}
public RedPacketModel setConditions(int conditions) {
this.conditions = conditions;
return this;
}
}

View File

@ -35,6 +35,7 @@ import com.yunbao.common.bean.PrankGiftBean;
import com.yunbao.common.bean.PrankHttpTurntableBean; import com.yunbao.common.bean.PrankHttpTurntableBean;
import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean; import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.RedPacketInfoModel;
import com.yunbao.common.bean.SearchModel; import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.SlideInBannerModel; import com.yunbao.common.bean.SlideInBannerModel;
@ -730,4 +731,24 @@ public interface PDLiveApi {
*/ */
@GET("/api/public/?service=Live.getBlindBoxInfo") @GET("/api/public/?service=Live.getBlindBoxInfo")
Observable<ResponseModel<List<BlindBoxInfoModel>>> getBlindBoxInfo(); Observable<ResponseModel<List<BlindBoxInfoModel>>> getBlindBoxInfo();
/**
* 获取盲盒礼物当前数据
*/
@GET("/api/public/?service=Live.createRedPacket")
Observable<ResponseModel<Object>> createRedPacket(
@Query("liveuid") String liveUid,
@Query("red_packet_money") String redPacketMoney,
@Query("red_packet_quantity") String redPacketQuantity,
@Query("conditions") String conditions
);
/**
* 获取盲盒礼物当前数据
*/
@GET("/api/public/?service=Live.redPacketInfo")
Observable<ResponseModel<RedPacketInfoModel>> redPacketInfo(
@Query("liveuid") String liveUid,
@Query("red_packet_id") String redPacketId
);
} }

View File

@ -34,6 +34,7 @@ import com.yunbao.common.bean.PrankGiftBean;
import com.yunbao.common.bean.PrankHttpTurntableBean; import com.yunbao.common.bean.PrankHttpTurntableBean;
import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean; import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.RedPacketInfoModel;
import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserAreaBean; import com.yunbao.common.bean.UserAreaBean;
@ -1550,6 +1551,58 @@ public class LiveNetManager {
}).isDisposed(); }).isDisposed();
} }
/**
* 创建红包
*
* @param liveUid 直播间id
* @param redPacketMoney 红包金额
* @param redPacketQuantity 红包数量
* @param conditions 红包领取条件 0. 1.关注主播
*/
public void createRedPacket(String liveUid, String redPacketMoney, String redPacketQuantity, String conditions, HttpCallback<String> callback) {
API.get().pdLiveApi(mContext)
.createRedPacket(liveUid, redPacketMoney, redPacketQuantity, conditions)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<Object>>() {
@Override
public void accept(ResponseModel<Object> objectResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(objectResponseModel.getData().getMsg());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
/**
* 红包信息
*
* @param liveUid 直播间id
* @param redPacketId 红包id
*/
public void redPacketInfo(String liveUid, String redPacketId, HttpCallback<RedPacketInfoModel> callback) {
API.get().pdLiveApi(mContext)
.redPacketInfo(liveUid, redPacketId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(redPacketInfoModelResponseModel -> {
if (callback != null) {
callback.onSuccess(redPacketInfoModelResponseModel.getData().getInfo());
}
}, throwable -> {
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}).isDisposed();
}
/** /**
* 直播间取消网络请求 * 直播间取消网络请求
*/ */

View File

@ -6,6 +6,7 @@ package com.yunbao.common.utils;
public class TimeUtils { public class TimeUtils {
/** /**
* 毫秒转秒 * 毫秒转秒
*
* @param duration 毫秒数 * @param duration 毫秒数
* @return * @return
*/ */
@ -17,4 +18,53 @@ public class TimeUtils {
toSecond = ((minute * 60) + second); toSecond = ((minute * 60) + second);
return toSecond; return toSecond;
} }
//根据秒数转化为时分秒 00:00:00
public static String getTime(int second) {
if (second < 10) {
return "" + second;
}
if (second < 60) {
return "" + second;
}
if (second < 3600) {
int minute = second / 60;
second = second - minute * 60;
if (minute < 10) {
if (second < 10) {
return "0" + minute + ":0" + second;
}
return "0" + minute + ":" + second;
}
if (second < 10) {
return minute + ":0" + second;
}
return minute + ":" + second;
}
int hour = second / 3600;
int minute = (second - hour * 3600) / 60;
second = second - hour * 3600 - minute * 60;
if (hour < 10) {
if (minute < 10) {
if (second < 10) {
return "0" + hour + ":0" + minute + ":0" + second;
}
return "0" + hour + ":0" + minute + ":" + second;
}
if (second < 10) {
return "0" + hour + minute + ":0" + second;
}
return "0" + hour + minute + ":" + second;
}
if (minute < 10) {
if (second < 10) {
return hour + ":0" + minute + ":0" + second;
}
return hour + ":0" + minute + ":" + second;
}
if (second < 10) {
return hour + minute + ":0" + second;
}
return hour + minute + ":" + second;
}
} }

View File

@ -1223,4 +1223,7 @@ Limited ride And limited avatar frame</string>
<string name="cred_envelope_obtained">獲得%s</string> <string name="cred_envelope_obtained">獲得%s</string>
<string name="view_lucky_viewers">查看幸運觀衆></string> <string name="view_lucky_viewers">查看幸運觀衆></string>
<string name="anchor_his_heart">贈送主播禮物表達心意</string> <string name="anchor_his_heart">贈送主播禮物表達心意</string>
<string name="red_packet_countdown">倒計時:%s</string>
<string name="open_red_packet">待開紅包:%s</string>
<string name="together_to_achieve_goal">來自%s的獎勵齊心協力連成目標</string>
</resources> </resources>

View File

@ -1382,6 +1382,11 @@ public class LiveAudienceActivity extends LiveActivity {
manager.blindBoxAllServerNotify(event.getAllServerNotifyEvent()); manager.blindBoxAllServerNotify(event.getAllServerNotifyEvent());
} }
break; break;
case RED_PACKET:
if (manager != null) {
manager.redPacketManage(event.getRedPacketModel());
}
break;
} }

View File

@ -54,15 +54,17 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
private View mAnimView; private View mAnimView;
private String mName1, mName2; private String mName1, mName2;
boolean isTouch = true; boolean isTouch = true;
private String mLiveUid;
public void setTouch(boolean touch) { public void setTouch(boolean touch) {
isTouch = touch; isTouch = touch;
} }
public LiveGiftAdapter(Context context, LayoutInflater inflater, List<LiveGiftBean> list, String coinName) { public LiveGiftAdapter(Context context, LayoutInflater inflater, List<LiveGiftBean> list, String coinName, String liveUid) {
mContext = context; mContext = context;
mInflater = inflater; mInflater = inflater;
mList = list; mList = list;
mLiveUid = liveUid;
mCoinName = coinName; mCoinName = coinName;
mName1 = CommonAppConfig.getInstance().getCoinName(); mName1 = CommonAppConfig.getInstance().getCoinName();
mName2 = CommonAppConfig.getInstance().getGoldCoinName(); mName2 = CommonAppConfig.getInstance().getGoldCoinName();
@ -243,7 +245,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
new XPopup.Builder(mContext) new XPopup.Builder(mContext)
.asCustom(new SendRendPacketPopup(mContext)) .asCustom(new SendRendPacketPopup(mContext,mLiveUid ))
.show(); .show();
} }
}); });

View File

@ -29,9 +29,10 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
private static final int GIFT_COUNT = 8;//每页8个礼物 private static final int GIFT_COUNT = 8;//每页8个礼物
private int mPage = -1; private int mPage = -1;
private ActionListener mActionListener; private ActionListener mActionListener;
private String mLiveUid;
public LiveGiftPagerAdapter(Context context, List<LiveGiftBean> giftList) { public LiveGiftPagerAdapter(Context context, List<LiveGiftBean> giftList,String liveUid) {
mContext = context; mContext = context;
mLiveUid = liveUid;
mViewList = new ArrayList<>(); mViewList = new ArrayList<>();
int fromIndex = 0; int fromIndex = 0;
int size = giftList.size(); int size = giftList.size();
@ -74,7 +75,7 @@ public class LiveGiftPagerAdapter extends PagerAdapter {
bean.setPage(i); bean.setPage(i);
list.add(bean); list.add(bean);
} }
LiveGiftAdapter adapter = new LiveGiftAdapter(mContext, inflater, list, coinName); LiveGiftAdapter adapter = new LiveGiftAdapter(mContext, inflater, list, coinName,mLiveUid);
adapter.setActionListener(actionListener); adapter.setActionListener(actionListener);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
mViewList.add(recyclerView); mViewList.add(recyclerView);

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.RedPacketGiftViewHolder;
import java.util.ArrayList;
import java.util.List;
public class RedPacketGiftAdapter 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_gift, parent, false);
return new RedPacketGiftViewHolder(redPacketGiftView);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof RedPacketGiftViewHolder) {
RedPacketGiftViewHolder redPacketGiftViewHolder = (RedPacketGiftViewHolder) 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

@ -238,7 +238,7 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene
} }
private void showGiftList(List<LiveGiftBean> list) { private void showGiftList(List<LiveGiftBean> list) {
mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list); mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list,"");
mLiveGiftPagerAdapter.setActionListener(this); mLiveGiftPagerAdapter.setActionListener(this);
mViewPager.setAdapter(mLiveGiftPagerAdapter); mViewPager.setAdapter(mLiveGiftPagerAdapter);

View File

@ -532,7 +532,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
} }
} }
mGiftList = list; mGiftList = list;
mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list); mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list,mLiveUid);
mLiveGiftPagerAdapter.setActionListener(this); mLiveGiftPagerAdapter.setActionListener(this);
mViewPager.setAdapter(mLiveGiftPagerAdapter); mViewPager.setAdapter(mLiveGiftPagerAdapter);
@ -570,7 +570,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On
private void showWrapList(List<LiveGiftBean> list) { private void showWrapList(List<LiveGiftBean> list) {
mWrapList = list; mWrapList = list;
mLiveWrapPagerAdapter = new LiveGiftPagerAdapter(mContext, list); mLiveWrapPagerAdapter = new LiveGiftPagerAdapter(mContext, list,mLiveUid);
mLiveWrapPagerAdapter.setActionListener(this); mLiveWrapPagerAdapter.setActionListener(this);
mVPWrapList.setAdapter(mLiveWrapPagerAdapter); mVPWrapList.setAdapter(mLiveWrapPagerAdapter);
LayoutInflater inflater = LayoutInflater.from(mContext); LayoutInflater inflater = LayoutInflater.from(mContext);

View File

@ -221,7 +221,7 @@ public class LiveGiftDialogFragment4Wishlist extends AbsDialogFragment implement
} }
private void showGiftList(List<LiveGiftBean> list) { private void showGiftList(List<LiveGiftBean> list) {
mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list); mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list,mLiveUid);
mLiveGiftPagerAdapter.setActionListener(this); mLiveGiftPagerAdapter.setActionListener(this);
mViewPager.setAdapter(mLiveGiftPagerAdapter); mViewPager.setAdapter(mLiveGiftPagerAdapter);
LayoutInflater inflater = LayoutInflater.from(mContext); LayoutInflater inflater = LayoutInflater.from(mContext);

View File

@ -2,27 +2,53 @@ package com.yunbao.live.dialog;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils;
import android.util.TypedValue;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup; import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.CenterPopupView; import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.RedPacketInfoModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.base.HttpCallback;
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.CircleProgress;
import com.yunbao.common.views.weight.ClipPathCircleImage;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.adapter.RedPacketGiftAdapter;
public class ReceiveRendPacketPopup extends CenterPopupView { public class ReceiveRendPacketPopup extends CenterPopupView {
private CircleProgress circleProgress; private CircleProgress circleProgress;
private int time = 10; private int time = 10;
private Button redPacketOpen; private Button redPacketOpen;
private TextView redPacketTimeText; private TextView redPacketTimeText, receiveRed, redPacketValue;
private FrameLayout redPacketTimeLayout; private FrameLayout redPacketTimeLayout;
private String mLiveUid, redPacketId, userID;
private ClipPathCircleImage headPortrait;
private RecyclerView redPacketGiftList;
private RedPacketGiftAdapter redPacketGiftAdapter;
private ImageView isAttention;
public ReceiveRendPacketPopup(@NonNull Context context, int time, String mLiveUid, String redPacketId) {
public ReceiveRendPacketPopup(@NonNull Context context) {
super(context); super(context);
this.time = time;
this.mLiveUid = mLiveUid;
this.redPacketId = redPacketId;
} }
// 返回自定义弹窗的布局离开 // 返回自定义弹窗的布局离开
@ -36,6 +62,35 @@ public class ReceiveRendPacketPopup extends CenterPopupView {
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
initView(); initView();
initData();
}
private void initData() {
LiveNetManager.get(getContext())
.redPacketInfo(mLiveUid, redPacketId, new HttpCallback<RedPacketInfoModel>() {
@Override
public void onSuccess(RedPacketInfoModel data) {
ImgLoader.displayAvatar(getContext(), data.getAvatar(), headPortrait);
receiveRed.setText(String.format(getContext()
.getString(R.string.together_to_achieve_goal),
data.getUserNicename()));
redPacketValue.setText(data.getAmountDiamond());
redPacketGiftAdapter.addData(data.getPacketGiftModels());
IMLoginModel userInfo = IMLoginManager.get(getContext()).getUserInfo();
if (TextUtils.equals(String.valueOf(userInfo.getId()), data.getUid())) {
isAttention.setVisibility(GONE);
} else {
isAttention.setVisibility(TextUtils.equals(data.getIsAttention(), "0") ? VISIBLE : GONE);
}
userID = data.getUserId();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
} }
private Handler timeHandler = new Handler(); private Handler timeHandler = new Handler();
@ -46,7 +101,13 @@ public class ReceiveRendPacketPopup extends CenterPopupView {
if (time > 0) { if (time > 0) {
circleProgress.setCurrent(time--); circleProgress.setCurrent(time--);
timeHandler.postDelayed(timeRunnable, 1000); timeHandler.postDelayed(timeRunnable, 1000);
redPacketTimeText.setText(String.valueOf(time)); String countdown = TimeUtils.getTime(time);
if (countdown.length() < 4) {
redPacketTimeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36);
} else {
redPacketTimeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 23);
}
redPacketTimeText.setText(countdown);
} else { } else {
redPacketTimeLayout.setVisibility(GONE); redPacketTimeLayout.setVisibility(GONE);
redPacketOpen.setVisibility(VISIBLE); redPacketOpen.setVisibility(VISIBLE);
@ -61,16 +122,50 @@ public class ReceiveRendPacketPopup extends CenterPopupView {
redPacketOpen = findViewById(R.id.red_packet_open); redPacketOpen = findViewById(R.id.red_packet_open);
redPacketTimeText = findViewById(R.id.red_packet_time_text); redPacketTimeText = findViewById(R.id.red_packet_time_text);
redPacketTimeLayout = findViewById(R.id.red_packet_time_layout); redPacketTimeLayout = findViewById(R.id.red_packet_time_layout);
receiveRed = findViewById(R.id.receive_red);
redPacketValue = findViewById(R.id.red_packet_value);
headPortrait = findViewById(R.id.head_portrait);
isAttention = findViewById(R.id.is_attention);
redPacketGiftList = findViewById(R.id.red_packet_gift_list);
redPacketGiftList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
redPacketGiftAdapter = new RedPacketGiftAdapter();
redPacketGiftList.setAdapter(redPacketGiftAdapter);
if (time > 0) {
circleProgress.setMax(time); circleProgress.setMax(time);
circleProgress.setCurrent(time); circleProgress.setCurrent(time);
redPacketTimeText.setText(String.valueOf(time)); String countdown = TimeUtils.getTime(time);
if (countdown.length() < 4) {
redPacketTimeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36);
} else {
redPacketTimeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 23);
}
redPacketTimeText.setText(countdown);
timeHandler.postDelayed(timeRunnable, 1000); timeHandler.postDelayed(timeRunnable, 1000);
} else {
redPacketTimeLayout.setVisibility(GONE);
redPacketOpen.setVisibility(VISIBLE);
}
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet_open), () -> { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet_open), () -> {
dismiss(); dismiss();
new XPopup.Builder(getContext()) new XPopup.Builder(getContext())
.asCustom(new ResultRendPacketPopup(getContext())) .asCustom(new ResultRendPacketPopup(getContext()))
.show(); .show();
}); });
ViewClicksAntiShake.clicksAntiShake(isAttention, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
CommonHttpUtil.setAttention(userID, new CommonCallback<Integer>() {
@Override
public void callback(Integer attention) {
if (attention == 1) {
isAttention.setVisibility(GONE);
}
}
});
}
});
} }
} }

View File

@ -7,7 +7,6 @@ import android.graphics.Color;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
@ -17,6 +16,8 @@ import androidx.annotation.NonNull;
import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.android.arouter.launcher.ARouter;
import com.lxj.xpopup.core.CenterPopupView; import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.R; import com.yunbao.live.R;
@ -27,9 +28,12 @@ public class SendRendPacketPopup extends CenterPopupView {
private TextView rill, total; private TextView rill, total;
private FrameLayout redPacketIllustrate; private FrameLayout redPacketIllustrate;
private ImageView iconInstructions, illustrateClose; private ImageView iconInstructions, illustrateClose;
private String mLiveID, conditions = "0";
public SendRendPacketPopup(@NonNull Context context) { public SendRendPacketPopup(@NonNull Context context, String liveID) {
super(context); super(context);
mLiveID = liveID;
} }
// 返回自定义弹窗的布局离开 // 返回自定义弹窗的布局离开
@ -60,10 +64,12 @@ public class SendRendPacketPopup extends CenterPopupView {
ViewClicksAntiShake.clicksAntiShake(thereIsNo, () -> { ViewClicksAntiShake.clicksAntiShake(thereIsNo, () -> {
selectText(thereIsNo, true); selectText(thereIsNo, true);
selectText(followingAnchor, false); selectText(followingAnchor, false);
conditions = "0";
}); });
ViewClicksAntiShake.clicksAntiShake(followingAnchor, () -> { ViewClicksAntiShake.clicksAntiShake(followingAnchor, () -> {
selectText(thereIsNo, false); selectText(thereIsNo, false);
selectText(followingAnchor, true); selectText(followingAnchor, true);
conditions = "1";
}); });
redEnvelopeRill.setText(String.format(getContext().getString(R.string.red_envelope_rill), "0")); redEnvelopeRill.setText(String.format(getContext().getString(R.string.red_envelope_rill), "0"));
totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), "0")); totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), "0"));
@ -121,6 +127,7 @@ public class SendRendPacketPopup extends CenterPopupView {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
rillInt = 0; rillInt = 0;
} }
if (TextUtils.isEmpty(number)) { if (TextUtils.isEmpty(number)) {
totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), "0")); totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), "0"));
} else { } else {
@ -149,6 +156,58 @@ public class SendRendPacketPopup extends CenterPopupView {
//我们的 //我们的
ARouter.getInstance().build(PATH_COIN).withInt("p", 0).navigation(); ARouter.getInstance().build(PATH_COIN).withInt("p", 0).navigation();
}); });
//创建红包
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_pack_send), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
String rillNumber = rill.getText().toString();
String number = total.getText().toString();
int rillInt = 0;
try {
rillInt = Integer.parseInt(rillNumber);
} catch (NumberFormatException e) {
rillInt = 0;
}
int totalInt = 0;
try {
totalInt = Integer.parseInt(number);
} catch (NumberFormatException e) {
totalInt = 0;
}
boolean totalTrue = false;
boolean rillTrue = false;
if (totalInt >= 1 && totalInt <= 100) {
totalTrue = true;
} else {
ToastUtil.show(String.format(getContext().getString(R.string.range_range_is), "1~100"));
}
if (rillInt >= 200 && rillInt <= 10000) {
rillTrue = true;
} else {
ToastUtil.show(String.format(getContext().getString(R.string.range_range_is), "200~10000"));
}
if (totalTrue && rillTrue) {
LiveNetManager.get(getContext())
.createRedPacket(mLiveID,
rillNumber,
number,
conditions, new HttpCallback<String>() {
@Override
public void onSuccess(String data) {
dismiss();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
}
});
} }
private void selectText(TextView textView, boolean select) { private void selectText(TextView textView, boolean select) {

View File

@ -7,6 +7,7 @@ import com.yunbao.common.bean.AnchorRecommendItemModel;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.RedPacketModel;
import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.XydCompleteModel; import com.yunbao.common.bean.XydCompleteModel;
import com.yunbao.common.event.AllServerNotifyEvent; import com.yunbao.common.event.AllServerNotifyEvent;
@ -43,6 +44,16 @@ public class LiveAudienceEvent extends BaseModel {
private XydCompleteModel xydCompleteModel; private XydCompleteModel xydCompleteModel;
private LiveReceiveGiftBean liveReceiveGiftBean; private LiveReceiveGiftBean liveReceiveGiftBean;
private AllServerNotifyEvent allServerNotifyEvent; private AllServerNotifyEvent allServerNotifyEvent;
private RedPacketModel redPacketModel;
public RedPacketModel getRedPacketModel() {
return redPacketModel;
}
public LiveAudienceEvent setRedPacketModel(RedPacketModel redPacketModel) {
this.redPacketModel = redPacketModel;
return this;
}
public AllServerNotifyEvent getAllServerNotifyEvent() { public AllServerNotifyEvent getAllServerNotifyEvent() {
return allServerNotifyEvent; return allServerNotifyEvent;
@ -356,7 +367,8 @@ public class LiveAudienceEvent extends BaseModel {
VOTE_CREATE(65, "创建投票"), VOTE_CREATE(65, "创建投票"),
VOTE_UPDATE(66, "更新投票"), VOTE_UPDATE(66, "更新投票"),
VOTE_END(67, "投票结束"), VOTE_END(67, "投票结束"),
BLIND_BOX(68, "盲盒全服通知"); BLIND_BOX(68, "盲盒全服通知"),
RED_PACKET(69, "RedPacket");
private int type; private int type;
private String name; private String name;

View File

@ -7,10 +7,8 @@ import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom;
import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot; import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@ -30,6 +28,7 @@ import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.RedPacketModel;
import com.yunbao.common.bean.SocketModel; import com.yunbao.common.bean.SocketModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.WishModel;
@ -42,7 +41,6 @@ import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager; import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
@ -69,8 +67,6 @@ import org.greenrobot.eventbus.EventBus;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.base.RTCErrorCode; import cn.rongcloud.rtc.base.RTCErrorCode;
@ -676,6 +672,7 @@ public class SocketRyClient {
); );
break; break;
case Constants.LIVE_PK_END: case Constants.LIVE_PK_END:
mListener.onEndPk(map.getLong("uid"), mListener.onEndPk(map.getLong("uid"),
map.getLong("pkuid"), map.getLong("pkuid"),
map.getLong("uid_score"), map.getLong("uid_score"),
@ -683,7 +680,12 @@ public class SocketRyClient {
JSONObject.parseObject(map.getJSONObject("ct").getJSONObject("pk_top_users").toJSONString(), LivePKUserListBean.class) JSONObject.parseObject(map.getJSONObject("ct").getJSONObject("pk_top_users").toJSONString(), LivePKUserListBean.class)
); );
break; break;
case Constants.RED_PACKET:
RedPacketModel redPacketModel = GsonUtils.fromJson(map.toString(), RedPacketModel.class);
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET)
.setRedPacketModel(redPacketModel));
break;
} }
} }

View File

@ -83,6 +83,7 @@ import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.NewPeopleTaskModel; import com.yunbao.common.bean.NewPeopleTaskModel;
import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.RankHourModel; import com.yunbao.common.bean.RankHourModel;
import com.yunbao.common.bean.RedPacketModel;
import com.yunbao.common.bean.RewardAllModel; import com.yunbao.common.bean.RewardAllModel;
import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.TaskModel; import com.yunbao.common.bean.TaskModel;
@ -113,6 +114,7 @@ import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.TimeUtils;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.utils.formatBigNum;
import com.yunbao.common.views.AbsViewHolder; import com.yunbao.common.views.AbsViewHolder;
@ -1106,54 +1108,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mChatRecyclerView.setHasFixedSize(true); mChatRecyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext); LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setOrientation(RecyclerView.VERTICAL); layoutManager.setOrientation(RecyclerView.VERTICAL);
// layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true); layoutManager.setStackFromEnd(true);
mChatRecyclerView.setLayoutManager(layoutManager); mChatRecyclerView.setLayoutManager(layoutManager);
mChatRecyclerView.addItemDecoration(new TopGradual()); mChatRecyclerView.addItemDecoration(new TopGradual());
mChatRecyclerView.setItemViewCacheSize(10); mChatRecyclerView.setItemViewCacheSize(10);
// mChatRecyclerView.setItemAnimator(new SimpleItemAnimator() {
// @Override
// public boolean animateRemove(RecyclerView.ViewHolder holder) {
// return false;
// }
//
// @Override
// public boolean animateAdd(RecyclerView.ViewHolder holder) {
// Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.live_chat_msg_in);
// holder.itemView.startAnimation(animation);
// return false;
// }
//
// @Override
// public boolean animateMove(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
// return false;
// }
//
// @Override
// public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop) {
// return false;
// }
//
// @Override
// public void runPendingAnimations() {
//
// }
//
// @Override
// public void endAnimation(@NonNull RecyclerView.ViewHolder item) {
//
// }
//
// @Override
// public void endAnimations() {
//
// }
//
// @Override
// public boolean isRunning() {
// return false;
// }
// });
mLiveChatAdapter = new LiveChatAdapter(mContext); mLiveChatAdapter = new LiveChatAdapter(mContext);
mChatRecyclerView.setAdapter(mLiveChatAdapter); mChatRecyclerView.setAdapter(mLiveChatAdapter);
mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() { mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() {
@ -1321,6 +1279,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
avatar_r1 = (RoundedImageView) findViewById(R.id.avatar_r1); avatar_r1 = (RoundedImageView) findViewById(R.id.avatar_r1);
avatar_r2 = (RoundedImageView) findViewById(R.id.avatar_r2); avatar_r2 = (RoundedImageView) findViewById(R.id.avatar_r2);
avatar_r3 = (RoundedImageView) findViewById(R.id.avatar_r3); avatar_r3 = (RoundedImageView) findViewById(R.id.avatar_r3);
redPacket = (FrameLayout) findViewById(R.id.red_packet);
redPacketCountdown = (TextView) findViewById(R.id.red_packet_countdown);
redSchedule = (TextView) findViewById(R.id.red_schedule);
redPacketQueue = (LinearLayout) findViewById(R.id.red_packet_queue);
openRedPacket = (TextView) findViewById(R.id.open_red_packet);
lt_pk_line = (RelativeLayout) findViewById(R.id.lt_pk_line); lt_pk_line = (RelativeLayout) findViewById(R.id.lt_pk_line);
clickAvatar(); clickAvatar();
@ -1409,17 +1372,71 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, liveWksLayout, "rectangle_new.png", 1); new LoadDian9TuUtil().loadDian9TuAssets2(mContext, liveWksLayout, "rectangle_new.png", 1);
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, wishListLayout2, "rectangle_new.png", 1); new LoadDian9TuUtil().loadDian9TuAssets2(mContext, wishListLayout2, "rectangle_new.png", 1);
}
private FrameLayout redPacket;
private TextView redPacketCountdown, redSchedule, openRedPacket;
private LinearLayout redPacketQueue;
private int redTimeCountdown = 0;
private RedPacketModel mRedPacketModel;
private Handler timeHandler = new Handler();
private Runnable timeRunnable = new Runnable() {
@Override
public void run() {
if (redTimeCountdown > 0) {
redTimeCountdown = redTimeCountdown - 1;
timeHandler.postDelayed(timeRunnable, 1000);
redPacketCountdown.setText(String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(redTimeCountdown)));
} else {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(mRedPacketModel.getRedPacketCount())
.append("/")
.append(mRedPacketModel.getRedPacketQuantity());
redSchedule.setText(stringBuffer.toString());
openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketRemain() + ""));
redPacketCountdown.setVisibility(View.GONE);
redPacketQueue.setVisibility(View.VISIBLE);
}
}
};
/**
* 红包相关处理
*/
public void redPacketManage(RedPacketModel redPacketModel) {
mRedPacketModel = redPacketModel;
if (redPacketModel.getIsShow() == 1) {
redPacket.setVisibility(View.VISIBLE);
if (redPacketModel.getCountdown() > 180) {
redPacketQueue.setVisibility(View.GONE);
redPacketCountdown.setVisibility(View.VISIBLE);
redTimeCountdown = redPacketModel.getCountdown() - 180;
redPacketCountdown.setText(TimeUtils.getTime(redTimeCountdown));
timeHandler.postDelayed(timeRunnable, 1000);
} else {
redPacketQueue.setVisibility(View.VISIBLE);
redPacketCountdown.setVisibility(View.GONE);
}
} else {
hindeRedPacket();
}
//测试点开红包 //测试点开红包
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet), new ViewClicksAntiShake.ViewClicksCallBack() { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
new XPopup.Builder(mContext) new XPopup.Builder(mContext)
.asCustom(new ReceiveRendPacketPopup(mContext)) .asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, redPacketModel.getRedPacketId()))
.show(); .show();
} }
}); });
} }
public void hindeRedPacket() {
redPacket.setVisibility(View.GONE);
}
/** /**
* 隐藏女神说 * 隐藏女神说
*/ */
@ -3523,6 +3540,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void showPrizePoolLevel(String level) { public void showPrizePoolLevel(String level) {
} }
/** /**
* 获取是否有热度卡加成 * 获取是否有热度卡加成
*/ */

View File

@ -39,6 +39,7 @@ import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.LiveRoomActivityModel; import com.yunbao.common.bean.LiveRoomActivityModel;
import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.RedPacketModel;
import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.WishModel; import com.yunbao.common.bean.WishModel;
@ -594,7 +595,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
} else if (!pkInfo.getString("end_pk_time").equals("0")) { } else if (!pkInfo.getString("end_pk_time").equals("0")) {
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = true; mLiveRoomViewHolder.pkHandler = true;
mLiveRoomViewHolder.pkUid=pkUid; mLiveRoomViewHolder.pkUid = pkUid;
mLiveRoomViewHolder.initPkRank(null); mLiveRoomViewHolder.initPkRank(null);
} }
if (mLivePlayViewHolder != null) { if (mLivePlayViewHolder != null) {
@ -666,6 +667,18 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_ING)); .setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_ING));
} }
if (data.getEnterRoomInfo().getRedPacketModel() != null) {
mLiveRoomViewHolder.redPacketManage(data.getEnterRoomInfo().getRedPacketModel());
// mLiveRoomViewHolder.redPacketManage(new RedPacketModel()
// .setIsShow(1)
// .setRedPacketCount(23)
// .setRedPacketQuantity(100)
// .setRedPacketRemain(6)
// .setCountdown(360));
}else {
mLiveRoomViewHolder.hindeRedPacket();
}
} }
@Override @Override
@ -2022,4 +2035,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.blindBoxAllServerNotify(event); mLiveRoomViewHolder.blindBoxAllServerNotify(event);
} }
} }
public void redPacketManage(RedPacketModel redPacket) {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.redPacketManage(redPacket);
}
}
} }

View File

@ -0,0 +1,27 @@
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 RedPacketGiftViewHolder extends RecyclerView.ViewHolder {
private ImageView giftIcon;
private TextView giftName;
public RedPacketGiftViewHolder(@NonNull View itemView) {
super(itemView);
giftIcon = itemView.findViewById(R.id.gift_icon);
giftName = itemView.findViewById(R.id.gift_name);
}
public void showData(RedPacketGiftModel redPacketGiftModel) {
ImgLoader.displayAvatar(itemView.getContext(), redPacketGiftModel.getGifticon(), giftIcon);
giftName.setText(redPacketGiftModel.getGiftNum());
}
}

View File

@ -2,8 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@mipmap/background_red_packet"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:background="@mipmap/background_red_packet"
android:backgroundTintMode="src_over"> android:backgroundTintMode="src_over">
<ImageView <ImageView
@ -21,16 +21,35 @@
android:layout_marginTop="40dp" android:layout_marginTop="40dp"
android:src="@mipmap/hide" /> android:src="@mipmap/hide" />
<TextView <ImageView
android:id="@+id/receive_red" android:id="@+id/is_attention"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_below="@id/head_portrait"
android:layout_centerHorizontal="true"
android:layout_marginTop="-17dp"
android:src="@mipmap/ixon_attention" />
<LinearLayout
android:id="@+id/receive_red_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/head_portrait" android:layout_below="@id/head_portrait"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="20dp" android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/receive_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:text="來自小PD的獎勵齊心協力連成目標" android:text="來自小PD的獎勵齊心協力連成目標"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="14sp" android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
<LinearLayout <LinearLayout
@ -56,6 +75,7 @@
android:src="@mipmap/icon_zhuansi" /> android:src="@mipmap/icon_zhuansi" />
<TextView <TextView
android:id="@+id/red_packet_value"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
@ -63,14 +83,16 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="12sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>
</LinearLayout>
<Button <Button
android:id="@+id/red_packet_open" android:id="@+id/red_packet_open"
android:layout_width="96dp" android:layout_width="96dp"
android:layout_height="96dp" android:layout_height="96dp"
android:layout_below="@+id/red_packet_value_layout" android:layout_below="@+id/head_portrait"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="12dp" android:layout_marginTop="68dp"
android:background="@drawable/background_open_red_packet" android:background="@drawable/background_open_red_packet"
android:text="@string/red_packet_open" android:text="@string/red_packet_open"
android:textColor="#FFE9BF" android:textColor="#FFE9BF"
@ -82,9 +104,9 @@
android:id="@+id/red_packet_time_layout" android:id="@+id/red_packet_time_layout"
android:layout_width="96dp" android:layout_width="96dp"
android:layout_height="96dp" android:layout_height="96dp"
android:layout_below="@+id/red_packet_value_layout" android:layout_below="@+id/head_portrait"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="12dp"> android:layout_marginTop="68dp">
<com.yunbao.common.views.weight.CircleProgress <com.yunbao.common.views.weight.CircleProgress
android:id="@+id/circleProgress" android:id="@+id/circleProgress"
@ -96,7 +118,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="0" android:text="00:00"
android:textColor="#FFFFF9" android:textColor="#FFFFF9"
android:textSize="36sp" android:textSize="36sp"
android:textStyle="bold" /> android:textStyle="bold" />
@ -112,6 +134,12 @@
android:background="@drawable/background_red_packet_list" android:background="@drawable/background_red_packet_list"
android:orientation="horizontal"> android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/red_packet_gift_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="14dp" />
</LinearLayout> </LinearLayout>
<TextView <TextView

View File

@ -15,16 +15,18 @@
app:cardElevation="0dp"> app:cardElevation="0dp">
<TextView <TextView
android:id="@+id/red_packet_countdown"
android:layout_width="58dp" android:layout_width="58dp"
android:layout_height="16dp" android:layout_height="16dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingStart="5dp" android:paddingStart="5dp"
android:text="倒計時04:59" android:text="@string/red_packet_countdown"
android:visibility="gone" android:visibility="gone"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="9sp" /> android:textSize="9sp" />
<LinearLayout <LinearLayout
android:id="@+id/red_packet_queue"
android:layout_width="68dp" android:layout_width="68dp"
android:layout_height="27dp" android:layout_height="27dp"
android:gravity="center_vertical" android:gravity="center_vertical"
@ -33,6 +35,7 @@
android:visibility="visible"> android:visibility="visible">
<TextView <TextView
android:id="@+id/red_schedule"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="10/200" android:text="10/200"
@ -40,6 +43,7 @@
android:textSize="9sp" /> android:textSize="9sp" />
<TextView <TextView
android:id="@+id/open_red_packet"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="待開紅包:4" android:text="待開紅包:4"

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageView
android:id="@+id/gift_icon"
android:layout_marginStart="14dp"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@mipmap/hide" />
<TextView
android:id="@+id/gift_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:text="dadsad"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>

View File

@ -200,6 +200,7 @@
</FrameLayout> </FrameLayout>
<TextView <TextView
android:id="@+id/red_pack_send"
android:layout_width="160dp" android:layout_width="160dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_gravity="center_horizontal|bottom" android:layout_gravity="center_horizontal|bottom"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB