From 798128053bb17ed293aa8d5424db3b5ed007d375 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期一, 23 十二月 2024 10:20:57 +0800 Subject: [PATCH] 1.优化订单列表框架,升级为viewPager2,提升性能。 2.添加收到新工单后的红点提醒。 3.修复查询数据为空时报错。 4.优化修改经纬度的流程。 5.修复mqtt的CLIENT_ID一致导致的连接错误。 6.修复收到新工单后点击消息通知栏跳转详情时不更新数据的bug。 --- app/src/main/java/com/dayu/pipirrapp/net/MyIntercepterApplication.java | 33 ++++++++++++++++++++++++--------- 1 files changed, 24 insertions(+), 9 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..2fa9142 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(); @@ -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,7 @@ builder.message(message); return builder.build(); } + + + } -- Gitblit v1.8.0