66 1
This commit is contained in:
@@ -161,7 +161,7 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
|
||||
//设置mqtt环境 false 测试环境 true 正式环境
|
||||
// ExternalResConstants.INSTANCE.setIS_MQTT_RELEASE(false);
|
||||
//设置http环境 false 测试环境 true 正式环境
|
||||
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(false);
|
||||
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(true);
|
||||
currentEnvironment = ExternalResConstants.INSTANCE.HTTP_PATH();
|
||||
|
||||
initialization();
|
||||
@@ -438,24 +438,12 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
|
||||
if (SpUtil.isAgreePolicy()) {
|
||||
checkInEmulator();
|
||||
// UtilConfig.checkInEmulator();
|
||||
AgoraManager.getInstance();
|
||||
MessageListenerSingleton.getInstance();
|
||||
CrashReport.initCrashReport(this, "b45883f58f", true);/*bugly初始化*/
|
||||
// // 启动 MQTT 服务
|
||||
// Intent mqttServiceIntent = new Intent(this, MyMqttService.class);
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// startForegroundService(mqttServiceIntent);
|
||||
// } else {
|
||||
// startService(mqttServiceIntent);
|
||||
// }
|
||||
|
||||
// mqttConnect=MqttConnect.getInstance(this, currentEnvironment.getMqttUrl(),"android-"+ MqttClient.generateClientId());
|
||||
// mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.101.98","android-"+ MqttClient.generateClientId());
|
||||
// mqttConnect.mqttClient();
|
||||
CrashReport.initCrashReport(this, "b45883f58f", true);/*bugly初始化*/
|
||||
|
||||
// 每次启动应用时重置状态
|
||||
SpUtil.getInstance().setBooleanValue("youth_model_shown", false);
|
||||
startInitSdk();
|
||||
|
||||
// 初始化(通常在Application或Activity的onCreate中)
|
||||
CosUploadManager.getInstance(CommonAppContext.getInstance());
|
||||
}
|
||||
@@ -527,9 +515,12 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
|
||||
public void upMqtt(){
|
||||
if (mqttConnect == null){
|
||||
mqttConnect=MqttConnect.getInstance(this, currentEnvironment.getMqttUrl(),"android-"+ MqttClient.generateClientId());
|
||||
// mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.101.98","android-"+ MqttClient.generateClientId());
|
||||
mqttConnect.mqttClient();
|
||||
}
|
||||
|
||||
AgoraManager.getInstance();
|
||||
MessageListenerSingleton.getInstance();
|
||||
startInitSdk();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -764,6 +755,11 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
|
||||
// 每次启动应用时重置状态
|
||||
SpUtil.setBooleanValue("youth_model_shown", false);
|
||||
|
||||
if (mqttConnect != null){
|
||||
mqttConnect.close();
|
||||
}
|
||||
|
||||
|
||||
// 发送广播通知所有Activity刷新状态
|
||||
Intent refreshIntent = new Intent("com.xscm.moduleutil.ACTION_USER_LOGOUT");
|
||||
sendBroadcast(refreshIntent);
|
||||
|
||||
@@ -74,6 +74,15 @@ public class RetrofitClient {
|
||||
boolean isNetworkAvailable = checkNetworkConnection(); // 实现这个方法来检查网络状态
|
||||
String cacheControl = isNetworkAvailable ? "max-age=0" : "only-if-cached, max-stale=86400";
|
||||
|
||||
private JoinRoomLoadListener joinRoomLoadListener;
|
||||
|
||||
public interface JoinRoomLoadListener {
|
||||
void onJoinRoomLoad(String result);
|
||||
}
|
||||
public void setJoinRoomLoadListener(JoinRoomLoadListener joinRoomLoadListener) {
|
||||
this.joinRoomLoadListener = joinRoomLoadListener;
|
||||
}
|
||||
|
||||
private boolean checkNetworkConnection() {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) CommonAppContext.getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
@@ -2248,6 +2257,9 @@ public class RetrofitClient {
|
||||
}
|
||||
} else if (roomInfoRespBaseModel.getCode() == 0) {
|
||||
ToastUtils.showShort(roomInfoRespBaseModel.getMsg());
|
||||
if (joinRoomLoadListener != null){
|
||||
joinRoomLoadListener.onJoinRoomLoad(roomInfoRespBaseModel.getMsg());
|
||||
}
|
||||
}else if (roomInfoRespBaseModel.getCode() == 202){
|
||||
observer.onNext(roomInfoRespBaseModel.getData());
|
||||
} else {
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.xscm.modulemain.activity.WebViewActivity;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.activity.user.activity.HeartCpActivity;
|
||||
import com.xscm.modulemain.activity.user.activity.MyRoomActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.R;
|
||||
@@ -122,11 +123,13 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
disLoading();
|
||||
}
|
||||
|
||||
private Activity mThis;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
RetrofitClient.getInstance ().CpListener(new CPListener() {
|
||||
mThis = this;
|
||||
RetrofitClient.getInstance().CpListener(new CPListener() {
|
||||
@Override
|
||||
public void onReceiveMsg(@NotNull RoomMessageEvent roomMessageEvent) {
|
||||
cpReceiver(roomMessageEvent);
|
||||
@@ -137,6 +140,16 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
cpMsg(gitData);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
RetrofitClient.getInstance().setJoinRoomLoadListener(result -> {
|
||||
if (mThis instanceof MainActivity) {
|
||||
((MainActivity) mThis).isShowLoading(false);
|
||||
} else if (mThis instanceof MyRoomActivity) {
|
||||
((MyRoomActivity) mThis).isShowLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,19 +209,19 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
String cpTypeJson = GsonUtils.toJson(event.getCp_type());
|
||||
if (event.getCp_type().getCp_type() == 1) {
|
||||
|
||||
if (event.getGift_user_data()!=null && event.getGift_user_data().size()>0){
|
||||
for (int i = 0; i <event.getGift_user_data().size(); i++)
|
||||
if (event.getGift_user_data() != null && event.getGift_user_data().size() > 0) {
|
||||
for (int i = 0; i < event.getGift_user_data().size(); i++)
|
||||
// 创建自定义消息
|
||||
MessageListenerSingleton.getInstance().sendCustomC2CMessage(130,cpTypeJson,
|
||||
MessageListenerSingleton.getInstance().sendCustomC2CMessage(130, cpTypeJson,
|
||||
event.getGift_user_data().get(i).getUser_id()
|
||||
);
|
||||
}
|
||||
}else if (event.getCp_type().getCp_type() == 2) {
|
||||
if (event.getGift_user_data()!=null && event.getGift_user_data().size()>0){
|
||||
} else if (event.getCp_type().getCp_type() == 2) {
|
||||
if (event.getGift_user_data() != null && event.getGift_user_data().size() > 0) {
|
||||
for (int i = 0; i < event.getGift_user_data().size(); i++)
|
||||
// 创建自定义消息
|
||||
MessageListenerSingleton.getInstance().sendCustomC2CMessage(131,cpTypeJson,
|
||||
event.getGift_user_data().get(i).getUser_id()
|
||||
MessageListenerSingleton.getInstance().sendCustomC2CMessage(131, cpTypeJson,
|
||||
event.getGift_user_data().get(i).getUser_id()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -216,13 +229,13 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
}
|
||||
|
||||
public void cpReceiver(BaseEvent event) {
|
||||
String a = ActivityUtils.getTopActivity().getLocalClassName();
|
||||
if (event instanceof RoomMessageEvent) {
|
||||
com.xscm.moduleutil.bean.RoomGiftData.CpType text = GsonUtils.fromJson(((RoomMessageEvent) event).getText().getText().toString(),com.xscm.moduleutil.bean.RoomGiftData.CpType.class);
|
||||
String a = ActivityUtils.getTopActivity().getLocalClassName();
|
||||
if (event instanceof RoomMessageEvent) {
|
||||
com.xscm.moduleutil.bean.RoomGiftData.CpType text = GsonUtils.fromJson(((RoomMessageEvent) event).getText().getText().toString(), com.xscm.moduleutil.bean.RoomGiftData.CpType.class);
|
||||
if (text.getCp_type() == 1) {
|
||||
queren1(1,text.getText1(),text.getGift_id()+"",((RoomMessageEvent) event).getText().getFromUserInfo().getUser_id()+"",((RoomMessageEvent) event).getRoomId());
|
||||
}else if (text.getCp_type() == 2) {
|
||||
queren1(2,text.getText1(),text.getGift_id()+"",((RoomMessageEvent) event).getText().getFromUserInfo().getUser_id()+"",((RoomMessageEvent) event).getRoomId());
|
||||
queren1(1, text.getText1(), text.getGift_id() + "", ((RoomMessageEvent) event).getText().getFromUserInfo().getUser_id() + "", ((RoomMessageEvent) event).getRoomId());
|
||||
} else if (text.getCp_type() == 2) {
|
||||
queren1(2, text.getText1(), text.getGift_id() + "", ((RoomMessageEvent) event).getText().getFromUserInfo().getUser_id() + "", ((RoomMessageEvent) event).getRoomId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -312,15 +325,15 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
}
|
||||
};
|
||||
|
||||
private void queren1(int type,String content,String giftid,String userId,String roomId) {
|
||||
private void queren1(int type, String content, String giftid, String userId, String roomId) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(ActivityUtils.getTopActivity(),
|
||||
type==1?"心动信号":"缘定三生 此刻同心",
|
||||
new ConfirmDialog(ActivityUtils.getTopActivity(),
|
||||
type == 1 ? "心动信号" : "缘定三生 此刻同心",
|
||||
content,
|
||||
type==1?"回赠同心锁":"进入心动空间",
|
||||
type==1?"再想想":"我知道了",
|
||||
type == 1 ? "回赠同心锁" : "进入心动空间",
|
||||
type == 1 ? "再想想" : "我知道了",
|
||||
v -> {
|
||||
if (type==1) {
|
||||
if (type == 1) {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
RetrofitClient.getInstance().cpGiveGift(userId, giftid, roomId, new BaseObserver<RoomGiftData>() {
|
||||
@Override
|
||||
@@ -331,23 +344,23 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
@Override
|
||||
public void onNext(RoomGiftData roomGiftData) {
|
||||
if (roomGiftData.getCp_type() != null) {
|
||||
if (roomGiftData.getCp_type().getCp_type()==2){
|
||||
queren1(2,roomGiftData.getCp_type().getText(),"",SpUtil.getUserId()+"","");
|
||||
}
|
||||
if (roomGiftData.getCp_type().getCp_type() == 2) {
|
||||
queren1(2, roomGiftData.getCp_type().getText(), "", SpUtil.getUserId() + "", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}else {
|
||||
int userids= Integer.parseInt(userId);
|
||||
} else {
|
||||
int userids = Integer.parseInt(userId);
|
||||
Intent intent = new Intent(ActivityUtils.getTopActivity(), HeartCpActivity.class);
|
||||
intent.putExtra("userId",userids);
|
||||
intent.putExtra("userId", userids);
|
||||
startActivity(intent);
|
||||
}
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
|
||||
}, false,0).show();
|
||||
}, false, 0).show();
|
||||
}
|
||||
|
||||
|
||||
@@ -1081,7 +1094,7 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
// 这里可以根据实际需求实现跳转逻辑
|
||||
// 例如:跳转到礼物详情页面、用户主页等
|
||||
// 使用缓存数据进入房间
|
||||
if (ActivityUtils.getTopActivity() instanceof RoomActivity){
|
||||
if (ActivityUtils.getTopActivity() instanceof RoomActivity) {
|
||||
if (!Objects.equals(((RoomActivity) ActivityUtils.getTopActivity()).getRoomId(), xlhBean.getRoom_id())) {
|
||||
((RoomActivity) ActivityUtils.getTopActivity()).refreshRoomInfo(xlhBean.getRoom_id());
|
||||
}
|
||||
@@ -1095,7 +1108,7 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
// 这里可以根据实际需求实现跳转逻辑
|
||||
// 例如:跳转到礼物详情页面、用户主页等
|
||||
// 使用缓存数据进入房间
|
||||
if (ActivityUtils.getTopActivity() instanceof RoomActivity){
|
||||
if (ActivityUtils.getTopActivity() instanceof RoomActivity) {
|
||||
if (!Objects.equals(((RoomActivity) ActivityUtils.getTopActivity()).getRoomId(), redBean.getRoom_id())) {
|
||||
((RoomActivity) ActivityUtils.getTopActivity()).refreshRoomInfo(redBean.getRoom_id());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -178,7 +179,7 @@ public class RankingChildFragment extends BaseMvpFragment<DataListPresenter, Roo
|
||||
// }
|
||||
|
||||
mBinding.roomHeadTop1Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip1);
|
||||
// setview(listsBean.getIcon(), mBinding.llVip1);
|
||||
mBinding.roomRankTop1HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -202,7 +203,7 @@ public class RankingChildFragment extends BaseMvpFragment<DataListPresenter, Roo
|
||||
|
||||
|
||||
mBinding.roomHeadTop2Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip2);
|
||||
// setview(listsBean.getIcon(), mBinding.llVip2);
|
||||
mBinding.roomRankTop2HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -212,11 +213,25 @@ public class RankingChildFragment extends BaseMvpFragment<DataListPresenter, Roo
|
||||
}
|
||||
|
||||
private void setview(List<String> item, LinearLayout llContainer) {
|
||||
// 1. 基础判空:容器/数据为空直接返回
|
||||
if (llContainer == null || item == null || item.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 2. 检查 Fragment 状态 + 获取有效 Context
|
||||
Context context = null;
|
||||
// 检查 Fragment 是否还附加在 Activity 上
|
||||
if (isAdded() && getContext() != null) {
|
||||
context = getContext(); // 非空校验,避免隐性空指针
|
||||
} else {
|
||||
// 兜底:如果 Context 为空,直接返回(避免后续崩溃)
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> images = item; // 获取图片列表
|
||||
|
||||
for (String url : images) {
|
||||
if (url.contains("http")) {
|
||||
ImageView imageView1 = new ImageView(Application.getInstance());
|
||||
ImageView imageView1 = new ImageView(context);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_57),
|
||||
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_15)
|
||||
@@ -248,7 +263,7 @@ public class RankingChildFragment extends BaseMvpFragment<DataListPresenter, Roo
|
||||
// }
|
||||
|
||||
mBinding.roomHeadTop3Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip3);
|
||||
// setview(listsBean.getIcon(), mBinding.llVip3);
|
||||
mBinding.roomRankTop3HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@@ -389,8 +389,7 @@ public class RoomManager {
|
||||
CommonAppContext.getInstance().playId.equals(roomId) ?"取消":"在想想",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
// MvpPre.deleteComment(String.valueOf(commentId));
|
||||
fetchRoomDataAndEnter(ActivityUtils.getTopActivity(),roomId,"",taskId);
|
||||
fetchAndJoinRoom(ActivityUtils.getTopActivity(),roomId,"",taskId);
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
|
||||
@@ -339,7 +339,7 @@
|
||||
android:layout_width="@dimen/dp_15"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:layout_marginEnd="@dimen/dp_5"
|
||||
android:checked="true"
|
||||
android:checked="false"
|
||||
android:background="@drawable/selector_login_agreement"
|
||||
android:button="@null" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user