1:完成cp效果展示,
This commit is contained in:
@@ -122,6 +122,7 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
viewHolder.integral = (TextView) convertView.findViewById(R.id.integral);
|
||||
viewHolder.im_heart = (ImageView) convertView.findViewById(R.id.im_heartssss);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (GiftPackAdapter.ViewHolder) convertView.getTag();
|
||||
@@ -168,5 +169,6 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
public TextView tv_gift_change_love_values;
|
||||
public ImageView ivDownOn;
|
||||
public ConstraintLayout cl_iv_down_on;
|
||||
public ImageView im_heart;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xscm.moduleutil.adapter;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
@@ -122,14 +123,16 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.item_gift_room, parent, false);
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
viewHolder.tv_gift_name = (TextView) convertView.findViewById(R.id.tv_gift_name);
|
||||
viewHolder.tv_gift_price = (TextView) convertView.findViewById(R.id.tv_gift_price);
|
||||
viewHolder.iv_gift_pic = (ImageView) convertView.findViewById(R.id.iv_gift_pic);
|
||||
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
|
||||
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
viewHolder.iv_gift_select= (ImageView) convertView.findViewById(R.id.iv_gift_select);
|
||||
|
||||
// im_heart现在位于顶层布局中
|
||||
viewHolder.im_heart = (ImageView) convertView.findViewById(R.id.im_heartssss);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
@@ -146,7 +149,15 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
if (giftModel.getIs_lock()==0){
|
||||
viewHolder.iv_gift_select.setVisibility(GONE);
|
||||
}else {
|
||||
viewHolder.iv_gift_select.setVisibility(View.VISIBLE);
|
||||
viewHolder.iv_gift_select.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
if (giftModel.getIs_cp()==0) {//这是cp礼物
|
||||
viewHolder.im_heart.setVisibility(GONE);
|
||||
}else {
|
||||
if (viewHolder.im_heart != null) {
|
||||
viewHolder.im_heart.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 在给View绑定显示的数据时,计算正确的position = position + curIndex * pageSize,
|
||||
@@ -214,6 +225,7 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
public TextView tv_gift_change_love_values;
|
||||
public ImageView ivDownOn;
|
||||
public ImageView iv_gift_select;
|
||||
public ImageView im_heart;
|
||||
public ConstraintLayout cl_iv_down_on;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 送礼后的成功回调
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RoomGiftData extends BaseEvent {
|
||||
private int gift_total;
|
||||
|
||||
private List<GiftUserData> gift_user_data;
|
||||
|
||||
private CpType cp_type;
|
||||
|
||||
@Data
|
||||
public static class GiftUserData {
|
||||
private String user_id;//受理人id
|
||||
private String gift_price;//礼物价格
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class CpType {
|
||||
private int cp_type;//0:不处理 1:表明心意 2:组成cp
|
||||
private String text;//发送方弹起的信息
|
||||
private String text1;//接收方弹起的信息
|
||||
private int gift_id;//礼物id
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.room.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RoomMessageEvent {
|
||||
public class RoomMessageEvent extends BaseEvent {
|
||||
private int MsgType; // 消息类型,如 QXRoomMessageTypeJoin
|
||||
private String RoomId; // 房间 ID
|
||||
private T Text; // 携带的数据对象
|
||||
@@ -100,12 +103,15 @@ public class RoomMessageEvent {
|
||||
|
||||
private SingerInfo.SongInfo song_info;
|
||||
private SingerInfo.SongInfo next_song_info;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class text {
|
||||
private long position;
|
||||
private int is_mute;
|
||||
private RoomGiftData.CpType cp_type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ public class RoonGiftModel {
|
||||
private int activities_id;//4:盲盒 ;5:天空之境;
|
||||
private int gift_bag;//10:天空之境 11:岁月之城 12:时空之巅
|
||||
private int is_lock;//爵位礼物 0:不锁 1:锁
|
||||
|
||||
private int is_cp;//1:是 0:不是
|
||||
public boolean isCan_send_self() {
|
||||
if ( isManghe()) {
|
||||
return true;
|
||||
|
||||
@@ -89,6 +89,10 @@ public class EMMessageInfo implements MultiItemEntity {
|
||||
public static final int QXRoomMessageTypeMuteRemoteAudio = 125;
|
||||
///小黑屋 关麦
|
||||
public static final int QXRoomMessageTypeMuteLocalAudio = 126;
|
||||
public static final int QXRoomMessageTypeCPDx = 130;//心动礼物,单向发送
|
||||
public static final int QXRoomMessageTypeCPSx = 131;//心动礼物,双向发送
|
||||
|
||||
|
||||
|
||||
/// 交友房阶段发生变化
|
||||
public static final int QXRoomMessageTypeRoomFriendPartDidChanged = 1049;
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
|
||||
public class BaseCpDialog extends Dialog {
|
||||
|
||||
private String title;
|
||||
private String message;
|
||||
private String positiveButtonText;
|
||||
private String negativeButtonText;
|
||||
private View.OnClickListener positiveButtonClickListener;
|
||||
private View.OnClickListener negativeButtonClickListener;
|
||||
private boolean isCountdownEnabled = false; // 是否启用倒计时
|
||||
private int countdownSeconds = 0; // 倒计时秒数
|
||||
private CountDownTimer countDownTimer; // 倒计时对象
|
||||
|
||||
|
||||
public BaseCpDialog(Context context, String title, String message,
|
||||
String positiveButtonText, String negativeButtonText,
|
||||
View.OnClickListener positiveButtonClickListener,
|
||||
View.OnClickListener negativeButtonClickListener,
|
||||
boolean isCountdownEnabled, int countdownSeconds) {
|
||||
super(context);
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.positiveButtonText = positiveButtonText;
|
||||
this.negativeButtonText = negativeButtonText;
|
||||
this.positiveButtonClickListener = positiveButtonClickListener;
|
||||
this.negativeButtonClickListener = negativeButtonClickListener;
|
||||
this.isCountdownEnabled = isCountdownEnabled;
|
||||
this.countdownSeconds = countdownSeconds;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.setGravity(Gravity.CENTER); // 居中显示
|
||||
window.setBackgroundDrawableResource(R.drawable.bg_r16_fff); // 透明背景
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.dialog_confirm);
|
||||
init();
|
||||
// 动态设置背景
|
||||
// getWindow().setBackgroundDrawableResource(R.drawable.bg_r16_fff);
|
||||
|
||||
// 初始化视图
|
||||
TextView tvTitle = findViewById(R.id.tv_title);
|
||||
TextView tvMessage = findViewById(R.id.tv_message);
|
||||
Button btnPositive = findViewById(R.id.btn_positive);
|
||||
Button btnNegative = findViewById(R.id.btn_negative);
|
||||
@SuppressLint({"MissingInflatedId", "LocalSuppress"})
|
||||
ConstraintLayout rootView =(ConstraintLayout) findViewById(R.id.root_view);
|
||||
|
||||
// 设置文本
|
||||
tvTitle.setText(title);
|
||||
tvMessage.setText(message);
|
||||
btnPositive.setText(positiveButtonText);
|
||||
btnNegative.setText(negativeButtonText);
|
||||
|
||||
// 设置点击监听器
|
||||
btnPositive.setOnClickListener(v -> {
|
||||
isCountdownCancelled = true; // 标记倒计时被取消
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel(); // 取消倒计时
|
||||
countDownTimer = null;
|
||||
}
|
||||
if (positiveButtonClickListener != null) {
|
||||
positiveButtonClickListener.onClick(v);
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
|
||||
// 判断是否需要显示取消按钮
|
||||
if (negativeButtonText != null && !negativeButtonText.isEmpty()) {
|
||||
btnNegative.setText(negativeButtonText);
|
||||
btnNegative.setVisibility(View.VISIBLE);
|
||||
|
||||
btnNegative.setOnClickListener(v -> {
|
||||
if (negativeButtonClickListener != null) {
|
||||
negativeButtonClickListener.onClick(v);
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
|
||||
// 倒计时逻辑
|
||||
if (isCountdownEnabled && countdownSeconds > 0) {
|
||||
startCountdown(btnNegative);
|
||||
}
|
||||
} else {
|
||||
// 隐藏取消按钮
|
||||
btnNegative.setVisibility(View.GONE);
|
||||
}
|
||||
// 倒计时逻辑
|
||||
if (isCountdownEnabled && countdownSeconds > 0) {
|
||||
startCountdown(btnNegative);
|
||||
}
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(btnPositive, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
btnPositive.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
|
||||
// 找到根布局并应用动画
|
||||
|
||||
// if (rootView != null) {
|
||||
// Animation slideDown = AnimationUtils.loadAnimation(context, R.anim.slide_down);
|
||||
// Animation shake = AnimationUtils.loadAnimation(context, R.anim.shake);
|
||||
//
|
||||
// rootView.startAnimation(slideDown);
|
||||
// rootView.startAnimation(shake);
|
||||
// }
|
||||
}
|
||||
private boolean isCountdownCancelled = false; // 添加标志位
|
||||
private void startCountdown(Button btnNegative) {
|
||||
countDownTimer = new CountDownTimer(countdownSeconds * 1000L, 1000) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int secondsLeft = (int) (millisUntilFinished / 1000);
|
||||
btnNegative.setText(negativeButtonText + " (" + secondsLeft + "s)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
// 检查是否被主动取消
|
||||
if (!isCountdownCancelled) {
|
||||
btnNegative.setText(negativeButtonText);
|
||||
if (negativeButtonClickListener != null) {
|
||||
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel(); // 取消倒计时
|
||||
countDownTimer = null;
|
||||
}
|
||||
super.dismiss();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -515,7 +515,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_ROOM_GIFT)
|
||||
Call<BaseModel<String>> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number, @Field("heart_id") String heat_id);
|
||||
Call<BaseModel<RoomGiftData>> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number, @Field("heart_id") String heat_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_CP_GIVE_GIFT)
|
||||
Call<BaseModel<RoomGiftData>> cpGiveGift(@Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("room_id") String room_id);
|
||||
|
||||
@GET(Constants.GET_FIRST_CHARGE_GIFT)
|
||||
Call<BaseModel<FirstChargeGiftBean>> firstChargeGift();
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.bean.room.*;
|
||||
import com.xscm.moduleutil.bean.zhuangb.ZhuangBanShangChengBean;
|
||||
import com.xscm.moduleutil.listener.CPListener;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.SystemUtils;
|
||||
@@ -39,7 +40,6 @@ import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -48,7 +48,6 @@ import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.ResponseBody;
|
||||
@@ -142,6 +141,15 @@ public class RetrofitClient {
|
||||
mRetrofit = provideRetrofit(provideOkHttpClient());
|
||||
sApiServer = mRetrofit.create(ApiServer.class);
|
||||
}
|
||||
private CPListener cpListener;
|
||||
public void CpListener(CPListener cpListenter) {
|
||||
this.cpListener = cpListenter;
|
||||
}
|
||||
|
||||
public CPListener getCpListener() {
|
||||
return cpListener;
|
||||
}
|
||||
|
||||
|
||||
public static RetrofitClient getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
@@ -3054,21 +3062,75 @@ public class RetrofitClient {
|
||||
});
|
||||
}
|
||||
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String
|
||||
type, String pit_number, String heart_id, BaseObserver<String> observer) {
|
||||
sApiServer.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, heart_id).enqueue(new Callback<BaseModel<String>>() {
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number, String heart_id, BaseObserver<RoomGiftData> observer) {
|
||||
sApiServer.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, heart_id).enqueue(new Callback<BaseModel<RoomGiftData>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
onNextRetu(response, observer);
|
||||
public void onResponse(Call<BaseModel<RoomGiftData>> call, Response<BaseModel<RoomGiftData>> response) {
|
||||
if (response.code()==200){
|
||||
BaseModel<RoomGiftData> data = response.body();
|
||||
if (data.getCode()==1) {
|
||||
if (data.getData().getCp_type()!=null){
|
||||
if (cpListener !=null){
|
||||
cpListener.onSendCpMsg(data.getData());
|
||||
}
|
||||
}
|
||||
observer.onNext(data.getData());
|
||||
|
||||
}else if (data.getCode()==0){
|
||||
ToastUtils.showShort(data.getMsg());
|
||||
}else if (data.getCode()==301) {
|
||||
try {
|
||||
ToastUtils.showShort(data.getMsg());
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||
public void onFailure(Call<BaseModel<RoomGiftData>> call, Throwable t) {
|
||||
ToastUtils.showShort(t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cpGiveGift(String user_id, String gift_id,String room_id,BaseObserver<RoomGiftData> observer) {
|
||||
sApiServer.cpGiveGift(user_id, gift_id,room_id).enqueue(new Callback<BaseModel<RoomGiftData>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<RoomGiftData>> call, Response<BaseModel<RoomGiftData>> response) {
|
||||
if (response.code()==200){
|
||||
BaseModel<RoomGiftData> data = response.body();
|
||||
if (data.getCode()==1) {
|
||||
if (data.getData().getCp_type()!=null){
|
||||
if (cpListener !=null){
|
||||
cpListener.onSendCpMsg(data.getData());
|
||||
}
|
||||
}
|
||||
observer.onNext(data.getData());
|
||||
|
||||
}else if (data.getCode()==0){
|
||||
ToastUtils.showShort(data.getMsg());
|
||||
}else if (data.getCode()==301) {
|
||||
try {
|
||||
ToastUtils.showShort(data.getMsg());
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<RoomGiftData>> call, Throwable t) {
|
||||
LogUtils.e("cpGiveGift",t.fillInStackTrace());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getDayDropGift(BaseObserver<HeavenGiftBean> observer) {
|
||||
sApiServer.getDayDropGift().enqueue(new Callback<BaseModel<HeavenGiftBean>>() {
|
||||
@Override
|
||||
@@ -3383,8 +3445,7 @@ public class RetrofitClient {
|
||||
});
|
||||
}
|
||||
|
||||
public void roomRelationList(String
|
||||
type, BaseObserver<List<RoomRelationBean>> observer) {
|
||||
public void roomRelationList(String type, BaseObserver<List<RoomRelationBean>> observer) {
|
||||
sApiServer.roomRelationList(type).enqueue(new Callback<BaseModel<List<RoomRelationBean>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<List<RoomRelationBean>>> call, Response<BaseModel<List<RoomRelationBean>>> response) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xscm.moduleutil.listener
|
||||
|
||||
import com.xscm.moduleutil.bean.RoomGiftData
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent
|
||||
|
||||
/**
|
||||
* 这是cp的监听器,方便在各个模块中调用
|
||||
*/
|
||||
interface CPListener {
|
||||
/**
|
||||
* 发送CP消息的处理函数
|
||||
* @param gitData 礼物数据信息,包含房间礼物相关的数据
|
||||
*/
|
||||
fun onSendCpMsg(gitData: RoomGiftData)
|
||||
|
||||
/**
|
||||
* 接收房间消息事件的处理函数
|
||||
* @param roomMessageEvent 房间消息事件对象,包含消息相关的所有信息
|
||||
*/
|
||||
fun onReceiveMsg(roomMessageEvent: RoomMessageEvent)
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.room.EMMessageInfo;
|
||||
import com.xscm.moduleutil.event.RoomJoinMountModel;
|
||||
import com.xscm.moduleutil.event.UnreadCountEvent;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.rtc.MusicPlayBean;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.tencent.imsdk.v2.V2TIMAdvancedMsgListener;
|
||||
@@ -103,6 +104,7 @@ public class MessageListenerSingleton {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改 notify 方法以增加保护
|
||||
private void notifyPublicScreenListeners(RoomMessageEvent message) {
|
||||
synchronized (publicScreenListeners) {
|
||||
@@ -217,7 +219,7 @@ public class MessageListenerSingleton {
|
||||
try {
|
||||
// 先退出当前群组(如果需要)
|
||||
if (groupId != null && !groupId.equals(roomId)) {
|
||||
LogUtils.d("MessageListener", "开始退出群组: " + groupId +"____room:"+ roomId);
|
||||
LogUtils.d("MessageListener", "开始退出群组: " + groupId + "____room:" + roomId);
|
||||
CountDownLatch quitLatch = new CountDownLatch(1);
|
||||
boolean[] quitSuccess = {false};
|
||||
|
||||
@@ -225,14 +227,14 @@ public class MessageListenerSingleton {
|
||||
V2TIMManager.getInstance().quitGroup("room" + groupId, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
LogUtils.d("MessageListener", "退出群组成功: " + groupId+"____room:"+ roomId);
|
||||
LogUtils.d("MessageListener", "退出群组成功: " + groupId + "____room:" + roomId);
|
||||
quitSuccess[0] = true;
|
||||
quitLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
LogUtils.e("MessageListener", "退出群组失败: " + groupId +"____room:"+ roomId + ", code=" + code + ", desc=" + desc);
|
||||
LogUtils.e("MessageListener", "退出群组失败: " + groupId + "____room:" + roomId + ", code=" + code + ", desc=" + desc);
|
||||
quitSuccess[0] = false;
|
||||
quitLatch.countDown();
|
||||
}
|
||||
@@ -313,7 +315,12 @@ public class MessageListenerSingleton {
|
||||
LogUtils.d("C2C 自定义(信令)消息 " + sender.getNickName());
|
||||
String message = new String(customData, StandardCharsets.UTF_8);
|
||||
RoomMessageEvent event = GsonUtils.fromJson(message, RoomMessageEvent.class);
|
||||
notifyMessageReceived(event);
|
||||
if (event.getMsgType() == 130 || event.getMsgType() == 131) {
|
||||
// EventBus.getDefault().post(event);
|
||||
RetrofitClient.getInstance().getCpListener().onReceiveMsg(event);
|
||||
} else {
|
||||
notifyMessageReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -486,7 +493,7 @@ public class MessageListenerSingleton {
|
||||
|
||||
if (instance != null) {
|
||||
instance.listeners.clear();
|
||||
removeAllListeners();
|
||||
// removeAllListeners();
|
||||
isInitialized = false;
|
||||
groupId = null;
|
||||
LogUtils.e("@@@", "重置成功");
|
||||
@@ -497,7 +504,7 @@ public class MessageListenerSingleton {
|
||||
public static void reset(String roomId) {
|
||||
if (instance != null) {
|
||||
instance.listeners.clear();
|
||||
removeAllListeners();
|
||||
// removeAllListeners();
|
||||
isInitialized = false;
|
||||
groupId = null;
|
||||
// instance = null;
|
||||
@@ -508,7 +515,7 @@ public class MessageListenerSingleton {
|
||||
|
||||
|
||||
// 确保监听器已添加
|
||||
private void ensureListenersAdded() {
|
||||
public void ensureListenersAdded() {
|
||||
initListeners();
|
||||
addAllListeners();
|
||||
}
|
||||
@@ -574,7 +581,32 @@ public class MessageListenerSingleton {
|
||||
);
|
||||
}
|
||||
|
||||
public void sendCustomC2CMessage(String userId, byte[] binaryData) {
|
||||
// TODO: 2025/11/19 添加发送公共方法,messageType:发送的type;message:发送的内容 userId:发送给谁
|
||||
public void sendCustomC2CMessage(int messageType, String message, String userId) {
|
||||
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setFromUserInfo(SpUtil.getUserInfo());
|
||||
t.setText(message);
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(messageType, mRoomId, t);
|
||||
String json = com.blankj.utilcode.util.GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
// 创建自定义群消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
v2TIMMessage.setExcludedFromUnreadCount(true);
|
||||
v2TIMMessage.setExcludedFromContentModeration(true);
|
||||
// v2TIMMessage.setNeedReadReceipt(true);
|
||||
//
|
||||
// // 发送消息
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, "u" + userId, null, V2TIMMessage.V2TIM_PRIORITY_HIGH,
|
||||
true,
|
||||
null,
|
||||
sendCallback);
|
||||
|
||||
}
|
||||
|
||||
public void sendCustomC2CMessage125(String userId, byte[] binaryData) {
|
||||
// 创建自定义群消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
v2TIMMessage.setExcludedFromUnreadCount(true);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoomGiftData;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
@@ -102,7 +103,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number, String heart_id) {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, heart_id, new BaseObserver<String>() {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, heart_id, new BaseObserver<RoomGiftData>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -110,7 +111,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
public void onNext(RoomGiftData s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.Map;
|
||||
public class ColorManager {
|
||||
private static ColorManager instance;
|
||||
private String primaryColor = "#3ABC6D"; // 默认主题色
|
||||
private String buttonColor = "#6D6D6D"; // 默认按钮色
|
||||
private String buttonColor = "#FFFFFF"; // 默认按钮色
|
||||
|
||||
// 监听器列表,用于通知颜色变化
|
||||
private List<ColorChangeListener> listeners = new ArrayList<>();
|
||||
@@ -80,7 +80,7 @@ public class ColorManager {
|
||||
try {
|
||||
return Color.parseColor(buttonColor);
|
||||
} catch (Exception e) {
|
||||
return Color.parseColor("#6D6D6D"); // 默认颜色
|
||||
return Color.parseColor("#FFFFFF"); // 默认颜色
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public class ImageUtils {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Glide.with(mImageView).load(path).diskCacheStrategy(DiskCacheStrategy.ALL).into(mImageView);
|
||||
Glide.with(mImageView).load(path).placeholder(R.mipmap.default_avatar).diskCacheStrategy(DiskCacheStrategy.ALL).into(mImageView);
|
||||
}
|
||||
|
||||
public static void loadHeadCC(String path, ImageView mImageView) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class MeHeadView extends ConstraintLayout {
|
||||
|
||||
if (nobilityImage!=null && !TextUtils.isEmpty(nobilityImage)){
|
||||
iv_frame_bg.setVisibility(VISIBLE);
|
||||
ImageUtils.loadHead(nobilityImage, iv_frame_bg);
|
||||
ImageUtils.loadRoomItem(nobilityImage, iv_frame_bg);
|
||||
}else {
|
||||
iv_frame_bg.setVisibility(GONE);
|
||||
}
|
||||
|
||||
@@ -278,6 +278,7 @@ public class Constants {
|
||||
public static final String POST_GRAB = "/api/Redpacket/grab";//抢红包
|
||||
|
||||
public static final String GET_ROOM_GIFT = "/api/Room/room_give_gift";//直播间送礼
|
||||
public static final String POST_CP_GIVE_GIFT = "/api/UserCp/cpGiveGift";//用户CP礼物回赠
|
||||
public static final String GET_ROOM_USER = "/api/Room/room_user_home";//房间内点击头像
|
||||
public static final String APPLY_PIT = "/api/RoomPit/apply_pit";//申请上麦
|
||||
public static final String DOWN_PIT = "/api/RoomPit/down_pit";//下麦
|
||||
|
||||
Reference in New Issue
Block a user