新的上架提交
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package com.xscm.moduleutil.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
|
||||
import static com.blankj.utilcode.util.ActivityUtils.startActivity;
|
||||
|
||||
public class CrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
private static CrashHandler instance;
|
||||
private Thread.UncaughtExceptionHandler defaultHandler;
|
||||
@@ -36,6 +39,10 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
private void restartApp() {
|
||||
// 实现应用重启逻辑
|
||||
ARouter.getInstance().build(ARouteConstants.ME).navigation();
|
||||
// ARouter.getInstance().build(ARouteConstants.ME).navigation();
|
||||
|
||||
Intent intent = new Intent("com.qxcm.qxlive.LAUNCH_PAGE");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +196,21 @@ public class ImageUtils {
|
||||
}
|
||||
Glide.with(mImageView).load(path).error(R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(mImageView);
|
||||
|
||||
}
|
||||
public static void loadHeadCCTask(String path, ImageView mImageView,int errorImage) {
|
||||
if (mImageView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = mImageView.getContext();
|
||||
if (context instanceof android.app.Activity) {
|
||||
android.app.Activity activity = (android.app.Activity) context;
|
||||
if (activity.isFinishing() || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Glide.with(mImageView).load(path).error(errorImage).placeholder(errorImage).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(mImageView);
|
||||
|
||||
}
|
||||
|
||||
public static void loadCompressImg(String path, ImageView mImageView, int width, int height) {
|
||||
|
||||
@@ -15,7 +15,7 @@ public enum EnvironmentEnum {
|
||||
"3e8f3add448d4692bc1d04c75ffe801b",
|
||||
"tcp://81.70.45.221",
|
||||
"https://vespa.qxyushen.top/h5",
|
||||
1),
|
||||
0),
|
||||
TEST(//测试环境
|
||||
"https://test.vespa.qxyushen.top/",
|
||||
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.xscm.moduleutil.utils.logger;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* com.xscm.moduleutil.utils.logger
|
||||
* qx
|
||||
* 2025/11/6
|
||||
*/
|
||||
public class BaseUrlSwitcherInterceptor implements Interceptor {
|
||||
private List<String> baseUrls;
|
||||
private int currentIndex = 0;
|
||||
|
||||
public BaseUrlSwitcherInterceptor(List<String> baseUrls) {
|
||||
this.baseUrls = baseUrls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
HttpUrl originalHttpUrl = request.url();
|
||||
|
||||
// 获取当前应该使用的 baseUrl
|
||||
String currentBaseUrl = baseUrls.get(currentIndex);
|
||||
HttpUrl newBaseUrl = HttpUrl.parse(currentBaseUrl);
|
||||
|
||||
if (newBaseUrl == null) {
|
||||
throw new IllegalArgumentException("Invalid base url: " + currentBaseUrl);
|
||||
}
|
||||
|
||||
// 构建新的 HttpUrl
|
||||
HttpUrl newUrl = originalHttpUrl.newBuilder()
|
||||
.scheme(newBaseUrl.scheme())
|
||||
.host(newBaseUrl.host())
|
||||
.port(newBaseUrl.port())
|
||||
.build();
|
||||
|
||||
Request.Builder builder = request.newBuilder().url(newUrl);
|
||||
Request newRequest = builder.build();
|
||||
|
||||
// 尝试执行请求
|
||||
try {
|
||||
return chain.proceed(newRequest);
|
||||
} catch (IOException e) {
|
||||
// 如果请求失败,则切换到下一个 baseUrl 并重试
|
||||
currentIndex = (currentIndex + 1) % baseUrls.size();
|
||||
return intercept(chain); // 递归调用重新构建请求
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user