1:添加备用服务器,在请求themeData的时候,返回的不对的时候,就切换服务器
This commit is contained in:
@@ -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>() {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user