1:添加备用服务器,在请求themeData的时候,返回的不对的时候,就切换服务器

This commit is contained in:
2025-12-31 03:31:31 +08:00
parent 479e039e56
commit c2fd1df529
12 changed files with 147 additions and 83 deletions

View File

@@ -44,6 +44,7 @@ import com.tencent.qcloud.tuicore.TUILogin;
import com.tencent.qcloud.tuicore.interfaces.TUICallback; import com.tencent.qcloud.tuicore.interfaces.TUICallback;
import com.xscm.moduleutil.bean.UserBean; import com.xscm.moduleutil.bean.UserBean;
import com.xscm.moduleutil.bean.UserInfo; import com.xscm.moduleutil.bean.UserInfo;
import com.xscm.moduleutil.dialog.ConfirmDialog;
import com.xscm.moduleutil.event.AppLifecycleEvent; import com.xscm.moduleutil.event.AppLifecycleEvent;
import com.xscm.moduleutil.event.UnreadCountEvent; import com.xscm.moduleutil.event.UnreadCountEvent;
import com.xscm.moduleutil.http.RetrofitClient; import com.xscm.moduleutil.http.RetrofitClient;
@@ -165,14 +166,14 @@ public class CommonAppContext extends MultiDexApplication implements Application
SpUtil.setShelf(1); SpUtil.setShelf(1);
} }
if (SpUtil.getTaskService()==1){ if (SpUtil.getTaskService() == 1){//当如果是正式服的时候,这里就变成可以设置成辅助服务器,当如果是测试服务的时候,就是变成了测试了,
selectRelease = 2; selectRelease = 1;
} }
//设置mqtt环境 false 测试环境 true 正式环境 //设置mqtt环境 false 测试环境 true 正式环境
// ExternalResConstants.INSTANCE.setIS_MQTT_RELEASE(false); // ExternalResConstants.INSTANCE.setIS_MQTT_RELEASE(false);
//设置http环境 false 测试环境 true 正式环境 //设置http环境 false 测试环境 true 正式环境
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(selectRelease != -1); ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(selectRelease);
currentEnvironment = ExternalResConstants.INSTANCE.HTTP_PATH(); currentEnvironment = ExternalResConstants.INSTANCE.HTTP_PATH();
initialization(); initialization();
@@ -220,6 +221,38 @@ public class CommonAppContext extends MultiDexApplication implements Application
} }
} }
public void dialogHttp(){
new ConfirmDialog(ActivityUtils.getTopActivity(),
"提示",
"当前网络环境异常,请重试",
"确认",
"取消",
v -> {
// 点击“确认”按钮时执行删除操作
selectRelease = 3;
initHttp();
},
v -> {
selectRelease = 3;
initHttp();
// 点击“取消”按钮时什么都不做
}, false, 0).show();
}
public void initHttp(){
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(selectRelease);
currentEnvironment = ExternalResConstants.INSTANCE.HTTP_PATH();
try {
RetrofitClient.INSTANCE=null;
RetrofitClient.getInstance();
clearLoginInfo();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
// 更新未读消息数的方法 // 更新未读消息数的方法
private void updateUnreadMessageCount() { private void updateUnreadMessageCount() {
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() { V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {

View File

@@ -17,12 +17,15 @@ object ExternalResConstants {
// } // }
// } // }
//================================================================================HTTP====================================================================================== //================================================================================HTTP======================================================================================
var IS_HTTP_RELEASE = true var IS_HTTP_RELEASE: Int = 1 //0 测试环境 1 正式环境 2 辅助环境
val HTTP_PATH_DEBUG: EnvironmentEnum = EnvironmentEnum.TEST val HTTP_PATH_DEBUG: EnvironmentEnum = EnvironmentEnum.TEST
val HTTP_PATH_RELEASE: EnvironmentEnum = EnvironmentEnum.PRODUCTION val HTTP_PATH_RELEASE: EnvironmentEnum = EnvironmentEnum.PRODUCTION
val HTTP_AUXILIARY: EnvironmentEnum = EnvironmentEnum.Auxiliary
fun HTTP_PATH(): EnvironmentEnum { fun HTTP_PATH(): EnvironmentEnum {
return if (IS_HTTP_RELEASE) { return if (IS_HTTP_RELEASE == 1) {
HTTP_PATH_RELEASE HTTP_PATH_RELEASE
} else if (IS_HTTP_RELEASE == 3) {
HTTP_AUXILIARY
} else { } else {
HTTP_PATH_DEBUG HTTP_PATH_DEBUG
} }

View File

@@ -61,9 +61,9 @@ import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
public class RetrofitClient { public class RetrofitClient {
private static RetrofitClient INSTANCE; public static RetrofitClient INSTANCE;
private static ApiServer sApiServer; private static ApiServer sApiServer;
public static final int DEFAULT_TIME_OUT = 30; public static final int DEFAULT_TIME_OUT = 10;
private static OkHttpClient client; private static OkHttpClient client;
private final Retrofit mRetrofit; private final Retrofit mRetrofit;
@@ -1695,10 +1695,11 @@ public class RetrofitClient {
observer.onNext(baseModel.getData()); observer.onNext(baseModel.getData());
} }
} else { } else {
observer.onNext(null); CommonAppContext.getInstance().dialogHttp();
} }
} }
} else { } else {
CommonAppContext.getInstance().dialogHttp();
LogUtils.e("获取主题数据失败", response.message()); LogUtils.e("获取主题数据失败", response.message());
} }
} }
@@ -1706,6 +1707,7 @@ public class RetrofitClient {
@Override @Override
public void onFailure(Call<BaseModel<ThemeBean>> call, Throwable t) { public void onFailure(Call<BaseModel<ThemeBean>> call, Throwable t) {
LogUtils.e("获取主题数据失败", t); LogUtils.e("获取主题数据失败", t);
CommonAppContext.getInstance().dialogHttp();
} }
}); });
} }

