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.xscm.moduleutil.bean.UserBean;
import com.xscm.moduleutil.bean.UserInfo;
import com.xscm.moduleutil.dialog.ConfirmDialog;
import com.xscm.moduleutil.event.AppLifecycleEvent;
import com.xscm.moduleutil.event.UnreadCountEvent;
import com.xscm.moduleutil.http.RetrofitClient;
@@ -165,14 +166,14 @@ public class CommonAppContext extends MultiDexApplication implements Application
SpUtil.setShelf(1);
}
if (SpUtil.getTaskService()==1){
selectRelease = 2;
if (SpUtil.getTaskService() == 1){//当如果是正式服的时候,这里就变成可以设置成辅助服务器,当如果是测试服务的时候,就是变成了测试了,
selectRelease = 1;
}
//设置mqtt环境 false 测试环境 true 正式环境
// ExternalResConstants.INSTANCE.setIS_MQTT_RELEASE(false);
//设置http环境 false 测试环境 true 正式环境
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(selectRelease != -1);
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(selectRelease);
currentEnvironment = ExternalResConstants.INSTANCE.HTTP_PATH();
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() {
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {

View File

@@ -4,7 +4,7 @@ import com.xscm.moduleutil.utils.config.EnvironmentEnum
object ExternalResConstants {
//================================================================================MQTT======================================================================================
//================================================================================MQTT======================================================================================
// var IS_MQTT_RELEASE = true
// val MQTT_PATH_DEBUG = "tcp://1.13.181.248"
// val MQTT_PATH_RELEASE = "tcp://1.13.101.98"
@@ -17,12 +17,15 @@ object ExternalResConstants {
// }
// }
//================================================================================HTTP======================================================================================
var IS_HTTP_RELEASE = true
val HTTP_PATH_DEBUG:EnvironmentEnum = EnvironmentEnum.TEST
val HTTP_PATH_RELEASE:EnvironmentEnum = EnvironmentEnum.PRODUCTION
var IS_HTTP_RELEASE: Int = 1 //0 测试环境 1 正式环境 2 辅助环境
val HTTP_PATH_DEBUG: EnvironmentEnum = EnvironmentEnum.TEST
val HTTP_PATH_RELEASE: EnvironmentEnum = EnvironmentEnum.PRODUCTION
val HTTP_AUXILIARY: EnvironmentEnum = EnvironmentEnum.Auxiliary
fun HTTP_PATH(): EnvironmentEnum {
return if (IS_HTTP_RELEASE) {
return if (IS_HTTP_RELEASE == 1) {
HTTP_PATH_RELEASE
} else if (IS_HTTP_RELEASE == 3) {
HTTP_AUXILIARY
} else {
HTTP_PATH_DEBUG
}

View File

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

View File

@@ -90,7 +90,7 @@ public class SystemUtils {
ConfigUtils configUtils = ConfigUtils.getInstance(context);
configUtils.setConfigName(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();
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.Map;
import java.util.Objects;
public class ConfigUtils {
@@ -74,8 +75,11 @@ public class ConfigUtils {
*/
public String findStringByKey(String key) {
if (data_list==null){
data_list = new HashMap<String, Object>();
}
if (data_list.containsKey(key))
return data_list.get(key).toString();
return data_list.get(key)!=null?data_list.get(key).toString():"";
else
return sp.getString(key, null);
}

View File

@@ -20,6 +20,26 @@ public enum EnvironmentEnum {
// "https://vespa.qxyushen.top/h5",
"https://yushengapi.qxyushen.top/h5",
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(//测试环境
"https://test.vespa.qxyushen.top/",
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",

View File

@@ -6,7 +6,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginStart="@dimen/dp_17"
android:layout_marginEnd="@dimen/dp_15"
android:layout_marginEnd="@dimen/dp_15"
android:orientation="horizontal">
<!-- 用户头像 -->
@@ -31,14 +31,15 @@
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_7"
android:layout_marginEnd="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_7"
tools:text="我是评论"
tools:text="我是评论我是评论我是评论我是评论我是评论我是评论我是评论我是评论我是评论我是评论"
android:textColor="@color/color_FF333333"
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" />
<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) {
if (mBinding.switQh.isChecked()) {
SpUtil.setTaskService(1);
CommonAppContext.selectRelease = 2;
CommonAppContext.selectRelease = 1;
} else {
SpUtil.setTaskService(0);
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("点唱", "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_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));
roomTypeParent.setChildren(roomTypeChildren);
parentList.add(roomTypeParent);
@@ -389,9 +389,11 @@ public class RoomSettingFragment extends BaseMvpDialogFragment<RoomSettingPresen
queren("9");
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeHUYU) {
queren("7");
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeLianG) {
queren("-1");
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeSIGNCONTRACT) {
}
// else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeLianG) { 2025年12月30日20:56:53根据需求隐藏用户自主切换练歌房
// queren("-1");
// }
else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomTypeSIGNCONTRACT) {
queren("10");
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomSetting) {
if (roomInfoResp != null) {

View File

@@ -22,32 +22,31 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- 主内容 RecyclerView -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/dp_6"
android:paddingRight="@dimen/dp_6"
android:paddingBottom="@dimen/dp_12"
tools:itemCount="1"
tools:listitem="@layout/item_cirle_list" />
<!-- 主内容 RecyclerView -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/dp_6"
android:paddingRight="@dimen/dp_6"
android:paddingBottom="@dimen/dp_12"
tools:itemCount="1"
tools:listitem="@layout/item_cirle_list" />
<!-- 评论列表 ScrollView -->
<!-- <ScrollView-->
<!-- android:id="@+id/scroll_view"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_weight="1"-->
<!-- android:background="@drawable/bg_r16_fff">-->
<!-- 评论列表 ScrollView -->
<!-- <ScrollView-->
<!-- android:id="@+id/scroll_view"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_weight="1"-->
<!-- android:background="@drawable/bg_r16_fff">-->
<LinearLayout
android:layout_width="match_parent"
@@ -89,48 +88,48 @@
</LinearLayout>
<!-- 输入区域,始终位于底部 -->
<LinearLayout
android:id="@+id/cl_input"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_70"
android:background="#ffffff"
android:orientation="horizontal"
android:paddingVertical="@dimen/dp_8">
<!-- 输入区域,始终位于底部 -->
<LinearLayout
android:id="@+id/cl_input"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_70"
android:background="#ffffff"
android:orientation="horizontal"
android:paddingVertical="@dimen/dp_8">
<EditText
android:id="@+id/et_input"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_marginStart="@dimen/dp_16"
android:layout_marginEnd="@dimen/dp_8"
android:layout_weight="1"
android:background="@drawable/bg_r80_hui"
android:gravity="center_vertical"
android:hint="就差你一个神评论~"
android:paddingStart="@dimen/dp_12"
android:textSize="@dimen/sp_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tv_send"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_input"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_marginStart="@dimen/dp_16"
android:layout_marginEnd="@dimen/dp_8"
android:layout_weight="1"
android:background="@drawable/bg_r80_hui"
android:gravity="center_vertical"
android:hint="就差你一个神评论~"
android:paddingStart="@dimen/dp_12"
android:textSize="@dimen/sp_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tv_send"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_send"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_30"
android:layout_marginEnd="@dimen/dp_12"
android:background="@drawable/cs"
android:gravity="center"
android:text="发送"
android:textColor="@color/color_FF333333"
android:textSize="@dimen/sp_12"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_send"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_30"
android:layout_marginEnd="@dimen/dp_12"
android:background="@drawable/cs"
android:gravity="center"
android:text="发送"
android:textColor="@color/color_FF333333"
android:textSize="@dimen/sp_12"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>

View File

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