From 4f7f99c6ea914bcd38de78bd8371be566026b905 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期三, 26 二月 2025 15:54:14 +0800
Subject: [PATCH] -为按钮和列表项添加波纹效果,以获得更好的视觉反馈 -改进MapFragment中的底部布局动画 -在MapFragment中添加设备状态和RTU地址显示 -更新BaseListResult以支持泛型类型 -为设备数据添加IntakeListResult和IntakeResult -通过数据库支持增强标记位置更新功能 -添加电话拨号意图以分隔标记详细信息 -通过过期检查改进磁贴缓存 -添加问题报告的确认对话框 -更新登录活动以限制用户名长度 -为波纹效果和UI元素添加新颜色 -重构XML布局以使用新的波纹图 -改进MapFragment中的错误处理和用户反馈
---
app/src/main/java/com/dayu/pipirrapp/net/MyIntercepterApplication.java | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/app/src/main/java/com/dayu/pipirrapp/net/MyIntercepterApplication.java b/app/src/main/java/com/dayu/pipirrapp/net/MyIntercepterApplication.java
index 9b712f1..67b62ab 100644
--- a/app/src/main/java/com/dayu/pipirrapp/net/MyIntercepterApplication.java
+++ b/app/src/main/java/com/dayu/pipirrapp/net/MyIntercepterApplication.java
@@ -1,12 +1,13 @@
package com.dayu.pipirrapp.net;
+import android.text.TextUtils;
+
import com.dayu.pipirrapp.MyApplication;
-import com.dayu.pipirrapp.utils.SharedPreferencesHelper;
-import com.dayu.pipirrapp.utils.ToastUtil;
+import com.dayu.pipirrapp.utils.NetUtils;
import com.tencent.bugly.crashreport.CrashReport;
-
import java.io.IOException;
+import java.net.ConnectException;
import java.util.HashMap;
import java.util.Map;
@@ -29,13 +30,20 @@
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
try {
+ if (NetUtils.isNetworkAvailable(MyApplication.myApplication)) {
+ Request myRequest = createRequest(chain.request());
+ Response response = null;
+ try {
+ response = chain.proceed(myRequest);
+ } catch (ConnectException e) {
+ e.printStackTrace();
+ return getNullResponse(request);
+ }
- Request myRequest = createRequest(chain.request());
- if (myRequest != null) {
- Response response = chain.proceed(myRequest);
return response;
} else {
- ToastUtil.showToastLong(MyApplication.myApplication, "璇锋鏌ョ綉缁滆繛鎺�!!");
+ return getNullResponse(request);
+
}
} catch (Exception e) {
e.printStackTrace();
@@ -48,7 +56,7 @@
try {
Request.Builder builder = request.newBuilder();
Map params = new HashMap();
- if (request.method().equals("GET")) {
+ if ("GET".equals(request.method())) {
builder.url(request.url().toString());
} else {
@@ -60,8 +68,12 @@
}
}
builder.addHeader("os", "app");
- builder.addHeader("Authorization", SharedPreferencesHelper.getInstance(MyApplication.myApplication).get("token", ""));
+ if (!TextUtils.isEmpty(MyApplication.myApplication.token)) {
+ builder.addHeader("token", MyApplication.myApplication.token);
+ }
+
}
+ builder.addHeader("tag", MyApplication.myApplication.myTag);
return builder.build();
} catch (Exception e) {
e.printStackTrace();
@@ -80,7 +92,7 @@
public Response getNullResponse(Request request) {
int code = 20010;
String message = "鍜︼紝璇锋鏌ョ綉缁�";
- String errJson = "{\"code\":" + code + ",\"message\":\"" + message + "\"}";
+ String errJson = "{\"code\":" + code + ",\"msg\":\"" + message + "\"}";
Response.Builder builder = new Response.Builder().body(ResponseBody.create(MediaType.parse("application/json"), errJson));
builder.request(request);
builder.protocol(Protocol.HTTP_1_1);
@@ -88,4 +100,6 @@
builder.message(message);
return builder.build();
}
+
+
}
--
Gitblit v1.8.0