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相关类不被混淆
|
||||
-keepclassmembers class * {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -57,6 +58,7 @@ import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.event.HourlyBean;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.event.RedBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.BackgroundManager;
|
||||
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<XLHBean> xlhMessageQueue = new ArrayList<>(); // XLH消息队列
|
||||
private final List<RedBean> redMessageQueue = new ArrayList<>(); // 红包队列
|
||||
private boolean isMqttPlaying = false; // MQTT播放状态标志
|
||||
private boolean isXlhPlaying = false; // XLH播放状态标志
|
||||
private boolean isRedPlaying = false; // XLH播放状态标志
|
||||
private final Object mqttQueueLock = new Object(); // MQTT队列同步锁
|
||||
private final Object xlhQueueLock = new Object(); // XLH队列同步锁
|
||||
private final Object RedQueueLock = new Object(); // XLH队列同步锁
|
||||
private View currentMqttView = null; // 当前正在播放的MQTT视图
|
||||
private View currentXlhView = null; // 当前正在播放的XLH视图
|
||||
private View currentRedView = null; // 当前正在播放的XLH视图
|
||||
|
||||
private final List<HourlyBean> hourlyMessageQueue = new ArrayList<>(); // 小时榜消息队列
|
||||
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消息
|
||||
private void processNextMqttMessage() {
|
||||
MqttBean.ListBean mqttBean;
|
||||
@@ -737,8 +903,9 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
showPiaoPingMessageXlh(xlhBean);
|
||||
}
|
||||
|
||||
ViewGroup decorView;
|
||||
ViewGroup decorView1;
|
||||
ViewGroup decorView;//礼物的
|
||||
ViewGroup decorView1;//巡乐会的
|
||||
ViewGroup decorView2;//红包的
|
||||
|
||||
private void showFloatingMessage(MqttBean.ListBean mqttBean) {
|
||||
|
||||
@@ -977,7 +1144,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
LogUtils.e("XLH动画执行失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}, 3000);
|
||||
}, 5000);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("XLH动画启动失败", e);
|
||||
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)
|
||||
public void onEvent(ChatInfo event) {
|
||||
|
||||
@@ -213,24 +213,6 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
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);
|
||||
// }
|
||||
|
||||
// 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://1.13.181.248","android-"+ MqttClient.generateClientId());
|
||||
// mqttConnect=MqttConnect.getInstance(this,"tcp://62.234.12.147","android-"+ MqttClient.generateClientId());
|
||||
mqttConnect.mqttClient();
|
||||
|
||||
// 每次启动应用时重置状态
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.Data;
|
||||
public class RedPacketInfo {
|
||||
private int id;
|
||||
private String remark;// 备注
|
||||
private String password;// 开始时间
|
||||
private String password;// 口令
|
||||
private int countdown;//0:立即开抢,其他:倒计时抢
|
||||
private String conditions;//条件
|
||||
private String total_amount;//红包总金额
|
||||
@@ -27,26 +27,26 @@ public class RedPacketInfo {
|
||||
|
||||
private boolean isAvailable;//是否可以领取
|
||||
|
||||
private String left_amount;//33.00",
|
||||
private String left_amount;//33.00",
|
||||
private int left_count;
|
||||
private long end_time;
|
||||
private long createtime;
|
||||
private String updatetime;
|
||||
|
||||
private int is_qiang;
|
||||
|
||||
// 获取剩余时间
|
||||
public long remainingTime() {
|
||||
long needTime = 0;
|
||||
// 获取当前时间戳(毫秒)
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
long currentTimeMillis = System.currentTimeMillis() / 1000;
|
||||
// 计算剩余时间
|
||||
needTime = start_time - currentTimeMillis;
|
||||
return needTime;
|
||||
}
|
||||
|
||||
// 判断红包是否可以领取
|
||||
public boolean canOpenNow(){
|
||||
return remainingTime()<=0;
|
||||
public boolean canOpenNow() {
|
||||
return remainingTime() <= 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RedpacketDetail {
|
||||
private RedPacketInfo redPacket_info;
|
||||
private RedPacketInfo redpacket_info;
|
||||
|
||||
private List<Records> records;
|
||||
private MyRecord my_record;
|
||||
|
||||
@@ -64,6 +64,7 @@ public class UserInfo implements Serializable {
|
||||
|
||||
private int heartId; // "heartId": 4,
|
||||
private int heartNum; //
|
||||
private String red_num;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,13 +2,16 @@ package com.xscm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/2
|
||||
*@description: 巡乐会开始后推送的信息
|
||||
*/
|
||||
@Data
|
||||
public class XLHBean {
|
||||
public class XLHBean implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String text;
|
||||
private String room_id;
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@ package com.xscm.moduleutil.event;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 小时榜飘屏
|
||||
*/
|
||||
@Data
|
||||
public class HourlyBean {
|
||||
public class HourlyBean implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String room_id;
|
||||
private String room_name;
|
||||
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 {
|
||||
|
||||
READY_TO_OPEN, // 可以直接打开
|
||||
COUNTDOWN_TO_OPEN, // 倒计时后可打开
|
||||
CONDITION_TO_OPEN, // 满足条件后可打开
|
||||
COUNTDOWN_AND_CONDITION // 先倒计时,再满足条件后可打开
|
||||
/// 打开红包
|
||||
QXRedBagDrawTypeOpen,
|
||||
/// 仅倒计时
|
||||
QXRedBagDrawTypeTimeDown,
|
||||
/// 仅收藏房间
|
||||
QXRedBagDrawTypeCollect,
|
||||
/// 手慢了被领完了
|
||||
QXRedBagDrawTypeFinished,
|
||||
/// 发送评论领红包
|
||||
QXRedBagDrawTypePwdSend,
|
||||
}
|
||||
|
||||
@@ -387,6 +387,10 @@ public interface ApiServer {
|
||||
@POST(Constants.POST_GZ)
|
||||
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
|
||||
@POST(Constants.ACCEPT_PK)
|
||||
Call<BaseModel<String>> acceptPk(@Field("pk_id") String pk_id, @Field("type") String type);
|
||||
|
||||
@@ -3429,6 +3429,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) {
|
||||
sApiServer.acceptPk(pk_id, type).enqueue(new Callback<BaseModel<String>>() {
|
||||
@Override
|
||||
@@ -3653,7 +3667,6 @@ public class RetrofitClient {
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
ToastUtils.showShort(string.getMsg());
|
||||
} else {
|
||||
ToastUtils.showShort(string.getMsg());
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ public class MqttConnect {
|
||||
public static String shutdown = "";
|
||||
public static String update_app = "";
|
||||
public static String qx_hour_ranking = "";
|
||||
|
||||
public static String qx_redpacket_arrive="";//红包飘屏的主题
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
String[] topic;
|
||||
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
|
||||
// qx_hour_ranking = "qx_hour_ranking";
|
||||
qx_hour_ranking = "qx_hour_ranking";
|
||||
qx_redpacket_arrive="qx_redpacket_arrive";
|
||||
|
||||
ArrayList<String> topicList = new ArrayList<>();
|
||||
topicList.add(shutdown);
|
||||
topicList.add(update_app);
|
||||
topicList.add(qx_hour_ranking);
|
||||
topicList.add(qx_redpacket_arrive);
|
||||
topic = topicList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@@ -87,6 +91,7 @@ public class MqttConnect {
|
||||
sub(shutdown);
|
||||
sub(update_app);
|
||||
sub(qx_hour_ranking);
|
||||
sub(qx_redpacket_arrive);
|
||||
// uiTip("MQTT连接成功");
|
||||
}catch (MqttException e){
|
||||
// uiTip("MQTT连接失败,准备重连。。。:"+e.getMessage());
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.orhanobut.logger.Logger;
|
||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.event.HourlyBean;
|
||||
import com.xscm.moduleutil.event.RedBean;
|
||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
@@ -63,9 +64,49 @@ public class MqttInitCallback implements MqttCallback {
|
||||
receiveXlhMessage(messageStr);
|
||||
}else if (topic.equals("qx_hour_ranking")){
|
||||
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) {
|
||||
try {
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
|
||||
@@ -2,12 +2,16 @@ package com.xscm.moduleutil.utils;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 红包管理器单例类
|
||||
@@ -20,7 +24,7 @@ public class 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);
|
||||
}
|
||||
|
||||
// 在添加数据后启动定时器(如果尚未启动)
|
||||
startCheckTimer();
|
||||
if (this.delegate != null && this.delegate instanceof QXRedPacketManagerDelegate) {
|
||||
((QXRedPacketManagerDelegate) this.delegate).onRedPacketsAdded(redPackets, this.redPackets.size());
|
||||
}
|
||||
@@ -70,6 +76,8 @@ public class QXRedPacketManager {
|
||||
|
||||
this.redPackets.put(redPacket.getRedpacket_id(), redPacket);
|
||||
|
||||
// 在添加数据后启动定时器(如果尚未启动)
|
||||
startCheckTimer();
|
||||
if (this.delegate != null && this.delegate instanceof QXRedPacketManagerDelegate) {
|
||||
((QXRedPacketManagerDelegate) this.delegate).onRedPacketAdded(redPacket, this.redPackets.size());
|
||||
}
|
||||
@@ -111,6 +119,10 @@ public class QXRedPacketManager {
|
||||
* 开始检查定时器
|
||||
*/
|
||||
public void startCheckTimer() {
|
||||
// 如果定时器已经在运行,直接返回
|
||||
if (checkTimerRunnable != null && checkTimerHandler != null) {
|
||||
return;
|
||||
}
|
||||
if (checkTimerRunnable == null) {
|
||||
checkTimerRunnable = new Runnable() {
|
||||
@Override
|
||||
@@ -128,9 +140,35 @@ public class QXRedPacketManager {
|
||||
* 检查并更新红包状态
|
||||
*/
|
||||
private void checkAndUpdateRedPackets() {
|
||||
// 添加空值检查
|
||||
if (this.redPackets == null || this.redPackets.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<RedPacketInfo> packets = new ArrayList<>(this.redPackets.values());
|
||||
|
||||
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();
|
||||
packet.setAvailable(packet.canOpenNow());
|
||||
|
||||
@@ -140,12 +178,6 @@ public class QXRedPacketManager {
|
||||
((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() {
|
||||
this.redPackets.clear();
|
||||
endCheckTimer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,24 +212,6 @@ public class QXRedPacketManager {
|
||||
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 剩余数量
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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_LIKE_LIST = "/api/UserZone/like_list";//获取点赞列表
|
||||
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 UP_ALBUM = "/api/User/add_album_content";//添加相册图片
|
||||
public static final String MOVE_ALBUM = "/api/User/move_album_images";//移动相册图片
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="rectangle"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/transparent" />
|
||||
<solid android:color="#40000000" />
|
||||
<corners android:radius="@dimen/dp_6"/>
|
||||
</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
|
||||
public void redPacketDetail(RedpacketDetail redpacketDetail) {
|
||||
if (redpacketDetail != null) {
|
||||
ImageUtils.loadHeadCC(redpacketDetail.getMy_record().getAvatar(), mBinding.userAvatar);
|
||||
mBinding.userName.setText(redpacketDetail.getMy_record().getNickname());
|
||||
mBinding.tvRedTitle.setText(redpacketDetail.getRedPacket_info().getRemark());
|
||||
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());
|
||||
|
||||
ImageUtils.loadHeadCC(redpacketDetail.getRedpacket_info().getAvatar(), mBinding.userAvatar);
|
||||
mBinding.userName.setText(redpacketDetail.getRedpacket_info().getNickname());
|
||||
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.tvLq.setText(redpacketDetail.getRecords().size() + "/" + redpacketDetail.getRedpacket_info().getTotal_count());
|
||||
redAdapter.setNewData(redpacketDetail.getRecords());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ import java.util.stream.Collectors
|
||||
|
||||
@Route(path = ARouteConstants.ROOM_DETAILS)
|
||||
class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
RoomContacts.View, PermissionCallbacks, OnMessageReceivedListener {
|
||||
RoomContacts.View, PermissionCallbacks, OnMessageReceivedListener, QXRedPacketManager.QXRedPacketManagerDelegate {
|
||||
private var roomFragment: RoomFragment? = null
|
||||
var commonPageAdapter: CommonPageAdapter? = null
|
||||
private var mRoomBean: RoomBean? = null
|
||||
@@ -165,6 +165,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
private var isMinimized = false
|
||||
private var appStateListener: AppStateListener? = null
|
||||
|
||||
private var qxRedPacketManager: QXRedPacketManager? = null
|
||||
|
||||
|
||||
// 添加弹框到管理列表
|
||||
fun addActiveDialog(dialog: DialogInterface) {
|
||||
activeDialogs.add(dialog)
|
||||
@@ -206,37 +209,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// }
|
||||
// }
|
||||
|
||||
private fun handleRestoreFromMinimize(intent: Intent) {
|
||||
// 如果是从桌面启动且之前有最小化的房间
|
||||
// if (Intent.ACTION_MAIN.equals(intent.getAction())
|
||||
// && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) {
|
||||
//
|
||||
// SharedPreferences prefs = getSharedPreferences("room_minimize_state", Context.MODE_PRIVATE);
|
||||
// boolean isMinimized = prefs.getBoolean("is_minimized", false);
|
||||
//
|
||||
// if (isMinimized) {
|
||||
// // 恢复到最小化的房间
|
||||
// String minimizedRoomId = prefs.getString(PREF_MINIMIZED_ROOM, null);
|
||||
// if (minimizedRoomId != null && minimizedRoomId.equals(roomId)) {
|
||||
// // 当前就是最小化的房间,直接恢复
|
||||
// resumeRoomFromMinimize();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 其他情况按正常流程处理
|
||||
|
||||
val newRoomId = intent.getStringExtra("roomId")
|
||||
val newPassword = intent.getStringExtra("password")
|
||||
|
||||
if (!TextUtils.isEmpty(newRoomId) && newRoomId != roomId) {
|
||||
// switchToRoom(newRoomId, newPassword);
|
||||
releaseRoom()
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun resumeRoomFromMinimize() {
|
||||
// 从最小化状态恢复房间
|
||||
@@ -417,7 +389,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
val bottomSheet = ExitRoomBottomSheet.newInstance(false, true, true);
|
||||
bottomSheet.setOnOptionSelectedListener(object : OnOptionSelectedListener {
|
||||
override fun onMinimize() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun onExitRoom() {
|
||||
@@ -617,6 +588,12 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
V2TIMManager.getInstance().addIMSDKListener(imSdkListener);
|
||||
// 在 RoomActivity 中获取单例实例
|
||||
// 在onCreate中初始化红包管理器实例,以便在整个Activity生命周期中使用
|
||||
qxRedPacketManager = QXRedPacketManager.getInstance()
|
||||
// 获取单例实例并设置委托
|
||||
qxRedPacketManager!!.setDelegate(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -626,7 +603,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
override fun onConnectSuccess() { //重连成功
|
||||
if (CommonAppContext.getInstance().playId != null) {
|
||||
LogUtils.e("@@@", "重连成功")
|
||||
LogUtils.e("@@@", ""+CommonAppContext.getInstance().playId)
|
||||
LogUtils.e("@@@", "" + CommonAppContext.getInstance().playId)
|
||||
RetrofitClient.getInstance().roomUserReconnect(CommonAppContext.getInstance().playId)
|
||||
}
|
||||
}
|
||||
@@ -815,6 +792,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
if (mRoomInfoResp == null) {
|
||||
// 使用Handler确保在主线程中调用
|
||||
MvpPre!!.getRoomIn(roomId, password)
|
||||
|
||||
}
|
||||
MvpPre!!.getRoomOnline(roomId, "1", "10")
|
||||
}
|
||||
@@ -858,14 +836,14 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
// TODO: 发红包
|
||||
fun redDialogView(){
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).navigation();
|
||||
|
||||
RedBagSendDialog(this).show()
|
||||
// 在Activity中使用
|
||||
fun redDialogView() {
|
||||
RedBagSendDialog(this, roomId).show()
|
||||
}
|
||||
|
||||
var redEnvelopesFragment: RedEnvelopesFragment? = null
|
||||
var redListDialog: RedListDialog? = null
|
||||
var redPacketInfo: RedPacketInfo? = null
|
||||
|
||||
override fun initView() {
|
||||
super.initView()
|
||||
floatingMagnetView = findViewById(R.id.flaoat)
|
||||
@@ -910,9 +888,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
layoutParams.height = SystemUtils.getWidth(74) // 示例高度
|
||||
mBinding!!.roomTop.root.layoutParams = layoutParams
|
||||
|
||||
// MP4PlaybackCallback mp4PlaybackCallback=MP4PlaybackCallback.getInstance();
|
||||
// mp4PlaybackCallback.setAvatarFrameView(mBinding.svgaGift);
|
||||
// mBinding.svgaGift.setAnimListener(mp4PlaybackCallback);
|
||||
mBinding!!.xlhIm.setOnClickListener {
|
||||
val fm = supportFragmentManager
|
||||
if (fm != null && !fm.isDestroyed) {
|
||||
@@ -931,8 +906,24 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
mBinding!!.drvRed.visibility = View.GONE
|
||||
mBinding!!.redBj.setOnClickListener {
|
||||
val redListDialog = RedListDialog(this)
|
||||
redListDialog.show()
|
||||
redListDialog = RedListDialog(this)
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1087,8 +1078,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private fun enterLandscapeMode() {
|
||||
isFullScreen = true
|
||||
|
||||
@@ -1201,51 +1190,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
// 隐藏退出按钮
|
||||
ivExitFullscreen!!.visibility = View.GONE
|
||||
// upHeight()
|
||||
// initPublicScreenFragment()
|
||||
// if (!isFinishing && !isDestroyed) {
|
||||
// resetFragment()
|
||||
// upHeight()
|
||||
// } else {
|
||||
// Log.e("Fragment", "Fragment transaction skipped due to state loss.")
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// isFullScreen = false;
|
||||
// // 恢复系统UI
|
||||
// View decorView = getWindow().getDecorView();
|
||||
//// decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
// decorView.setSystemUiVisibility(
|
||||
// View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
// );
|
||||
// // 设置回竖屏
|
||||
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
// // 找到 fl_screenshare 并移回原父容器
|
||||
// FrameLayout fl_screenshare = findViewById(R.id.fl_screenshare);
|
||||
// if (fl_screenshare != null) {
|
||||
// safelyMoveViewToParent(fl_screenshare, fullScreenContainer);
|
||||
//// ViewParent parent = fl_screenshare.getParent();
|
||||
//// if (parent instanceof ViewGroup) {
|
||||
//// ((ViewGroup) parent).removeView(fl_screenshare);
|
||||
//// }
|
||||
//// // 添加到全屏容器
|
||||
//// fullScreenContainer.addView(fl_screenshare);
|
||||
// // 找到原始父容器并重新添加
|
||||
//// FrameLayout originalParent = findViewById(R.id.fullscreen_container); // 或者你实际的容器
|
||||
//// if (originalParent != null) {
|
||||
//// originalParent.removeView(fl_screenshare); // 防止重复添加
|
||||
//// }
|
||||
//
|
||||
//// floatingMagnetView.addView(fl_screenshare);
|
||||
// }
|
||||
// // 恢复界面
|
||||
// fullScreenContainer.setVisibility(View.GONE);
|
||||
// floatingMagnetView.setVisibility(View.VISIBLE);
|
||||
// ivQuan.setVisibility(View.VISIBLE);
|
||||
// ivExitFullscreen.setVisibility(View.GONE); // 隐藏退出按钮
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
@@ -1595,18 +1539,12 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
xlhDjs(messageEvent.text.end_time)
|
||||
|
||||
// if (messageEvent.getText().getXlh_data() != null) {
|
||||
// if (messageEvent.getText().getXlh_data().getStatus() == 1) {
|
||||
// mBinding.xlhRk.setVisibility(View.VISIBLE);
|
||||
// xlhDjs(messageEvent.getText().getEnd_time());
|
||||
// } else {
|
||||
// mBinding.xlhRk.setVisibility(View.GONE);
|
||||
// releaseCountDownTimer1();
|
||||
// }
|
||||
// }
|
||||
} else if (msgType == 1060) {
|
||||
qxRedPacketManager!!.addRedPacket(messageEvent.text.redpacketInfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var endTime: Long = 0
|
||||
|
||||
private fun xlhDjs(endTimeStr: String?) {
|
||||
@@ -1735,10 +1673,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// ivSoundEffects(false)
|
||||
// }
|
||||
|
||||
if ("9" == toPitNumber && messageEvent.text.user_id .equals(SpUtil.getUserId().toString())) {
|
||||
if ("9" == toPitNumber && messageEvent.text.user_id.equals(SpUtil.getUserId().toString())) {
|
||||
mBinding!!.roomTop.rl.visibility = View.VISIBLE
|
||||
ivSoundEffects(true)
|
||||
}else{
|
||||
} else {
|
||||
if (customMusicFloatingView != null) {
|
||||
customMusicFloatingView!!.destroy()
|
||||
AgoraManager.getInstance(this@RoomActivity).desMusic()
|
||||
@@ -2141,31 +2079,21 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
private fun handleMsgType1024(messageEvent: RoomMessageEvent, text: T?) {
|
||||
if (text == null || mRoomInfoResp == null || mRoomInfoResp!!.room_info == null) return
|
||||
|
||||
try {
|
||||
// 初始化 room_auction 如果为 null
|
||||
if (mRoomInfoResp!!.room_auction == null) {
|
||||
mRoomInfoResp!!.room_auction = RoomAuction()
|
||||
}
|
||||
|
||||
// 安全地处理 auction_list
|
||||
val auctionList = mRoomInfoResp!!.room_auction.auction_list ?: ArrayList()
|
||||
auctionList.clear()
|
||||
|
||||
// 安全地添加新数据
|
||||
text.auction_list?.let { auctionList.addAll(it) }
|
||||
|
||||
mRoomInfoResp!!.room_auction.auction_list = auctionList
|
||||
|
||||
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
||||
roomFragment!!.handleAuctionMessageEvent(messageEvent)
|
||||
} catch (e: Exception) {
|
||||
LogUtils.e("handleMsgType1024 error: " + e.message)
|
||||
if (text == null || mRoomInfoResp == null || mRoomInfoResp!!.room_auction == null) return
|
||||
if (mRoomInfoResp!!.room_auction.auction_list != null) {
|
||||
mRoomInfoResp!!.room_auction.auction_list.clear()
|
||||
}
|
||||
if (mRoomInfoResp!!.room_auction.auction_list != null) {
|
||||
mRoomInfoResp!!.room_auction.auction_list.addAll(text.auction_list)
|
||||
} else {
|
||||
mRoomInfoResp!!.room_auction.auction_list = ArrayList()
|
||||
// mRoomInfoResp.getRoom_auction().getAuction_list().addAll(text.getAuction_list());
|
||||
}
|
||||
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
||||
roomFragment!!.handleAuctionMessageEvent(messageEvent)
|
||||
// roomFragment.updateSeatViewExchangedWithPitArray(mRoomInfoResp);
|
||||
}
|
||||
|
||||
|
||||
private fun handleMsgType1020(messageEvent: RoomMessageEvent, text: T?) {
|
||||
if (text == null) return
|
||||
|
||||
@@ -2179,8 +2107,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
if (text.fromUserInfo.user_id == SpUtil.getUserId()) {
|
||||
LogUtils.e("退出房间")
|
||||
// MvpPre!!.quitRoom(roomId, SpUtil.getUserId().toString() + "")
|
||||
performExitRoom(1)
|
||||
MvpPre!!.quitRoom(roomId, SpUtil.getUserId().toString() + "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2596,6 +2523,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
||||
}
|
||||
|
||||
fun setUserInfo() {
|
||||
mRoomInfoResp!!.user_info.is_collect = 1
|
||||
}
|
||||
|
||||
/**
|
||||
* 特效设置
|
||||
*/
|
||||
@@ -3221,6 +3152,13 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
etContent.setText("")
|
||||
countDownTimer()
|
||||
if (redEnvelopesFragment != null) {
|
||||
redEnvelopesFragment = RedEnvelopesFragment(this@RoomActivity)
|
||||
redEnvelopesFragment!!.setIsCollectedRoom(mRoomUserBean!!.is_collect == 1)
|
||||
redEnvelopesFragment!!.setFromToComment(true)
|
||||
redEnvelopesFragment!!.setRedPacket(redPacketInfo)
|
||||
redEnvelopesFragment!!.show()
|
||||
}
|
||||
dialog.dismiss()
|
||||
})
|
||||
|
||||
@@ -3263,11 +3201,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun roomInfoEvent(messageEvent: UserInfo) {
|
||||
// mBinding.llInput.setVisibility(View.VISIBLE);
|
||||
// mBinding.inputMenu1.bringToFront(); // 强制将该 View 置于最上层
|
||||
// mBinding.inputMenu1.show();
|
||||
// mBinding.inputMenu1.setText("@" + messageEvent.getNickname());
|
||||
inputSting = "@" + messageEvent.nickname
|
||||
if (messageEvent != null && messageEvent.red_num != null) {
|
||||
inputSting = messageEvent.red_num
|
||||
} else {
|
||||
inputSting = "@" + messageEvent.nickname
|
||||
}
|
||||
dialogDismiss()
|
||||
}
|
||||
|
||||
@@ -3517,10 +3455,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
}
|
||||
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 != roomId){
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(applicationContext,mRoomInfoResp!!.room_info.head_line.room_id,"")
|
||||
}else{
|
||||
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) {
|
||||
RoomManager.getInstance()
|
||||
.fetchRoomDataAndEnter(applicationContext, mRoomInfoResp!!.room_info.head_line.room_id, "")
|
||||
} else {
|
||||
com.blankj.utilcode.util.ToastUtils.showLong("您就在当前房间")
|
||||
}
|
||||
}
|
||||
@@ -3737,6 +3676,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// }
|
||||
// }
|
||||
|
||||
MvpPre!!.roomRedPackets(roomId);
|
||||
|
||||
if (isInBackground) {
|
||||
isInBackground = false
|
||||
MvpPre!!.postRoomInfo(CommonAppContext.getInstance().playId)
|
||||
@@ -3958,7 +3899,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
|
||||
val roomBean = resp.room_info
|
||||
if (roomBean!!.type_id.equals("6")){
|
||||
if (roomBean!!.type_id.equals("6")) {
|
||||
|
||||
// upHeight()
|
||||
initPublicScreenFragment()
|
||||
@@ -4139,7 +4080,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
override fun quitRoom() {
|
||||
|
||||
}
|
||||
|
||||
//退出房间进行销毁
|
||||
@@ -4221,8 +4161,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
override fun findRoom() {
|
||||
}
|
||||
|
||||
override fun roomEit() {
|
||||
performExitRoom(1)
|
||||
override fun roomRedPackets(list: MutableList<RedPacketInfo>?) {
|
||||
if (list != null) {
|
||||
qxRedPacketManager!!.addRedPackets(list!!)
|
||||
}
|
||||
}
|
||||
|
||||
private fun queren1(nickname: String) {
|
||||
@@ -4264,6 +4206,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
clearMinimizeState()
|
||||
cleanupResources()
|
||||
}
|
||||
if (qxRedPacketManager != null) {
|
||||
qxRedPacketManager!!.endCheckTimer();
|
||||
}
|
||||
// 确保父类的 onDestroy 被调用
|
||||
super.onDestroy()
|
||||
}
|
||||
@@ -4582,5 +4527,96 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
private val AUDIO_PERMISSIONS = arrayOf(Manifest.permission.RECORD_AUDIO)
|
||||
}
|
||||
|
||||
override fun onRedPacketsAdded(redPackets: MutableList<RedPacketInfo>?, remainingCount: Int) {
|
||||
// 处理添加红包列表的逻辑
|
||||
if (redPackets!!.isNotEmpty()) {
|
||||
mBinding!!.drvRed.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
||||
} else {
|
||||
mBinding!!.drvRed.visibility = View.GONE
|
||||
mBinding!!.redNum.visibility = View.GONE
|
||||
qxRedPacketManager!!.removeAllRedPackets()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onRedPacketAdded(redPacket: RedPacketInfo?, remainingCount: Int) {
|
||||
// 处理添加单个红包的逻辑
|
||||
if (redPacket != null) {
|
||||
mBinding!!.drvRed.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
// 处理红包状态更新的逻辑
|
||||
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));
|
||||
baseViewHolder.setText(R.id.tv_user_name, redBean.getNickname());
|
||||
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) {
|
||||
|
||||
@@ -1,20 +1,116 @@
|
||||
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.BaseViewHolder;
|
||||
import com.example.moduleroom.R;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 红包的列表适配器
|
||||
*/
|
||||
public class RedBagAdapter extends BaseQuickAdapter<RedPacketInfo, BaseViewHolder> {
|
||||
private Map<Integer,View> viewMap;
|
||||
public RedBagAdapter() {
|
||||
super(R.layout.item_red_bag);
|
||||
viewMap=new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
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.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.example.moduleroom.R;
|
||||
import com.example.moduleroom.adapter.RedBagAdapter;
|
||||
import com.example.moduleroom.databinding.DialogRedListBinding;
|
||||
import com.example.moduleroom.fragment.RedEnvelopesFragment;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.utils.QXRedPacketManager;
|
||||
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) {
|
||||
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
// 添加获取适配器的方法
|
||||
public RedBagAdapter getAdapter() {
|
||||
return redBagAdapter;
|
||||
}
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_red_list;
|
||||
@@ -121,27 +119,21 @@ public class RedListDialog extends BaseDialog<DialogRedListBinding> {
|
||||
|
||||
redBagAdapter.setNewData(qxRedPacketManager.getAllRedPackets()) ;
|
||||
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() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.moduleroom.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
@@ -8,21 +9,29 @@ import android.view.WindowManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.example.moduleroom.R;
|
||||
import com.example.moduleroom.activity.RoomActivity;
|
||||
import com.example.moduleroom.databinding.FragmentRedEnvelopesBinding;
|
||||
import com.xscm.moduleutil.bean.RedPackGrab;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.event.RedEnvelopeStatus;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.QXRedPacketManager;
|
||||
import com.xscm.moduleutil.view.QXRedBagSendView;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
import com.xscm.moduleutil.widget.floatingView.IFloatingView;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.xscm.moduleutil.event.RedEnvelopeStatus.*;
|
||||
|
||||
/**
|
||||
* @author xscm
|
||||
* @ClassName RedEnvelopesFragment
|
||||
@@ -31,12 +40,28 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding> {
|
||||
private RedEnvelopeStatus mCurrentStatus;
|
||||
private RedPacketInfo mRedPacketInfo;
|
||||
private RedEnvelopeStatus drawType;
|
||||
public RedPacketInfo mRedPacketInfo;
|
||||
public boolean isCollectedRoom;//是否收藏房间
|
||||
|
||||
public long needTime;// 倒计时
|
||||
public boolean isFromToComment;//是否是发送评论地方过来
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
public RedEnvelopesFragment(@NonNull @NotNull Context context) {
|
||||
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
|
||||
public void initData() {
|
||||
@@ -49,7 +74,8 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
// 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() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -73,15 +99,19 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RedPackGrab redPackGrab) {
|
||||
if (redPackGrab!=null){
|
||||
if (redPackGrab.getCode()==1){
|
||||
if (redPackGrab != null) {
|
||||
if (redPackGrab.getCode() == 1) {
|
||||
mRedPacketInfo.setIs_qiang(1);
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
}else if (redPackGrab.getCode()==2){
|
||||
dismiss();
|
||||
} else if (redPackGrab.getCode() == 2) {
|
||||
ToastUtils.showShort("您已经抢过红包了");
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
}else {
|
||||
dismiss();
|
||||
} else {
|
||||
snatched();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -89,7 +119,7 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
|
||||
// QXRedBagSendView redBagView = new QXRedBagSendView(getContext());
|
||||
// redBagView.showInView((ViewGroup) getWindow().getDecorView());
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.tvCk.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -98,9 +128,42 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
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() {
|
||||
mBinding.tvRedCount.setText("手慢,没有抢到");
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
@@ -109,7 +172,6 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,30 +181,178 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
|
||||
public void setRedPacket(RedPacketInfo redPacketInfo) {
|
||||
this.mRedPacketInfo = redPacketInfo;
|
||||
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
||||
mBinding.tvUserName.setText(redPacketInfo.getNickname());
|
||||
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
||||
// 根据红包信息确定当前状态
|
||||
// if (redPacketInfo.isHasCountdown() && redPacketInfo.isHasCondition()) {
|
||||
// mCurrentStatus = RedEnvelopeStatus.COUNTDOWN_AND_CONDITION;
|
||||
// handleCountdownAndCondition();
|
||||
// } else if (redPacketInfo.isHasCountdown()) {
|
||||
// mCurrentStatus = RedEnvelopeStatus.COUNTDOWN_TO_OPEN;
|
||||
// handleCountdown();
|
||||
// } else if (redPacketInfo.isHasCondition()) {
|
||||
// mCurrentStatus = RedEnvelopeStatus.CONDITION_TO_OPEN;
|
||||
// handleCondition();
|
||||
// } else {
|
||||
mCurrentStatus = RedEnvelopeStatus.READY_TO_OPEN;//红包可以直接抢的
|
||||
handleReadyToOpen();
|
||||
// }
|
||||
setType(getDrawTypeWithRedpacktModel(redPacketInfo));
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
||||
mBinding.tvUserName.setText(redPacketInfo.getNickname() + "的红包");
|
||||
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
||||
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeOpen) {
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
mBinding.textShare.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
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() {
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
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_marginStart="@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_constraintBottom_toBottomOf="@+id/im_x"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#fff"
|
||||
android:textSize="@dimen/sp_13"
|
||||
tools:text="已存入金币,可直接提现"
|
||||
tools:text="已存入金币"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_red_jb"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="@dimen/dp_31"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:background="@color/color_transparent">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -22,6 +23,16 @@
|
||||
app:layout_constraintStart_toStartOf="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
|
||||
android:id="@+id/im_red_close"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
@@ -79,7 +90,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_red_count"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:src="@mipmap/red_k"
|
||||
tools:ignore="ContentDescription"
|
||||
android:visibility="gone"/>
|
||||
@@ -93,51 +104,62 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginBottom="@dimen/dp_88"
|
||||
android:layout_marginBottom="@dimen/dp_80"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
android:textSize="@dimen/sp_23"
|
||||
android:textStyle="bold"
|
||||
tools:text="发布评论抢红包"
|
||||
android:paddingTop="@dimen/dp_9"
|
||||
android:paddingTop="@dimen/dp_12"
|
||||
android:gravity="top|center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_pwd"
|
||||
android:layout_width="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:textSize="@dimen/sp_12"
|
||||
android:text="口令红包参与条件"
|
||||
android:gravity="center"
|
||||
/>
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text_pl">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_pinl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="发送评论:"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_kl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_pinl"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_pinl"
|
||||
android:textColor="#FFCE47"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="这是一个口令"
|
||||
android:gravity="center"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:textSize="@dimen/sp_12"
|
||||
android:text="口令红包参与条件"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_pinl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="发送评论:"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_kl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_pinl"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_pinl"
|
||||
android:textColor="#FFCE47"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="这是一个口令"
|
||||
android:gravity="center"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_ck"
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
android:layout_marginBottom="@dimen/dp_7"
|
||||
android:paddingTop="@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:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
@@ -3,16 +3,58 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
>
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/iv_red_bag"
|
||||
android:layout_width="@dimen/dp_60"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
android:src="@mipmap/red"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="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>
|
||||
Reference in New Issue
Block a user