View File

@@ -90,7 +90,7 @@ public class SystemUtils {
ConfigUtils configUtils = ConfigUtils.getInstance(context); ConfigUtils configUtils = ConfigUtils.getInstance(context);
configUtils.setConfigName(system_uuid_key); configUtils.setConfigName(system_uuid_key);
String system_config_uuid = configUtils.findStringByKey(system_uuid_key); String system_config_uuid = configUtils.findStringByKey(system_uuid_key);
if (system_config_uuid == null) { if (system_config_uuid == null || system_config_uuid.isEmpty()) {
// system_config_uuid = DeviceUtils.getUniqueDeviceId(); // system_config_uuid = DeviceUtils.getUniqueDeviceId();
configUtils.addOrUpdateText(system_uuid_key, system_config_uuid); configUtils.addOrUpdateText(system_uuid_key, system_config_uuid);
} }

View File

@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public class ConfigUtils { public class ConfigUtils {
@@ -74,8 +75,11 @@ public class ConfigUtils {
*/ */
public String findStringByKey(String key) { public String findStringByKey(String key) {
if (data_list==null){
data_list = new HashMap<String, Object>();
}
if (data_list.containsKey(key)) if (data_list.containsKey(key))
return data_list.get(key).toString(); return data_list.get(key)!=null?data_list.get(key).toString():"";
else else
return sp.getString(key, null); return sp.getString(key, null);
} }

View File

@@ -20,6 +20,26 @@ public enum EnvironmentEnum {
// "https://vespa.qxyushen.top/h5", // "https://vespa.qxyushen.top/h5",
"https://yushengapi.qxyushen.top/h5", "https://yushengapi.qxyushen.top/h5",
0), 0),
Auxiliary(//辅助生产环境
//"https://vespa.qxyushen.top/",
"https://qixinghuishen.qxhs.xyz/",
"KvNmqZc+VMzO4CfGMd5zmG6w6OFwpFO/19TwXUWfHDOBgmnl9DgIuE+kbrjNNnxqhtP3pH7bBrnSaSeFtunr72q6sgpLsfuswcUroMvz2slaTBcNzCaLi+GSnM3gB/GdO47mwLdk+iYBTvPUOCIuT608Z29z09w+vPeUDoMCHJBGXu6uh7Nj6PtV1dfGoUvByk1ZF0WYVjIqKDcb3tXY4jonFh3XAWhzMy8xKwN6F2nuK2IcdIwaSPsvuMZmhatP6f9kOE+vnfweyCHS3RxiG474WIoZGJM8omrl3/pOVqE=",
"https://oss-cn-beijing.aliyuncs.com/",
"LTAI5tKgrfcFQxH46ZwWYgFW",
"ZOjTqAJmUL563EKFKySrUwAHtx4hKt",
"midi01",
"https://midi01.oss-cn-beijing.aliyuncs.com/",
"wxc7681513be9f926b",
1600096860,
"3e8f3add448d4692bc1d04c75ffe801b",
//"tcp://1.13.101.98",
// "tcp://1.13.20.30",
"tcp://qixinghuishen.qxhs.xyz",
// "https://vespa.qxyushen.top/h5",
"https://qixinghuishen.qxhs.xyz/h5",
0),
TEST(//测试环境 TEST(//测试环境
"https://test.vespa.qxyushen.top/", "https://test.vespa.qxyushen.top/",
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=", "6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",

View File

@@ -31,14 +31,15 @@
<TextView <TextView
android:id="@+id/tv_content" android:id="@+id/tv_content"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_7" android:layout_marginEnd="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_7" android:layout_marginTop="@dimen/dp_7"
tools:text="我是评论" tools:text="我是评论我是评论我是评论我是评论我是评论我是评论我是评论我是评论我是评论我是评论"
android:textColor="@color/color_FF333333" android:textColor="@color/color_FF333333"
android:textSize="@dimen/sp_14" android:textSize="@dimen/sp_14"
app:layout_constraintStart_toEndOf="@+id/iv_avatar" app:layout_constraintStart_toStartOf="@+id/tv_nickname"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_nickname" /> app:layout_constraintTop_toBottomOf="@+id/tv_nickname" />
<TextView <TextView

Binary file not shown.

Before

Width:  |  Height:  |  Size: 972 B

View File

@@ -302,7 +302,7 @@ public class SettingActivity extends BaseMvpActivity<SettingPresenter, ActivityS
} else if (id == R.id.swit_qh) { } else if (id == R.id.swit_qh) {
if (mBinding.switQh.isChecked()) { if (mBinding.switQh.isChecked()) {
SpUtil.setTaskService(1); SpUtil.setTaskService(1);
CommonAppContext.selectRelease = 2; CommonAppContext.selectRelease = 1;
} else { } else {
SpUtil.setTaskService(0); SpUtil.setTaskService(0);
CommonAppContext.selectRelease = -1; CommonAppContext.selectRelease = -1;

View File

@@ -158,7 +158,7 @@ public class RoomSettingFragment extends BaseMvpDialogFragment<RoomSettingPresen
roomTypeChildren.add(new RoomSettingBean("拍卖", "ic_auction", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeAuction, read, isSelected, false, false)); roomTypeChildren.add(new RoomSettingBean("拍卖", "ic_auction", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeAuction, read, isSelected, false, false));
roomTypeChildren.add(new RoomSettingBean("点唱", "jiao_y", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeJiaoy, read, isSelected, false, false)); roomTypeChildren.add(new RoomSettingBean("点唱", "jiao_y", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeJiaoy, read, isSelected, false, false));
roomTypeChildren.add(new RoomSettingBean("互娱", "ic_jiaoy", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeHUYU, read, isSelected, false, false)); roomTypeChildren.add(new RoomSettingBean("互娱", "ic_jiaoy", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeHUYU, read, isSelected, false, false));
roomTypeChildren.add(new RoomSettingBean("练歌房", "ic_liang", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeLianG, read, isSelected, false, false)); // roomTypeChildren.add(new RoomSettingBean("练歌房", "ic_liang", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeLianG, read, isSelected, false, false));
roomTypeChildren.add(new RoomSettingBean("签约", "sing_contract", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeSIGNCONTRACT, read, isSelected, false, false)); roomTypeChildren.add(new RoomSettingBean("签约", "sing_contract", null, null, RoomSettingBean.QXRoomSettingTypeRoomTypeSIGNCONTRACT, read, isSelected, false, false));
roomTypeParent.setChildren(roomTypeChildren); roomTypeParent.setChildren(roomTypeChildren);
parentList.add(roomTypeParent); parentList.add(roomTypeParent);
@@ -389,9 +389,11 @@ public class RoomSettingFragment extends BaseMvpDialogFragment<RoomSettingPresen
queren("9"); queren("9");
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeHUYU) { } else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeHUYU) {
queren("7"); queren("7");
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeLianG) { }
queren("-1"); // else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeLianG) { 2025年12月30日20:56:53根据需求隐藏用户自主切换练歌房
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeSIGNCONTRACT) { // queren("-1");
// }
else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeSIGNCONTRACT) {
queren("10"); queren("10");
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomSetting) { } else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomSetting) {
if (roomInfoResp != null) { if (roomInfoResp != null) {

View File

@@ -22,14 +22,13 @@
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<!-- 主内容 RecyclerView --> <!-- 主内容 RecyclerView -->
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_view" android:id="@+id/recycle_view"

View File

@@ -28,8 +28,8 @@ isBuildModule=false
#org.gradle.deamon=false #org.gradle.deamon=false
android.injected.testOnly=false android.injected.testOnly=false
APP_VERSION_NAME=1.0.9.2 APP_VERSION_NAME=1.0.9.3
APP_VERSION_CODE=82 APP_VERSION_CODE=83
org.gradle.jvm.toolchain.useLegacyAdapters=false org.gradle.jvm.toolchain.useLegacyAdapters=false
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15 #org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15