1:红包功能完成
This commit is contained in:
10
app/proguard-rules.pro
vendored
10
app/proguard-rules.pro
vendored
@@ -927,6 +927,16 @@ public static java.lang.String TABLENAME;
|
|||||||
*;
|
*;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-keep class com.xscm.moduleutil.bean.RedBean** {*;}
|
||||||
|
-keepclassmembers class com.xscm.moduleutil.bean.RedBean** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class com.xscm.moduleutil.bean.HourlyBean** {*;}
|
||||||
|
-keepclassmembers class com.xscm.moduleutil.bean.HourlyBean** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
# 保持EventBus相关类不被混淆
|
# 保持EventBus相关类不被混淆
|
||||||
-keepclassmembers class * {
|
-keepclassmembers class * {
|
||||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -57,6 +58,7 @@ import com.xscm.moduleutil.base.RoomManager;
|
|||||||
import com.xscm.moduleutil.bean.XLHBean;
|
import com.xscm.moduleutil.bean.XLHBean;
|
||||||
import com.xscm.moduleutil.event.HourlyBean;
|
import com.xscm.moduleutil.event.HourlyBean;
|
||||||
import com.xscm.moduleutil.event.MqttBean;
|
import com.xscm.moduleutil.event.MqttBean;
|
||||||
|
import com.xscm.moduleutil.event.RedBean;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.utils.BackgroundManager;
|
import com.xscm.moduleutil.utils.BackgroundManager;
|
||||||
import com.xscm.moduleutil.utils.ColorManager;
|
import com.xscm.moduleutil.utils.ColorManager;
|
||||||
@@ -446,12 +448,16 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
// 在类中添加以下成员变量
|
// 在类中添加以下成员变量
|
||||||
private final List<MqttBean.ListBean> mqttMessageQueue = new ArrayList<>(); // MQTT消息队列
|
private final List<MqttBean.ListBean> mqttMessageQueue = new ArrayList<>(); // MQTT消息队列
|
||||||
private final List<XLHBean> xlhMessageQueue = new ArrayList<>(); // XLH消息队列
|
private final List<XLHBean> xlhMessageQueue = new ArrayList<>(); // XLH消息队列
|
||||||
|
private final List<RedBean> redMessageQueue = new ArrayList<>(); // 红包队列
|
||||||
private boolean isMqttPlaying = false; // MQTT播放状态标志
|
private boolean isMqttPlaying = false; // MQTT播放状态标志
|
||||||
private boolean isXlhPlaying = false; // XLH播放状态标志
|
private boolean isXlhPlaying = false; // XLH播放状态标志
|
||||||
|
private boolean isRedPlaying = false; // XLH播放状态标志
|
||||||
private final Object mqttQueueLock = new Object(); // MQTT队列同步锁
|
private final Object mqttQueueLock = new Object(); // MQTT队列同步锁
|
||||||
private final Object xlhQueueLock = new Object(); // XLH队列同步锁
|
private final Object xlhQueueLock = new Object(); // XLH队列同步锁
|
||||||
|
private final Object RedQueueLock = new Object(); // XLH队列同步锁
|
||||||
private View currentMqttView = null; // 当前正在播放的MQTT视图
|
private View currentMqttView = null; // 当前正在播放的MQTT视图
|
||||||
private View currentXlhView = null; // 当前正在播放的XLH视图
|
private View currentXlhView = null; // 当前正在播放的XLH视图
|
||||||
|
private View currentRedView = null; // 当前正在播放的XLH视图
|
||||||
|
|
||||||
private final List<HourlyBean> hourlyMessageQueue = new ArrayList<>(); // 小时榜消息队列
|
private final List<HourlyBean> hourlyMessageQueue = new ArrayList<>(); // 小时榜消息队列
|
||||||
private final Map<Integer, View> currentHourlyViews = new HashMap<>(); // 当前显示的小时榜视图
|
private final Map<Integer, View> currentHourlyViews = new HashMap<>(); // 当前显示的小时榜视图
|
||||||
@@ -711,6 +717,166 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onEvent(RedBean event){
|
||||||
|
LogUtils.e("收到红包", event);
|
||||||
|
if (event==null) return;
|
||||||
|
if (SpUtil.getFloatingScreen()==1){
|
||||||
|
|
||||||
|
synchronized (RedQueueLock) {
|
||||||
|
redMessageQueue.add(event);
|
||||||
|
if (!isRedPlaying) {
|
||||||
|
isRedPlaying = true;
|
||||||
|
processNextRedMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
redMessageQueue.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processNextRedMessage() {
|
||||||
|
RedBean redBean;
|
||||||
|
synchronized (RedQueueLock) {
|
||||||
|
if (redMessageQueue.isEmpty()) {
|
||||||
|
isRedPlaying = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
redBean = redMessageQueue.remove(0);
|
||||||
|
}
|
||||||
|
showPiaoPingMessageRed(redBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPiaoPingMessageRed(RedBean redBean){
|
||||||
|
try {
|
||||||
|
// 清理之前的视图(如果存在)
|
||||||
|
if (currentRedView != null && currentRedView.getParent() != null) {
|
||||||
|
ViewGroup parent = (ViewGroup) currentRedView.getParent();
|
||||||
|
parent.removeView(currentRedView);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decorView2 == null) {
|
||||||
|
decorView2 = (ViewGroup) getWindow().getDecorView();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentRedView = LayoutInflater.from(this).inflate(R.layout.item_piaoping_red, null);
|
||||||
|
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||||
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 140);
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
||||||
|
currentRedView.setLayoutParams(layoutParams);
|
||||||
|
decorView2.addView(currentRedView);
|
||||||
|
|
||||||
|
updateRedFloatingViewData(currentRedView, redBean);
|
||||||
|
// 播放红包音效
|
||||||
|
playRedPacketSound();
|
||||||
|
resetAndStartXlhAnimation(currentRedView, () -> {
|
||||||
|
// 清理当前视图
|
||||||
|
if (currentRedView != null && currentRedView.getParent() != null) {
|
||||||
|
ViewGroup parent = (ViewGroup) currentRedView.getParent();
|
||||||
|
parent.removeView(currentRedView);
|
||||||
|
}
|
||||||
|
currentRedView = null;
|
||||||
|
|
||||||
|
// 处理队列中的下一条消息
|
||||||
|
synchronized (RedQueueLock) {
|
||||||
|
isRedPlaying = false;
|
||||||
|
processNextRedMessage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("显示红包飘屏失败", e);
|
||||||
|
// 出现异常时继续处理队列
|
||||||
|
synchronized (RedQueueLock) {
|
||||||
|
isRedPlaying = false;
|
||||||
|
processNextRedMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 在类中添加成员变量
|
||||||
|
private MediaPlayer redPacketMediaPlayer = null;
|
||||||
|
private boolean isRedPacketMediaPrepared = false;
|
||||||
|
// 添加播放红包音效的方法
|
||||||
|
private void playRedPacketSound() {
|
||||||
|
try {
|
||||||
|
if (!isRedPacketMediaPrepared) {
|
||||||
|
// 第一次初始化MediaPlayer
|
||||||
|
if (redPacketMediaPlayer == null) {
|
||||||
|
redPacketMediaPlayer = MediaPlayer.create(this, R.raw.red_packet_come); // 假设音效文件名为red_packet_sound.mp3
|
||||||
|
redPacketMediaPlayer.setOnPreparedListener(mp -> {
|
||||||
|
isRedPacketMediaPrepared = true;
|
||||||
|
mp.start();
|
||||||
|
});
|
||||||
|
redPacketMediaPlayer.setOnCompletionListener(mp -> {
|
||||||
|
// 播放完成后重置,以便下次重新播放
|
||||||
|
try {
|
||||||
|
mp.seekTo(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("MediaPlayer重置失败", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redPacketMediaPlayer != null) {
|
||||||
|
redPacketMediaPlayer.prepareAsync(); // 异步准备
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 已经准备好了,直接重新播放
|
||||||
|
if (redPacketMediaPlayer != null && !redPacketMediaPlayer.isPlaying()) {
|
||||||
|
redPacketMediaPlayer.seekTo(0);
|
||||||
|
redPacketMediaPlayer.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("播放红包音效失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRedFloatingViewData(View view, RedBean redBean){
|
||||||
|
TextView textView = view.findViewById(R.id.tv_name);
|
||||||
|
|
||||||
|
if (redBean != null) {
|
||||||
|
String fullText = redBean.getText();
|
||||||
|
if (redBean.getNickname() != null && redBean.getRoom_name() != null) {
|
||||||
|
SpannableStringBuilder builder = new SpannableStringBuilder(fullText);
|
||||||
|
|
||||||
|
// 为用户名设置蓝色
|
||||||
|
int userNameStart = fullText.indexOf(redBean.getNickname());
|
||||||
|
if (userNameStart >= 0) {
|
||||||
|
builder.setSpan(
|
||||||
|
new ForegroundColorSpan(ContextCompat.getColor(this, R.color.colorPrimary)),
|
||||||
|
userNameStart,
|
||||||
|
userNameStart + redBean.getNickname().length(),
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 为房间名设置蓝色
|
||||||
|
int roomNameStart = fullText.indexOf(redBean.getRoom_name());
|
||||||
|
if (roomNameStart >= 0) {
|
||||||
|
builder.setSpan(
|
||||||
|
new ForegroundColorSpan(ContextCompat.getColor(this, R.color.colorPrimary)),
|
||||||
|
roomNameStart,
|
||||||
|
roomNameStart + redBean.getRoom_name().length(),
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setText(builder);
|
||||||
|
} else {
|
||||||
|
textView.setText(fullText);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
textView.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
view.setOnClickListener(v -> {
|
||||||
|
// 点击时执行跳转操作
|
||||||
|
handleRedItemClick(redBean);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 处理下一个MQTT消息
|
// 处理下一个MQTT消息
|
||||||
private void processNextMqttMessage() {
|
private void processNextMqttMessage() {
|
||||||
MqttBean.ListBean mqttBean;
|
MqttBean.ListBean mqttBean;
|
||||||
@@ -737,8 +903,9 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
showPiaoPingMessageXlh(xlhBean);
|
showPiaoPingMessageXlh(xlhBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewGroup decorView;
|
ViewGroup decorView;//礼物的
|
||||||
ViewGroup decorView1;
|
ViewGroup decorView1;//巡乐会的
|
||||||
|
ViewGroup decorView2;//红包的
|
||||||
|
|
||||||
private void showFloatingMessage(MqttBean.ListBean mqttBean) {
|
private void showFloatingMessage(MqttBean.ListBean mqttBean) {
|
||||||
|
|
||||||
@@ -977,7 +1144,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
LogUtils.e("XLH动画执行失败", e);
|
LogUtils.e("XLH动画执行失败", e);
|
||||||
onAnimationEnd.run();
|
onAnimationEnd.run();
|
||||||
}
|
}
|
||||||
}, 3000);
|
}, 5000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtils.e("XLH动画启动失败", e);
|
LogUtils.e("XLH动画启动失败", e);
|
||||||
onAnimationEnd.run();
|
onAnimationEnd.run();
|
||||||
@@ -1031,6 +1198,15 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleRedItemClick(RedBean redBean) {
|
||||||
|
// 这里可以根据实际需求实现跳转逻辑
|
||||||
|
// 例如:跳转到礼物详情页面、用户主页等
|
||||||
|
// 使用缓存数据进入房间
|
||||||
|
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), redBean.getRoom_id(), "");
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onEvent(ChatInfo event) {
|
public void onEvent(ChatInfo event) {
|
||||||
|
|||||||
@@ -213,24 +213,6 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
|||||||
return resources;
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
public void userInfoEvent(UserInfo event) {
|
|
||||||
// V2TIMUserFullInfo userFullInfo = new V2TIMUserFullInfo();
|
|
||||||
// userFullInfo.setNickname(event.getNickname());
|
|
||||||
// userFullInfo.setFaceUrl(event.getAvatar());
|
|
||||||
// userFullInfo.setAllowType(event.getSex());
|
|
||||||
// V2TIMManager.getInstance().setSelfInfo(userFullInfo, new V2TIMCallback() {
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess() {
|
|
||||||
// LogUtils.e("@@@", "成功");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError(int code, String desc) {
|
|
||||||
// LogUtils.e("@@@", "描述"+desc);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 显示全局飘屏消息(支持任意位置飘过)
|
* 显示全局飘屏消息(支持任意位置飘过)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -450,8 +450,8 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
|
|||||||
// startService(mqttServiceIntent);
|
// startService(mqttServiceIntent);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.181.248","android-"+ MqttClient.generateClientId());
|
mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.181.248","android-"+ MqttClient.generateClientId());
|
||||||
mqttConnect=MqttConnect.getInstance(this,"tcp://62.234.12.147","android-"+ MqttClient.generateClientId());
|
// mqttConnect=MqttConnect.getInstance(this,"tcp://62.234.12.147","android-"+ MqttClient.generateClientId());
|
||||||
mqttConnect.mqttClient();
|
mqttConnect.mqttClient();
|
||||||
|
|
||||||
// 每次启动应用时重置状态
|
// 每次启动应用时重置状态
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import lombok.Data;
|
|||||||
public class RedPacketInfo {
|
public class RedPacketInfo {
|
||||||
private int id;
|
private int id;
|
||||||
private String remark;// 备注
|
private String remark;// 备注
|
||||||
private String password;// 开始时间
|
private String password;// 口令
|
||||||
private int countdown;//0:立即开抢,其他:倒计时抢
|
private int countdown;//0:立即开抢,其他:倒计时抢
|
||||||
private String conditions;//条件
|
private String conditions;//条件
|
||||||
private String total_amount;//红包总金额
|
private String total_amount;//红包总金额
|
||||||
@@ -32,13 +32,13 @@ public class RedPacketInfo {
|
|||||||
private long end_time;
|
private long end_time;
|
||||||
private long createtime;
|
private long createtime;
|
||||||
private String updatetime;
|
private String updatetime;
|
||||||
|
private int is_qiang;
|
||||||
|
|
||||||
// 获取剩余时间
|
// 获取剩余时间
|
||||||
public long remainingTime() {
|
public long remainingTime() {
|
||||||
long needTime = 0;
|
long needTime = 0;
|
||||||
// 获取当前时间戳(毫秒)
|
// 获取当前时间戳(毫秒)
|
||||||
long currentTimeMillis = System.currentTimeMillis();
|
long currentTimeMillis = System.currentTimeMillis() / 1000;
|
||||||
// 计算剩余时间
|
// 计算剩余时间
|
||||||
needTime = start_time - currentTimeMillis;
|
needTime = start_time - currentTimeMillis;
|
||||||
return needTime;
|
return needTime;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class RedpacketDetail {
|
public class RedpacketDetail {
|
||||||
private RedPacketInfo redPacket_info;
|
private RedPacketInfo redpacket_info;
|
||||||
|
|
||||||
private List<Records> records;
|
private List<Records> records;
|
||||||
private MyRecord my_record;
|
private MyRecord my_record;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class UserInfo implements Serializable {
|
|||||||
|
|
||||||
private int heartId; // "heartId": 4,
|
private int heartId; // "heartId": 4,
|
||||||
private int heartNum; //
|
private int heartNum; //
|
||||||
|
private String red_num;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,16 @@ package com.xscm.moduleutil.bean;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@author qx
|
*@author qx
|
||||||
*@data 2025/9/2
|
*@data 2025/9/2
|
||||||
*@description: 巡乐会开始后推送的信息
|
*@description: 巡乐会开始后推送的信息
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class XLHBean {
|
public class XLHBean implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String text;
|
private String text;
|
||||||
private String room_id;
|
private String room_id;
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package com.xscm.moduleutil.event;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小时榜飘屏
|
* 小时榜飘屏
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class HourlyBean {
|
public class HourlyBean implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String room_id;
|
private String room_id;
|
||||||
private String room_name;
|
private String room_name;
|
||||||
private String text;
|
private String text;
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.xscm.moduleutil.event;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RedBean implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private String room_id;
|
||||||
|
private String room_name;
|
||||||
|
private String text;
|
||||||
|
private String nickname;
|
||||||
|
}
|
||||||
@@ -4,8 +4,14 @@ package com.xscm.moduleutil.event;
|
|||||||
*/
|
*/
|
||||||
public enum RedEnvelopeStatus {
|
public enum RedEnvelopeStatus {
|
||||||
|
|
||||||
READY_TO_OPEN, // 可以直接打开
|
/// 打开红包
|
||||||
COUNTDOWN_TO_OPEN, // 倒计时后可打开
|
QXRedBagDrawTypeOpen,
|
||||||
CONDITION_TO_OPEN, // 满足条件后可打开
|
/// 仅倒计时
|
||||||
COUNTDOWN_AND_CONDITION // 先倒计时,再满足条件后可打开
|
QXRedBagDrawTypeTimeDown,
|
||||||
|
/// 仅收藏房间
|
||||||
|
QXRedBagDrawTypeCollect,
|
||||||
|
/// 手慢了被领完了
|
||||||
|
QXRedBagDrawTypeFinished,
|
||||||
|
/// 发送评论领红包
|
||||||
|
QXRedBagDrawTypePwdSend,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,6 +387,10 @@ public interface ApiServer {
|
|||||||
@POST(Constants.POST_GZ)
|
@POST(Constants.POST_GZ)
|
||||||
Call<BaseModel<String>> userGuanz(@Field("user_id") String userId, @Field("type") String type);
|
Call<BaseModel<String>> userGuanz(@Field("user_id") String userId, @Field("type") String type);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST(Constants.POST_FOLLOW_ROOM)
|
||||||
|
Call<BaseModel<String>> followRoom(@Field("room_id") String roomId, @Field("type") String type);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.ACCEPT_PK)
|
@POST(Constants.ACCEPT_PK)
|
||||||
Call<BaseModel<String>> acceptPk(@Field("pk_id") String pk_id, @Field("type") String type);
|
Call<BaseModel<String>> acceptPk(@Field("pk_id") String pk_id, @Field("type") String type);
|
||||||
|
|||||||
@@ -3418,6 +3418,20 @@ public class RetrofitClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void followRoom(String room_id, String type, BaseObserver<String> observer) {
|
||||||
|
sApiServer.followRoom(room_id, type).enqueue(new Callback<BaseModel<String>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||||
|
onNextRetu(response, observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void acceptPk(String pk_id, String type, BaseObserver<String> observer) {
|
public void acceptPk(String pk_id, String type, BaseObserver<String> observer) {
|
||||||
sApiServer.acceptPk(pk_id, type).enqueue(new Callback<BaseModel<String>>() {
|
sApiServer.acceptPk(pk_id, type).enqueue(new Callback<BaseModel<String>>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -3642,7 +3656,6 @@ public class RetrofitClient {
|
|||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
ToastUtils.showShort(string.getMsg());
|
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showShort(string.getMsg());
|
ToastUtils.showShort(string.getMsg());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public class MqttConnect {
|
|||||||
public static String shutdown = "";
|
public static String shutdown = "";
|
||||||
public static String update_app = "";
|
public static String update_app = "";
|
||||||
public static String qx_hour_ranking = "";
|
public static String qx_hour_ranking = "";
|
||||||
|
|
||||||
|
public static String qx_redpacket_arrive="";//红包飘屏的主题
|
||||||
Handler handler = new Handler(Looper.getMainLooper());
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
String[] topic;
|
String[] topic;
|
||||||
int[] qos = {1,2,3,0,0,0,0,0,0,0,0,0,0}; // 消息质量
|
int[] qos = {1,2,3,0,0,0,0,0,0,0,0,0,0}; // 消息质量
|
||||||
@@ -47,11 +49,13 @@ public class MqttConnect {
|
|||||||
update_app = "qx_xunlehui"; // 发送更新APP
|
update_app = "qx_xunlehui"; // 发送更新APP
|
||||||
// qx_hour_ranking = "qx_hour_ranking";
|
// qx_hour_ranking = "qx_hour_ranking";
|
||||||
qx_hour_ranking = "qx_hour_ranking";
|
qx_hour_ranking = "qx_hour_ranking";
|
||||||
|
qx_redpacket_arrive="qx_redpacket_arrive";
|
||||||
|
|
||||||
ArrayList<String> topicList = new ArrayList<>();
|
ArrayList<String> topicList = new ArrayList<>();
|
||||||
topicList.add(shutdown);
|
topicList.add(shutdown);
|
||||||
topicList.add(update_app);
|
topicList.add(update_app);
|
||||||
topicList.add(qx_hour_ranking);
|
topicList.add(qx_hour_ranking);
|
||||||
|
topicList.add(qx_redpacket_arrive);
|
||||||
topic = topicList.toArray(new String[0]);
|
topic = topicList.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +91,7 @@ public class MqttConnect {
|
|||||||
sub(shutdown);
|
sub(shutdown);
|
||||||
sub(update_app);
|
sub(update_app);
|
||||||
sub(qx_hour_ranking);
|
sub(qx_hour_ranking);
|
||||||
|
sub(qx_redpacket_arrive);
|
||||||
// uiTip("MQTT连接成功");
|
// uiTip("MQTT连接成功");
|
||||||
}catch (MqttException e){
|
}catch (MqttException e){
|
||||||
// uiTip("MQTT连接失败,准备重连。。。:"+e.getMessage());
|
// uiTip("MQTT连接失败,准备重连。。。:"+e.getMessage());
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.orhanobut.logger.Logger;
|
|||||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||||
import com.xscm.moduleutil.bean.XLHBean;
|
import com.xscm.moduleutil.bean.XLHBean;
|
||||||
import com.xscm.moduleutil.event.HourlyBean;
|
import com.xscm.moduleutil.event.HourlyBean;
|
||||||
|
import com.xscm.moduleutil.event.RedBean;
|
||||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||||
import com.xscm.moduleutil.utils.SpUtil;
|
import com.xscm.moduleutil.utils.SpUtil;
|
||||||
|
|
||||||
@@ -63,9 +64,49 @@ public class MqttInitCallback implements MqttCallback {
|
|||||||
receiveXlhMessage(messageStr);
|
receiveXlhMessage(messageStr);
|
||||||
}else if (topic.equals("qx_hour_ranking")){
|
}else if (topic.equals("qx_hour_ranking")){
|
||||||
receiveQXHourRanking(topic, messageStr);
|
receiveQXHourRanking(topic, messageStr);
|
||||||
|
}else if (topic.equals("qx_redpacket_arrive")){
|
||||||
|
receiveRed(topic, messageStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void receiveRed(String topic, String messageStr) {
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(messageStr);
|
||||||
|
String message = jsonObject.getString("msg");
|
||||||
|
// 将事件处理放到主线程执行
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
processRedMessage(topic, message);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processRedMessage(String topic, String message) {
|
||||||
|
try {
|
||||||
|
// 如果 data 是集合字符串
|
||||||
|
// 解析为集合
|
||||||
|
RedBean dataList = JSON.parseObject(message, RedBean.class);
|
||||||
|
|
||||||
|
// 在主线程处理集合数据
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
processDataRed(dataList);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processDataRed(RedBean dataList) {
|
||||||
|
// 遍历集合并发送每个元素
|
||||||
|
// for (HourlyBean dataItem : dataList) {
|
||||||
|
// EventBus.getDefault().post(dataItem);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 或者发送整个集合
|
||||||
|
EventBus.getDefault().post(dataList);
|
||||||
|
}
|
||||||
|
|
||||||
private void receiveQXHourRanking(String topic, String data) {
|
private void receiveQXHourRanking(String topic, String data) {
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = JSON.parseObject(data);
|
JSONObject jsonObject = JSON.parseObject(data);
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ package com.xscm.moduleutil.utils;
|
|||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 红包管理器单例类
|
* 红包管理器单例类
|
||||||
@@ -20,7 +24,7 @@ public class QXRedPacketManager {
|
|||||||
|
|
||||||
// 私有构造函数,防止外部实例化
|
// 私有构造函数,防止外部实例化
|
||||||
private QXRedPacketManager() {
|
private QXRedPacketManager() {
|
||||||
this.redPackets = new HashMap<>();
|
this.redPackets = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,6 +57,8 @@ public class QXRedPacketManager {
|
|||||||
this.redPackets.put(model.getRedpacket_id(), model);
|
this.redPackets.put(model.getRedpacket_id(), model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 在添加数据后启动定时器(如果尚未启动)
|
||||||
|
startCheckTimer();
|
||||||
if (this.delegate != null && this.delegate instanceof QXRedPacketManagerDelegate) {
|
if (this.delegate != null && this.delegate instanceof QXRedPacketManagerDelegate) {
|
||||||
((QXRedPacketManagerDelegate) this.delegate).onRedPacketsAdded(redPackets, this.redPackets.size());
|
((QXRedPacketManagerDelegate) this.delegate).onRedPacketsAdded(redPackets, this.redPackets.size());
|
||||||
}
|
}
|
||||||
@@ -70,6 +76,8 @@ public class QXRedPacketManager {
|
|||||||
|
|
||||||
this.redPackets.put(redPacket.getRedpacket_id(), redPacket);
|
this.redPackets.put(redPacket.getRedpacket_id(), redPacket);
|
||||||
|
|
||||||
|
// 在添加数据后启动定时器(如果尚未启动)
|
||||||
|
startCheckTimer();
|
||||||
if (this.delegate != null && this.delegate instanceof QXRedPacketManagerDelegate) {
|
if (this.delegate != null && this.delegate instanceof QXRedPacketManagerDelegate) {
|
||||||
((QXRedPacketManagerDelegate) this.delegate).onRedPacketAdded(redPacket, this.redPackets.size());
|
((QXRedPacketManagerDelegate) this.delegate).onRedPacketAdded(redPacket, this.redPackets.size());
|
||||||
}
|
}
|
||||||
@@ -111,6 +119,10 @@ public class QXRedPacketManager {
|
|||||||
* 开始检查定时器
|
* 开始检查定时器
|
||||||
*/
|
*/
|
||||||
public void startCheckTimer() {
|
public void startCheckTimer() {
|
||||||
|
// 如果定时器已经在运行,直接返回
|
||||||
|
if (checkTimerRunnable != null && checkTimerHandler != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (checkTimerRunnable == null) {
|
if (checkTimerRunnable == null) {
|
||||||
checkTimerRunnable = new Runnable() {
|
checkTimerRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -128,9 +140,35 @@ public class QXRedPacketManager {
|
|||||||
* 检查并更新红包状态
|
* 检查并更新红包状态
|
||||||
*/
|
*/
|
||||||
private void checkAndUpdateRedPackets() {
|
private void checkAndUpdateRedPackets() {
|
||||||
|
// 添加空值检查
|
||||||
|
if (this.redPackets == null || this.redPackets.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<RedPacketInfo> packets = new ArrayList<>(this.redPackets.values());
|
List<RedPacketInfo> packets = new ArrayList<>(this.redPackets.values());
|
||||||
|
|
||||||
for (RedPacketInfo packet : packets) {
|
for (RedPacketInfo packet : packets) {
|
||||||
|
long packetTime = packet.remainingTime();
|
||||||
|
LogUtils.e("红包剩余时间:" + packet.getRedpacket_time());
|
||||||
|
long redpacketTime = 0;
|
||||||
|
try {
|
||||||
|
if (packet.getRedpacket_time() != null) {
|
||||||
|
redpacketTime = Long.parseLong(packet.getRedpacket_time());
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
LogUtils.e("红包时间格式错误: " + packet.getRedpacket_time());
|
||||||
|
}
|
||||||
|
if (packetTime <= -redpacketTime) {
|
||||||
|
|
||||||
|
removeRedPacket(packet.getRedpacket_id());
|
||||||
|
}
|
||||||
|
if (packet.getCountdown()==0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.delegate != null && this.delegate instanceof QXRedPacketManagerDelegate) {
|
||||||
|
((QXRedPacketManagerDelegate) this.delegate).didUpdateRedPacketTime(packet, packetTime);
|
||||||
|
}
|
||||||
|
|
||||||
boolean wasAvailable = packet.isAvailable();
|
boolean wasAvailable = packet.isAvailable();
|
||||||
packet.setAvailable(packet.canOpenNow());
|
packet.setAvailable(packet.canOpenNow());
|
||||||
|
|
||||||
@@ -140,12 +178,6 @@ public class QXRedPacketManager {
|
|||||||
((QXRedPacketManagerDelegate) this.delegate).onRedPacketUpdated(packet, this.redPackets.size());
|
((QXRedPacketManagerDelegate) this.delegate).onRedPacketUpdated(packet, this.redPackets.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 倒计时结束的红包可以设置自动移除
|
|
||||||
if (packet.getCountdown() > 0 && packet.remainingTime() <= -(Long.getLong(packet.getRedpacket_time()))) {
|
|
||||||
// 倒计时结束10秒后自动移除
|
|
||||||
removeRedPacket(packet.getRedpacket_id());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 继续执行定时任务
|
// 继续执行定时任务
|
||||||
@@ -157,6 +189,7 @@ public class QXRedPacketManager {
|
|||||||
*/
|
*/
|
||||||
public void removeAllRedPackets() {
|
public void removeAllRedPackets() {
|
||||||
this.redPackets.clear();
|
this.redPackets.clear();
|
||||||
|
endCheckTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,24 +212,6 @@ public class QXRedPacketManager {
|
|||||||
this.delegate = null;
|
this.delegate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置委托对象
|
|
||||||
*
|
|
||||||
* @param delegate 委托对象
|
|
||||||
*/
|
|
||||||
public void setDelegate(QXRedPacketManagerDelegate delegate) {
|
|
||||||
this.delegate = delegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取委托对象
|
|
||||||
*
|
|
||||||
* @return 委托对象
|
|
||||||
*/
|
|
||||||
public QXRedPacketManagerDelegate getDelegate() {
|
|
||||||
return this.delegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 委托接口
|
* 委托接口
|
||||||
*/
|
*/
|
||||||
@@ -232,8 +247,29 @@ public class QXRedPacketManager {
|
|||||||
* @param remainingCount 剩余数量
|
* @param remainingCount 剩余数量
|
||||||
*/
|
*/
|
||||||
void onRedPacketUpdated(RedPacketInfo packet, int remainingCount);
|
void onRedPacketUpdated(RedPacketInfo packet, int remainingCount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新红包时间回调
|
||||||
|
*
|
||||||
|
* @param packet 红包模型
|
||||||
|
* @param packetTime 红包剩余时间
|
||||||
|
*/
|
||||||
|
void didUpdateRedPacketTime(RedPacketInfo packet, long packetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -- SETTER --
|
||||||
|
* 设置委托对象
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -- GETTER --
|
||||||
|
* 获取委托对象
|
||||||
|
*
|
||||||
|
@param delegate 委托对象
|
||||||
|
* @return 委托对象
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private QXRedPacketManagerDelegate delegate;
|
private QXRedPacketManagerDelegate delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ public class Constants {
|
|||||||
public static final String GET_USER_HOME_ZONE = "/api/User/user_home_zone";//获取用户动态
|
public static final String GET_USER_HOME_ZONE = "/api/User/user_home_zone";//获取用户动态
|
||||||
public static final String GET_LIKE_LIST = "/api/UserZone/like_list";//获取点赞列表
|
public static final String GET_LIKE_LIST = "/api/UserZone/like_list";//获取点赞列表
|
||||||
public static final String POST_GZ = "/api/User/follow";//关注、回关、取关
|
public static final String POST_GZ = "/api/User/follow";//关注、回关、取关
|
||||||
|
public static final String POST_FOLLOW_ROOM = "/api/User/follow_room";//收藏
|
||||||
public static final String GET_ALBUM_DETAIL = "/api/User/get_album_detail";//相册详情
|
public static final String GET_ALBUM_DETAIL = "/api/User/get_album_detail";//相册详情
|
||||||
public static final String UP_ALBUM = "/api/User/add_album_content";//添加相册图片
|
public static final String UP_ALBUM = "/api/User/add_album_content";//添加相册图片
|
||||||
public static final String MOVE_ALBUM = "/api/User/move_album_images";//移动相册图片
|
public static final String MOVE_ALBUM = "/api/User/move_album_images";//移动相册图片
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape android:shape="rectangle"
|
<shape android:shape="rectangle"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<solid android:color="@color/transparent" />
|
<solid android:color="#40000000" />
|
||||||
<corners android:radius="@dimen/dp_6"/>
|
<corners android:radius="@dimen/dp_6"/>
|
||||||
</shape>
|
</shape>
|
||||||
35
moduleUtil/src/main/res/layout/item_piaoping_red.xml
Normal file
35
moduleUtil/src/main/res/layout/item_piaoping_red.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/im_xlh"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@mipmap/red_pp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/dp_60"
|
||||||
|
android:layout_marginEnd="@dimen/dp_2"
|
||||||
|
android:layout_marginTop="@dimen/dp_5"
|
||||||
|
android:ellipsize="start"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="礼品"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="@dimen/sp_12"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
BIN
moduleUtil/src/main/res/mipmap-mdpi/red_tx.png
Normal file
BIN
moduleUtil/src/main/res/mipmap-mdpi/red_tx.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_bj_h.png
Normal file
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_bj_h.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_kl_b.png
Normal file
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_kl_b.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_liet_bj.webp
Normal file
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_liet_bj.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_pp.webp
Normal file
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/red_pp.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
BIN
moduleUtil/src/main/res/raw/red_packet_come.MP3
Normal file
BIN
moduleUtil/src/main/res/raw/red_packet_come.MP3
Normal file
Binary file not shown.
@@ -93,13 +93,14 @@ public class RedResultActivity extends BaseMvpActivity<RedEnvelopesPresenter, Fr
|
|||||||
@Override
|
@Override
|
||||||
public void redPacketDetail(RedpacketDetail redpacketDetail) {
|
public void redPacketDetail(RedpacketDetail redpacketDetail) {
|
||||||
if (redpacketDetail != null) {
|
if (redpacketDetail != null) {
|
||||||
ImageUtils.loadHeadCC(redpacketDetail.getMy_record().getAvatar(), mBinding.userAvatar);
|
ImageUtils.loadHeadCC(redpacketDetail.getRedpacket_info().getAvatar(), mBinding.userAvatar);
|
||||||
mBinding.userName.setText(redpacketDetail.getMy_record().getNickname());
|
mBinding.userName.setText(redpacketDetail.getRedpacket_info().getNickname());
|
||||||
mBinding.tvRedTitle.setText(redpacketDetail.getRedPacket_info().getRemark());
|
mBinding.tvRedTitle.setText(redpacketDetail.getRedpacket_info().getRemark());
|
||||||
|
mBinding.tvJb.setText(redpacketDetail.getRedpacket_info().getCoin_type() == 1 ? "金币" : "钻石");
|
||||||
|
if (redpacketDetail.getMy_record() != null) {
|
||||||
mBinding.tvRedJb.setText(redpacketDetail.getMy_record().getAmount());
|
mBinding.tvRedJb.setText(redpacketDetail.getMy_record().getAmount());
|
||||||
mBinding.tvJb.setText(redpacketDetail.getRedPacket_info().getCoin_type() == 1 ? "金币" : "钻石");
|
}
|
||||||
mBinding.tvLq.setText(redpacketDetail.getRecords().size() + "/" + redpacketDetail.getRedPacket_info().getTotal_count());
|
mBinding.tvLq.setText(redpacketDetail.getRecords().size() + "/" + redpacketDetail.getRedpacket_info().getTotal_count());
|
||||||
|
|
||||||
redAdapter.setNewData(redpacketDetail.getRecords());
|
redAdapter.setNewData(redpacketDetail.getRecords());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -592,7 +592,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
// 在onCreate中初始化红包管理器实例,以便在整个Activity生命周期中使用
|
// 在onCreate中初始化红包管理器实例,以便在整个Activity生命周期中使用
|
||||||
qxRedPacketManager = QXRedPacketManager.getInstance()
|
qxRedPacketManager = QXRedPacketManager.getInstance()
|
||||||
// 获取单例实例并设置委托
|
// 获取单例实例并设置委托
|
||||||
QXRedPacketManager.getInstance().setDelegate(this);
|
qxRedPacketManager!!.setDelegate(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -839,6 +840,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
RedBagSendDialog(this, roomId).show()
|
RedBagSendDialog(this, roomId).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var redEnvelopesFragment: RedEnvelopesFragment? = null
|
||||||
|
var redListDialog: RedListDialog? = null
|
||||||
|
var redPacketInfo: RedPacketInfo? = null
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
super.initView()
|
super.initView()
|
||||||
floatingMagnetView = findViewById(R.id.flaoat)
|
floatingMagnetView = findViewById(R.id.flaoat)
|
||||||
@@ -883,9 +888,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
layoutParams.height = SystemUtils.getWidth(74) // 示例高度
|
layoutParams.height = SystemUtils.getWidth(74) // 示例高度
|
||||||
mBinding!!.roomTop.root.layoutParams = layoutParams
|
mBinding!!.roomTop.root.layoutParams = layoutParams
|
||||||
|
|
||||||
// MP4PlaybackCallback mp4PlaybackCallback=MP4PlaybackCallback.getInstance();
|
|
||||||
// mp4PlaybackCallback.setAvatarFrameView(mBinding.svgaGift);
|
|
||||||
// mBinding.svgaGift.setAnimListener(mp4PlaybackCallback);
|
|
||||||
mBinding!!.xlhIm.setOnClickListener {
|
mBinding!!.xlhIm.setOnClickListener {
|
||||||
val fm = supportFragmentManager
|
val fm = supportFragmentManager
|
||||||
if (fm != null && !fm.isDestroyed) {
|
if (fm != null && !fm.isDestroyed) {
|
||||||
@@ -904,8 +906,24 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
|
|
||||||
mBinding!!.drvRed.visibility = View.GONE
|
mBinding!!.drvRed.visibility = View.GONE
|
||||||
mBinding!!.redBj.setOnClickListener {
|
mBinding!!.redBj.setOnClickListener {
|
||||||
val redListDialog = RedListDialog(this)
|
redListDialog = RedListDialog(this)
|
||||||
redListDialog.show()
|
redListDialog!!.setOnRedPacketClickListener(object : RedListDialog.OnRedPacketClickListener {
|
||||||
|
|
||||||
|
override fun onRedPacketClick(redPacketInfos: RedPacketInfo?, position: Int) {
|
||||||
|
redPacketInfo = redPacketInfos
|
||||||
|
if (redPacketInfos!=null && redPacketInfos.is_qiang==1){
|
||||||
|
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", redPacketInfos.getRedpacket_id()).navigation();
|
||||||
|
}else {
|
||||||
|
redEnvelopesFragment = RedEnvelopesFragment(this@RoomActivity)
|
||||||
|
redEnvelopesFragment!!.setIsCollectedRoom(mRoomUserBean!!.is_collect == 1)
|
||||||
|
redEnvelopesFragment!!.setFromToComment(false)
|
||||||
|
redEnvelopesFragment!!.setRedPacket(redPacketInfos)
|
||||||
|
redEnvelopesFragment!!.show()
|
||||||
|
redListDialog!!.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
redListDialog!!.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2505,6 +2523,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setUserInfo() {
|
||||||
|
mRoomInfoResp!!.user_info.is_collect = 1
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特效设置
|
* 特效设置
|
||||||
*/
|
*/
|
||||||
@@ -3130,6 +3152,13 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
}
|
}
|
||||||
etContent.setText("")
|
etContent.setText("")
|
||||||
countDownTimer()
|
countDownTimer()
|
||||||
|
if (redEnvelopesFragment != null) {
|
||||||
|
redEnvelopesFragment = RedEnvelopesFragment(this@RoomActivity)
|
||||||
|
redEnvelopesFragment!!.setIsCollectedRoom(mRoomUserBean!!.is_collect == 1)
|
||||||
|
redEnvelopesFragment!!.setFromToComment(true)
|
||||||
|
redEnvelopesFragment!!.setRedPacket(redPacketInfo)
|
||||||
|
redEnvelopesFragment!!.show()
|
||||||
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -3172,11 +3201,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
fun roomInfoEvent(messageEvent: UserInfo) {
|
fun roomInfoEvent(messageEvent: UserInfo) {
|
||||||
// mBinding.llInput.setVisibility(View.VISIBLE);
|
if (messageEvent != null && messageEvent.red_num != null) {
|
||||||
// mBinding.inputMenu1.bringToFront(); // 强制将该 View 置于最上层
|
inputSting = messageEvent.red_num
|
||||||
// mBinding.inputMenu1.show();
|
} else {
|
||||||
// mBinding.inputMenu1.setText("@" + messageEvent.getNickname());
|
|
||||||
inputSting = "@" + messageEvent.nickname
|
inputSting = "@" + messageEvent.nickname
|
||||||
|
}
|
||||||
dialogDismiss()
|
dialogDismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3428,7 +3457,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
mBinding!!.ivQuanC.setOnClickListener { v: View? ->
|
mBinding!!.ivQuanC.setOnClickListener { v: View? ->
|
||||||
if (mRoomInfoResp!!.room_info.head_line.room_id != null && mRoomInfoResp!!.room_info.head_line.room_id.isNotEmpty()) {
|
if (mRoomInfoResp!!.room_info.head_line.room_id != null && mRoomInfoResp!!.room_info.head_line.room_id.isNotEmpty()) {
|
||||||
if (mRoomInfoResp!!.room_info.head_line.room_id != roomId) {
|
if (mRoomInfoResp!!.room_info.head_line.room_id != roomId) {
|
||||||
RoomManager.getInstance().fetchRoomDataAndEnter(applicationContext,mRoomInfoResp!!.room_info.head_line.room_id,"")
|
RoomManager.getInstance()
|
||||||
|
.fetchRoomDataAndEnter(applicationContext, mRoomInfoResp!!.room_info.head_line.room_id, "")
|
||||||
} else {
|
} else {
|
||||||
com.blankj.utilcode.util.ToastUtils.showLong("您就在当前房间")
|
com.blankj.utilcode.util.ToastUtils.showLong("您就在当前房间")
|
||||||
}
|
}
|
||||||
@@ -4176,6 +4206,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
clearMinimizeState()
|
clearMinimizeState()
|
||||||
cleanupResources()
|
cleanupResources()
|
||||||
}
|
}
|
||||||
|
if (qxRedPacketManager != null) {
|
||||||
|
qxRedPacketManager!!.endCheckTimer();
|
||||||
|
}
|
||||||
// 确保父类的 onDestroy 被调用
|
// 确保父类的 onDestroy 被调用
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
@@ -4500,6 +4533,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
mBinding!!.drvRed.visibility = View.VISIBLE
|
mBinding!!.drvRed.visibility = View.VISIBLE
|
||||||
mBinding!!.redNum.visibility = View.VISIBLE
|
mBinding!!.redNum.visibility = View.VISIBLE
|
||||||
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
||||||
|
} else {
|
||||||
|
mBinding!!.drvRed.visibility = View.GONE
|
||||||
|
mBinding!!.redNum.visibility = View.GONE
|
||||||
|
qxRedPacketManager!!.removeAllRedPackets()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4515,10 +4552,70 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
|
|
||||||
override fun onRedPacketRemoved(packetId: String?, remainingCount: Int) {
|
override fun onRedPacketRemoved(packetId: String?, remainingCount: Int) {
|
||||||
// 处理移除红包的逻辑
|
// 处理移除红包的逻辑
|
||||||
|
if (remainingCount == 0) {
|
||||||
|
mBinding!!.drvRed.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
mBinding!!.drvRed.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRedPacketUpdated(packet: RedPacketInfo?, remainingCount: Int) {
|
override fun onRedPacketUpdated(packet: RedPacketInfo?, remainingCount: Int) {
|
||||||
// 处理红包状态更新的逻辑
|
// 处理红包状态更新的逻辑
|
||||||
|
if (redEnvelopesFragment != null && redEnvelopesFragment!!.mRedPacketInfo != null && redEnvelopesFragment!!.mRedPacketInfo!!.countdown > 0) {
|
||||||
|
if (redEnvelopesFragment!!.mRedPacketInfo.type == 1) {
|
||||||
|
redEnvelopesFragment!!.changeViewType(RedEnvelopeStatus.QXRedBagDrawTypeOpen)
|
||||||
|
}else{
|
||||||
|
if (redEnvelopesFragment!!.isFromToComment) {
|
||||||
|
redEnvelopesFragment!!.changeViewType(RedEnvelopeStatus.QXRedBagDrawTypeOpen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didUpdateRedPacketTime(packet: RedPacketInfo?, packetTime: Long) {
|
||||||
|
|
||||||
|
if ((redEnvelopesFragment != null) && (redEnvelopesFragment!!.mRedPacketInfo != null) &&
|
||||||
|
(redEnvelopesFragment!!.mRedPacketInfo!!.countdown > 0) && packetTime >= 0
|
||||||
|
) {
|
||||||
|
LogUtils.e("进入倒计时" + packetTime)
|
||||||
|
if (redEnvelopesFragment!!.mRedPacketInfo.type == 1) {
|
||||||
|
if (redEnvelopesFragment!!.mRedPacketInfo.conditions.contains("1")) {
|
||||||
|
//有收藏房间条件
|
||||||
|
if (mRoomInfoResp!!.user_info.is_collect == 1) {
|
||||||
|
//需要满足收藏在倒计时
|
||||||
|
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (redEnvelopesFragment!!.isFromToComment) {
|
||||||
|
if (redEnvelopesFragment!!.mRedPacketInfo.conditions.contains("1")) {
|
||||||
|
//有收藏房间条件
|
||||||
|
if (mRoomInfoResp!!.user_info.is_collect == 1) {
|
||||||
|
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (redListDialog != null) {
|
||||||
|
if (redListDialog!!.isShowing && redListDialog!!.adapter != null) {
|
||||||
|
val adapter = redListDialog!!.adapter
|
||||||
|
val list = adapter.data
|
||||||
|
for (i in list.indices) {
|
||||||
|
val redPacketInfo = list[i]
|
||||||
|
if (redPacketInfo.redpacket_id == packet!!.redpacket_id) {
|
||||||
|
adapter.updateCountdown(i, packetTime)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class RedAdapter extends BaseQuickAdapter<RedpacketDetail.Records, BaseVi
|
|||||||
ImageUtils.loadHeadCC(redBean.getAvatar(), baseViewHolder.getView(R.id.red_user_avatar));
|
ImageUtils.loadHeadCC(redBean.getAvatar(), baseViewHolder.getView(R.id.red_user_avatar));
|
||||||
baseViewHolder.setText(R.id.tv_user_name, redBean.getNickname());
|
baseViewHolder.setText(R.id.tv_user_name, redBean.getNickname());
|
||||||
baseViewHolder.setText(R.id.tv_red_num, redBean.getAmount());
|
baseViewHolder.setText(R.id.tv_red_num, redBean.getAmount());
|
||||||
baseViewHolder.setText(R.id.tv_time, formatTimestamp(Long.getLong(redBean.getCreatetime())));
|
baseViewHolder.setText(R.id.tv_time, redBean.getCreatetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatTimestamp(long timestamp) {
|
private String formatTimestamp(long timestamp) {
|
||||||
|
|||||||
@@ -1,20 +1,116 @@
|
|||||||
package com.example.moduleroom.adapter;
|
package com.example.moduleroom.adapter;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
import com.chad.library.adapter.base.BaseViewHolder;
|
||||||
import com.example.moduleroom.R;
|
import com.example.moduleroom.R;
|
||||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 红包的列表适配器
|
* 红包的列表适配器
|
||||||
*/
|
*/
|
||||||
public class RedBagAdapter extends BaseQuickAdapter<RedPacketInfo, BaseViewHolder> {
|
public class RedBagAdapter extends BaseQuickAdapter<RedPacketInfo, BaseViewHolder> {
|
||||||
|
private Map<Integer,View> viewMap;
|
||||||
public RedBagAdapter() {
|
public RedBagAdapter() {
|
||||||
super(R.layout.item_red_bag);
|
super(R.layout.item_red_bag);
|
||||||
|
viewMap=new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void convert(BaseViewHolder helper, RedPacketInfo item) {
|
protected void convert(BaseViewHolder helper, RedPacketInfo item) {
|
||||||
|
viewMap.put(helper.getLayoutPosition(),helper.itemView);
|
||||||
|
ImageView iv_red_bag= helper.getView(R.id.iv_red_bag);
|
||||||
|
if (item.getIs_qiang()==1){
|
||||||
|
iv_red_bag.setImageResource(com.xscm.moduleutil.R.mipmap.red_bj_h);
|
||||||
|
helper.setVisible(R.id.tv_user_name,false);
|
||||||
|
helper.setVisible(R.id.tv_djs,false);
|
||||||
|
}else {
|
||||||
|
iv_red_bag.setImageResource(com.xscm.moduleutil.R.mipmap.red);
|
||||||
|
|
||||||
|
if (item.getType()==2){
|
||||||
|
helper.setVisible(R.id.im_list_bj,true);
|
||||||
|
}else {
|
||||||
|
helper.setVisible(R.id.im_list_bj,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示倒计时
|
||||||
|
if (item.getCountdown() > 0) {
|
||||||
|
helper.setVisible(R.id.tv_djs, true);
|
||||||
|
long minutes = item.getCountdown() / 60;
|
||||||
|
long seconds = item.getCountdown() % 60;
|
||||||
|
String timeFormat = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
helper.setText(R.id.tv_djs, timeFormat);
|
||||||
|
} else {
|
||||||
|
helper.setVisible(R.id.tv_djs, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.setText(R.id.tv_user_name, item.getNickname());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新指定位置的倒计时显示,不刷新整个item
|
||||||
|
* @param position 列表位置
|
||||||
|
* @param countdown 倒计时时间(秒)
|
||||||
|
*/
|
||||||
|
public void updateCountdown(int position, long countdown) {
|
||||||
|
if (position >= 0 && position < getData().size()) {
|
||||||
|
// 获取对应位置的item view
|
||||||
|
View view = viewMap.get(position);
|
||||||
|
if (view != null) {
|
||||||
|
// 直接更新倒计时文本,不刷新整个item
|
||||||
|
TextView tvDjs = view.findViewById(R.id.tv_djs);
|
||||||
|
if (tvDjs != null) {
|
||||||
|
// 格式化倒计时显示
|
||||||
|
long minutes = countdown / 60;
|
||||||
|
long seconds = countdown % 60;
|
||||||
|
String timeFormat = String.format("%02d:%02d", minutes, seconds);
|
||||||
|
tvDjs.setText(timeFormat);
|
||||||
|
|
||||||
|
// 控制倒计时显示状态
|
||||||
|
if (countdown > 0) {
|
||||||
|
tvDjs.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
tvDjs.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据位置获取item view
|
||||||
|
* @param position 位置
|
||||||
|
* @return item对应的view
|
||||||
|
*/
|
||||||
|
private View getViewByPosition(int position) {
|
||||||
|
RecyclerView recyclerView = getRecyclerView();
|
||||||
|
if (recyclerView != null) {
|
||||||
|
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
|
||||||
|
if (layoutManager != null) {
|
||||||
|
// 检查 position 是否在可见范围内
|
||||||
|
if (layoutManager instanceof LinearLayoutManager) {
|
||||||
|
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
|
||||||
|
int firstVisiblePosition = linearLayoutManager.findFirstVisibleItemPosition();
|
||||||
|
int lastVisiblePosition = linearLayoutManager.findLastVisibleItemPosition();
|
||||||
|
|
||||||
|
// 确保 position 在可见范围内
|
||||||
|
if (position >= firstVisiblePosition && position <= lastVisiblePosition) {
|
||||||
|
return layoutManager.findViewByPosition(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,19 +10,14 @@ import android.view.WindowManager;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
|
||||||
import com.blankj.utilcode.util.ScreenUtils;
|
import com.blankj.utilcode.util.ScreenUtils;
|
||||||
import com.example.moduleroom.R;
|
import com.example.moduleroom.R;
|
||||||
import com.example.moduleroom.adapter.RedBagAdapter;
|
import com.example.moduleroom.adapter.RedBagAdapter;
|
||||||
import com.example.moduleroom.databinding.DialogRedListBinding;
|
import com.example.moduleroom.databinding.DialogRedListBinding;
|
||||||
import com.example.moduleroom.fragment.RedEnvelopesFragment;
|
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
|
||||||
import com.xscm.moduleutil.utils.QXRedPacketManager;
|
import com.xscm.moduleutil.utils.QXRedPacketManager;
|
||||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 这是红包列表
|
* 这是红包列表
|
||||||
*/
|
*/
|
||||||
@@ -34,7 +29,10 @@ public class RedListDialog extends BaseDialog<DialogRedListBinding> {
|
|||||||
public RedListDialog(@NonNull Context context) {
|
public RedListDialog(@NonNull Context context) {
|
||||||
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
||||||
}
|
}
|
||||||
|
// 添加获取适配器的方法
|
||||||
|
public RedBagAdapter getAdapter() {
|
||||||
|
return redBagAdapter;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutId() {
|
public int getLayoutId() {
|
||||||
return R.layout.dialog_red_list;
|
return R.layout.dialog_red_list;
|
||||||
@@ -121,27 +119,21 @@ public class RedListDialog extends BaseDialog<DialogRedListBinding> {
|
|||||||
|
|
||||||
redBagAdapter.setNewData(qxRedPacketManager.getAllRedPackets()) ;
|
redBagAdapter.setNewData(qxRedPacketManager.getAllRedPackets()) ;
|
||||||
redBagAdapter.setOnItemClickListener((adapter, view, position) -> {
|
redBagAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||||
RedEnvelopesFragment redEnvelopesFragment = new RedEnvelopesFragment(getContext());
|
|
||||||
redEnvelopesFragment.setRedPacket(qxRedPacketManager.getAllRedPackets().get(position));
|
|
||||||
redEnvelopesFragment.show();
|
|
||||||
|
|
||||||
|
if (mListener != null) {
|
||||||
|
mListener.onRedPacketClick(redBagAdapter.getData().get(position), position);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// List<String> list = new ArrayList<>();
|
|
||||||
// list.add("1");
|
|
||||||
// list.add("2");
|
|
||||||
// list.add("3");
|
|
||||||
// list.add("4");
|
|
||||||
// list.add("5");
|
|
||||||
// list.add("4");
|
|
||||||
// list.add("5");
|
|
||||||
// list.add("4");
|
|
||||||
// list.add("5");
|
|
||||||
// list.add("4");
|
|
||||||
// list.add("5");
|
|
||||||
// redBagAdapter.setNewData(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnRedPacketClickListener {
|
||||||
|
void onRedPacketClick(RedPacketInfo redPacketInfo,int position);
|
||||||
|
}
|
||||||
|
private OnRedPacketClickListener mListener;
|
||||||
|
|
||||||
|
public void setOnRedPacketClickListener(OnRedPacketClickListener listener) {
|
||||||
|
this.mListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Resources getResources() {
|
private Resources getResources() {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.example.moduleroom.fragment;
|
package com.example.moduleroom.fragment;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@@ -8,21 +9,29 @@ import android.view.WindowManager;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.blankj.utilcode.util.ScreenUtils;
|
import com.blankj.utilcode.util.ScreenUtils;
|
||||||
|
import com.blankj.utilcode.util.TimeUtils;
|
||||||
import com.blankj.utilcode.util.ToastUtils;
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
import com.example.moduleroom.R;
|
import com.example.moduleroom.R;
|
||||||
|
import com.example.moduleroom.activity.RoomActivity;
|
||||||
import com.example.moduleroom.databinding.FragmentRedEnvelopesBinding;
|
import com.example.moduleroom.databinding.FragmentRedEnvelopesBinding;
|
||||||
import com.xscm.moduleutil.bean.RedPackGrab;
|
import com.xscm.moduleutil.bean.RedPackGrab;
|
||||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||||
|
import com.xscm.moduleutil.bean.UserInfo;
|
||||||
import com.xscm.moduleutil.event.RedEnvelopeStatus;
|
import com.xscm.moduleutil.event.RedEnvelopeStatus;
|
||||||
import com.xscm.moduleutil.http.BaseObserver;
|
import com.xscm.moduleutil.http.BaseObserver;
|
||||||
import com.xscm.moduleutil.http.RetrofitClient;
|
import com.xscm.moduleutil.http.RetrofitClient;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.utils.ImageUtils;
|
import com.xscm.moduleutil.utils.ImageUtils;
|
||||||
|
import com.xscm.moduleutil.utils.QXRedPacketManager;
|
||||||
import com.xscm.moduleutil.view.QXRedBagSendView;
|
import com.xscm.moduleutil.view.QXRedBagSendView;
|
||||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||||
|
import com.xscm.moduleutil.widget.floatingView.IFloatingView;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import static com.xscm.moduleutil.event.RedEnvelopeStatus.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xscm
|
* @author xscm
|
||||||
* @ClassName RedEnvelopesFragment
|
* @ClassName RedEnvelopesFragment
|
||||||
@@ -31,12 +40,28 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
*/
|
*/
|
||||||
public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding> {
|
public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding> {
|
||||||
private RedEnvelopeStatus mCurrentStatus;
|
private RedEnvelopeStatus drawType;
|
||||||
private RedPacketInfo mRedPacketInfo;
|
public RedPacketInfo mRedPacketInfo;
|
||||||
|
public boolean isCollectedRoom;//是否收藏房间
|
||||||
|
|
||||||
|
public long needTime;// 倒计时
|
||||||
|
public boolean isFromToComment;//是否是发送评论地方过来
|
||||||
|
|
||||||
|
private CountDownTimer countDownTimer;
|
||||||
|
|
||||||
public RedEnvelopesFragment(@NonNull @NotNull Context context) {
|
public RedEnvelopesFragment(@NonNull @NotNull Context context) {
|
||||||
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//是否收藏方法
|
||||||
|
public void setIsCollectedRoom(boolean isCollectedRoom) {
|
||||||
|
this.isCollectedRoom = isCollectedRoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromToComment(boolean isFromToComment) {
|
||||||
|
this.isFromToComment = isFromToComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData() {
|
public void initData() {
|
||||||
@@ -49,7 +74,8 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
|||||||
setCanceledOnTouchOutside(false);
|
setCanceledOnTouchOutside(false);
|
||||||
Window window = getWindow();
|
Window window = getWindow();
|
||||||
// window.setLayout(345, 454);
|
// window.setLayout(345, 454);
|
||||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 345.f / 345),WindowManager.LayoutParams.WRAP_CONTENT);
|
// window.setLayout((int) (ScreenUtils.getScreenWidth() * 345.f / 345), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||||
|
window.setLayout((int) (ScreenUtils.getScreenWidth() * 0.8), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||||
mBinding.imRedClose.setOnClickListener(new View.OnClickListener() {
|
mBinding.imRedClose.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -75,13 +101,17 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
|||||||
public void onNext(@NotNull RedPackGrab redPackGrab) {
|
public void onNext(@NotNull RedPackGrab redPackGrab) {
|
||||||
if (redPackGrab != null) {
|
if (redPackGrab != null) {
|
||||||
if (redPackGrab.getCode() == 1) {
|
if (redPackGrab.getCode() == 1) {
|
||||||
|
mRedPacketInfo.setIs_qiang(1);
|
||||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||||
|
dismiss();
|
||||||
} else if (redPackGrab.getCode() == 2) {
|
} else if (redPackGrab.getCode() == 2) {
|
||||||
ToastUtils.showShort("您已经抢过红包了");
|
ToastUtils.showShort("您已经抢过红包了");
|
||||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||||
|
dismiss();
|
||||||
} else {
|
} else {
|
||||||
snatched();
|
snatched();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -89,7 +119,7 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
|||||||
|
|
||||||
// QXRedBagSendView redBagView = new QXRedBagSendView(getContext());
|
// QXRedBagSendView redBagView = new QXRedBagSendView(getContext());
|
||||||
// redBagView.showInView((ViewGroup) getWindow().getDecorView());
|
// redBagView.showInView((ViewGroup) getWindow().getDecorView());
|
||||||
dismiss();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mBinding.tvCk.setOnClickListener(new View.OnClickListener() {
|
mBinding.tvCk.setOnClickListener(new View.OnClickListener() {
|
||||||
@@ -98,6 +128,39 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
|||||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mBinding.textPl.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeCollect){
|
||||||
|
RetrofitClient.getInstance().followRoom(mRedPacketInfo.getRoom_id()+"","1", new BaseObserver<String>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NotNull Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NotNull String s) {
|
||||||
|
if (getContext() instanceof RoomActivity) {
|
||||||
|
((RoomActivity) getContext()).setUserInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRedPacketInfo.canOpenNow()){
|
||||||
|
setType(QXRedBagDrawTypeOpen);
|
||||||
|
}else {
|
||||||
|
setType(QXRedBagDrawTypeTimeDown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}else if (drawType == RedEnvelopeStatus.QXRedBagDrawTypePwdSend){
|
||||||
|
UserInfo userInfo = new UserInfo();
|
||||||
|
userInfo.setRed_num(mRedPacketInfo.getPassword());
|
||||||
|
EventBus.getDefault().post(userInfo);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void snatched() {
|
private void snatched() {
|
||||||
@@ -109,7 +172,6 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
|||||||
mBinding.tvKl.setVisibility(View.GONE);
|
mBinding.tvKl.setVisibility(View.GONE);
|
||||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,30 +181,178 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
|||||||
|
|
||||||
public void setRedPacket(RedPacketInfo redPacketInfo) {
|
public void setRedPacket(RedPacketInfo redPacketInfo) {
|
||||||
this.mRedPacketInfo = redPacketInfo;
|
this.mRedPacketInfo = redPacketInfo;
|
||||||
|
setType(getDrawTypeWithRedpacktModel(redPacketInfo));
|
||||||
|
if (redPacketInfo.getType() == 2) {
|
||||||
|
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mBinding.imKlB.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
||||||
mBinding.tvUserName.setText(redPacketInfo.getNickname());
|
mBinding.tvUserName.setText(redPacketInfo.getNickname() + "的红包");
|
||||||
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
||||||
// 根据红包信息确定当前状态
|
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeOpen) {
|
||||||
// if (redPacketInfo.isHasCountdown() && redPacketInfo.isHasCondition()) {
|
mBinding.clPwd.setVisibility(View.GONE);
|
||||||
// mCurrentStatus = RedEnvelopeStatus.COUNTDOWN_AND_CONDITION;
|
mBinding.textShare.setVisibility(View.GONE);
|
||||||
// handleCountdownAndCondition();
|
} else {
|
||||||
// } else if (redPacketInfo.isHasCountdown()) {
|
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||||
// mCurrentStatus = RedEnvelopeStatus.COUNTDOWN_TO_OPEN;
|
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||||
// handleCountdown();
|
if (redPacketInfo.getType() == 2) {
|
||||||
// } else if (redPacketInfo.isHasCondition()) {
|
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||||
// mCurrentStatus = RedEnvelopeStatus.CONDITION_TO_OPEN;
|
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||||
// handleCondition();
|
} else {
|
||||||
// } else {
|
mBinding.tvKl.setVisibility(View.GONE);
|
||||||
mCurrentStatus = RedEnvelopeStatus.READY_TO_OPEN;//红包可以直接抢的
|
mBinding.imKlB.setVisibility(View.GONE);
|
||||||
handleReadyToOpen();
|
}
|
||||||
// }
|
if (redPacketInfo.getConditions() == null || redPacketInfo.getConditions().equals("0")) {
|
||||||
|
mBinding.clPwd.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||||
|
if (redPacketInfo.getConditions().equals("1")) {
|
||||||
|
mBinding.tvKl.setText("收藏房间");
|
||||||
|
} else if (redPacketInfo.getConditions().equals("2")) {
|
||||||
|
mBinding.tvKl.setText("仅麦上用户");
|
||||||
|
} else {
|
||||||
|
mBinding.tvKl.setText("收藏房间,进麦上用户");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNeedTime(long needTimes){
|
||||||
|
this.needTime = needTimes;
|
||||||
|
if (needTime > 0) {
|
||||||
|
mBinding.textPl.setText(TimeUtils.millis2String(needTime*1000, "mm:ss")+"后开启红包");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RedEnvelopeStatus getDrawTypeWithRedpacktModel(RedPacketInfo redPacketInfo) {
|
||||||
|
drawType = QXRedBagDrawTypeOpen;
|
||||||
|
if (redPacketInfo.getType() == 1) {//普通红包
|
||||||
|
drawType = QXRedBagDrawTypeOpen;
|
||||||
|
if (redPacketInfo.getCountdown() > 0) {
|
||||||
|
if (redPacketInfo.remainingTime() > 0) {
|
||||||
|
drawType = QXRedBagDrawTypeTimeDown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//收藏房间在先
|
||||||
|
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||||
|
drawType = QXRedBagDrawTypeCollect;
|
||||||
|
}
|
||||||
|
} else {//口令红包
|
||||||
|
drawType = QXRedBagDrawTypePwdSend;
|
||||||
|
if (isFromToComment) {
|
||||||
|
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||||
|
drawType = QXRedBagDrawTypeCollect;
|
||||||
|
} else {
|
||||||
|
if (redPacketInfo.canOpenNow()) {
|
||||||
|
drawType = QXRedBagDrawTypeOpen;
|
||||||
|
} else {
|
||||||
|
drawType = QXRedBagDrawTypeTimeDown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return drawType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setType(RedEnvelopeStatus type) {
|
||||||
|
this.drawType = type;
|
||||||
|
switch (type) {
|
||||||
|
case QXRedBagDrawTypeOpen:
|
||||||
|
handleReadyToOpen();
|
||||||
|
break;
|
||||||
|
case QXRedBagDrawTypeFinished:
|
||||||
|
qXRedBagDrawTypeFinished();
|
||||||
|
break;
|
||||||
|
case QXRedBagDrawTypeCollect:
|
||||||
|
qXRedBagDrawTypeCollect();
|
||||||
|
break;
|
||||||
|
case QXRedBagDrawTypeTimeDown:
|
||||||
|
qXRedBagDrawTypeTimeDown();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QXRedBagDrawTypePwdSend:
|
||||||
|
qXRedBagDrawTypePwdSend();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void qXRedBagDrawTypePwdSend() {
|
||||||
|
mBinding.imRedK.setVisibility(View.GONE);
|
||||||
|
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||||
|
mBinding.tvCk.setVisibility(View.GONE);
|
||||||
|
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.textPl.setText(setValue(QXRedBagDrawTypePwdSend));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void qXRedBagDrawTypeTimeDown() {
|
||||||
|
mBinding.imRedK.setVisibility(View.GONE);
|
||||||
|
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||||
|
mBinding.tvCk.setVisibility(View.GONE);
|
||||||
|
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.textPl.setText(setValue(QXRedBagDrawTypeTimeDown));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void qXRedBagDrawTypeCollect() {
|
||||||
|
mBinding.imRedK.setVisibility(View.GONE);
|
||||||
|
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||||
|
mBinding.tvCk.setVisibility(View.GONE);
|
||||||
|
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.textPl.setText(setValue(QXRedBagDrawTypeCollect));
|
||||||
|
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.tvPinl.setVisibility(View.GONE);
|
||||||
|
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.tvKl.setText("收藏房间");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setValue(RedEnvelopeStatus type) {
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case QXRedBagDrawTypeCollect:
|
||||||
|
return "收藏房间抢红包";
|
||||||
|
case QXRedBagDrawTypeTimeDown:
|
||||||
|
return "00:00后开启红包";
|
||||||
|
case QXRedBagDrawTypePwdSend:
|
||||||
|
return "发送评论抢红包";
|
||||||
|
default:
|
||||||
|
return "点击打开红包";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void qXRedBagDrawTypeFinished() {
|
||||||
|
mBinding.textPl.setVisibility(View.GONE);
|
||||||
|
mBinding.tvTitle.setVisibility(View.GONE);
|
||||||
|
mBinding.tvPinl.setVisibility(View.GONE);
|
||||||
|
mBinding.tvKl.setVisibility(View.GONE);
|
||||||
|
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.tvRedCount.setText("手慢了,红包被领完了");
|
||||||
|
mBinding.imRedK.setVisibility(View.GONE);
|
||||||
|
mBinding.clPwd.setVisibility(View.GONE);
|
||||||
|
mBinding.textShare.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
private void handleReadyToOpen() {
|
private void handleReadyToOpen() {
|
||||||
mBinding.textPl.setVisibility(View.GONE);
|
mBinding.textPl.setVisibility(View.GONE);
|
||||||
mBinding.tvTitle.setVisibility(View.GONE);
|
mBinding.tvTitle.setVisibility(View.GONE);
|
||||||
mBinding.tvPinl.setVisibility(View.GONE);
|
mBinding.tvPinl.setVisibility(View.GONE);
|
||||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
mBinding.tvKl.setVisibility(View.GONE);
|
||||||
mBinding.imRedK.setVisibility(View.VISIBLE);
|
mBinding.imRedK.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
// 取消倒计时,避免内存泄漏
|
||||||
|
if (countDownTimer != null) {
|
||||||
|
countDownTimer.cancel();
|
||||||
|
countDownTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeViewType(RedEnvelopeStatus type) {
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="@dimen/dp_25"
|
android:layout_marginStart="@dimen/dp_25"
|
||||||
android:layout_marginEnd="@dimen/dp_25"
|
android:layout_marginEnd="@dimen/dp_25"
|
||||||
android:layout_marginTop="@dimen/dp_156"
|
android:layout_marginTop="@dimen/dp_146"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/im_x"
|
app:layout_constraintBottom_toBottomOf="@+id/im_x"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#fff"
|
android:textColor="#fff"
|
||||||
android:textSize="@dimen/sp_13"
|
android:textSize="@dimen/sp_13"
|
||||||
tools:text="已存入金币,可直接提现"
|
tools:text="已存入金币"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_red_jb"
|
app:layout_constraintTop_toBottomOf="@+id/tv_red_jb"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_marginStart="@dimen/dp_31"
|
android:layout_marginStart="@dimen/dp_31"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
android:layout_marginEnd="@dimen/dp_10"
|
android:layout_marginEnd="@dimen/dp_10"
|
||||||
android:background="@color/color_transparent">
|
android:background="@color/color_transparent">
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -22,6 +23,16 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/im_kl_b"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
android:src="@mipmap/red_kl_b"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/im_red_close"
|
android:id="@+id/im_red_close"
|
||||||
android:layout_width="@dimen/dp_20"
|
android:layout_width="@dimen/dp_20"
|
||||||
@@ -79,7 +90,7 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/tv_red_count"
|
app:layout_constraintTop_toBottomOf="@+id/tv_red_count"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_marginTop="@dimen/dp_10"
|
android:layout_marginTop="@dimen/dp_30"
|
||||||
android:src="@mipmap/red_k"
|
android:src="@mipmap/red_k"
|
||||||
tools:ignore="ContentDescription"
|
tools:ignore="ContentDescription"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
@@ -93,21 +104,30 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_marginBottom="@dimen/dp_88"
|
android:layout_marginBottom="@dimen/dp_80"
|
||||||
android:textColor="@color/color_FFFFFFE0"
|
android:textColor="@color/color_FFFFFFE0"
|
||||||
android:textSize="@dimen/sp_23"
|
android:textSize="@dimen/sp_23"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="发布评论抢红包"
|
tools:text="发布评论抢红包"
|
||||||
android:paddingTop="@dimen/dp_9"
|
android:paddingTop="@dimen/dp_12"
|
||||||
android:gravity="top|center"/>
|
android:gravity="top|center"/>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_pwd"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/text_pl">
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_title"
|
android:id="@+id/tv_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintStart_toStartOf="@+id/text_pl"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/text_pl"
|
|
||||||
android:textColor="@color/color_FFFFFFE0"
|
android:textColor="@color/color_FFFFFFE0"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:textSize="@dimen/sp_12"
|
android:textSize="@dimen/sp_12"
|
||||||
android:text="口令红包参与条件"
|
android:text="口令红包参与条件"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
@@ -124,6 +144,7 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="发送评论:"
|
android:text="发送评论:"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:visibility="gone"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -138,6 +159,7 @@
|
|||||||
android:text="这是一个口令"
|
android:text="这是一个口令"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
/>
|
/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_ck"
|
android:id="@+id/tv_ck"
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
android:layout_marginBottom="@dimen/dp_7"
|
android:layout_marginBottom="@dimen/dp_7"
|
||||||
android:paddingTop="@dimen/dp_2"
|
android:paddingTop="@dimen/dp_2"
|
||||||
android:paddingBottom="@dimen/dp_2"
|
android:paddingBottom="@dimen/dp_2"
|
||||||
|
android:layout_marginStart="@dimen/dp_15"
|
||||||
|
android:layout_marginEnd="@dimen/dp_15"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
>
|
>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_red_bag"
|
android:id="@+id/iv_red_bag"
|
||||||
@@ -10,9 +11,50 @@
|
|||||||
android:layout_height="@dimen/dp_60"
|
android:layout_height="@dimen/dp_60"
|
||||||
android:src="@mipmap/red"
|
android:src="@mipmap/red"
|
||||||
android:scaleType="fitXY"
|
android:scaleType="fitXY"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_djs"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/iv_red_bag"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:textSize="@dimen/sp_10"
|
||||||
|
android:paddingStart="@dimen/dp_5"
|
||||||
|
android:paddingEnd="@dimen/dp_5"
|
||||||
|
android:textColor="#fff"
|
||||||
|
android:background="@drawable/bg_r6_000000"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:text="00:00" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_user_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/dp_16"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/iv_red_bag"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:textSize="@dimen/sp_12"
|
||||||
|
android:textColor="#D04248"
|
||||||
|
android:layout_marginBottom="@dimen/dp_5"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="@dimen/dp_8"
|
||||||
|
android:text="烟花易冷" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/im_list_bj"
|
||||||
|
android:layout_width="@dimen/dp_34"
|
||||||
|
android:layout_height="@dimen/dp_18"
|
||||||
|
android:src="@mipmap/red_liet_bj"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/iv_red_bag"
|
||||||
|
android:layout_marginTop="-4dp"
|
||||||
|
android:layout_marginEnd="-5dp"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user