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/tool/InspectionUtils.java | 123 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 118 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/com/dayu/pipirrapp/tool/InspectionUtils.java b/app/src/main/java/com/dayu/pipirrapp/tool/InspectionUtils.java
index b14376b..0da7abd 100644
--- a/app/src/main/java/com/dayu/pipirrapp/tool/InspectionUtils.java
+++ b/app/src/main/java/com/dayu/pipirrapp/tool/InspectionUtils.java
@@ -1,7 +1,10 @@
package com.dayu.pipirrapp.tool;
+import static com.dayu.pipirrapp.net.Constants.BASE_URL;
+
import android.content.Context;
import android.location.Location;
+import android.text.TextUtils;
import android.util.Log;
import androidx.room.Transaction;
@@ -10,10 +13,18 @@
import com.dayu.pipirrapp.bean.db.InspectionBean;
import com.dayu.pipirrapp.bean.db.InspectionLocationBean;
import com.dayu.pipirrapp.bean.db.LatLonBean;
+import com.dayu.pipirrapp.bean.net.InsectionResult;
+import com.dayu.pipirrapp.bean.net.InspectionRequest;
import com.dayu.pipirrapp.dao.DaoSingleton;
import com.dayu.pipirrapp.fragment.MapFragment;
+import com.dayu.pipirrapp.net.ApiManager;
+import com.dayu.pipirrapp.net.BaseResponse;
+import com.dayu.pipirrapp.net.subscribers.SubscriberListener;
import com.dayu.pipirrapp.utils.DateUtils;
+import com.dayu.pipirrapp.utils.MyLog;
+import com.tencent.bugly.crashreport.CrashReport;
+import java.util.List;
import java.util.UUID;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
@@ -44,16 +55,20 @@
* @param fragment
* @return
*/
- public static String getInspectionId(MapFragment fragment) {
+ public static void getInspectionId(MapFragment fragment) {
DaoSingleton.getAsynchInstance(fragment.getContext()).inspectionDao().getMostRecentInspectionWithNoStopTime()
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io()).subscribe(inspectionBean -> {
});
- return "";
}
+ /**
+ * 缁х画鏄剧ず寮傚父鍏抽棴涔嬪墠鐨勫贰妫�鍧愭爣
+ *
+ * @param fragment
+ */
public static void aginShowLocation(MapFragment fragment) {
//鏌ヨ褰撳墠鏈叧闂殑宸℃璁板綍
DaoSingleton.getAsynchInstance(fragment.getContext()).inspectionDao().getMostRecentInspectionWithNoStopTime()
@@ -61,7 +76,7 @@
.observeOn(Schedulers.io()).subscribe(inspectionBean -> {
fragment.mInspectionBean = inspectionBean;
// 鏌ヨ褰撳墠鏈叧闂殑宸℃璁板綍涓嬫墍鏈夌殑鍧愭爣
- DaoSingleton.getAsynchInstance(fragment.getContext()).inspectionLocationDao().findByInspectId(inspectionBean.getmInspectId()).subscribeOn(Schedulers.io())
+ DaoSingleton.getAsynchInstance(fragment.getContext()).inspectionLocationDao().findBymInspectId(inspectionBean.getmInspectId()).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(inspectionLocationBeans -> {
fragment.aginShowLocation(inspectionLocationBeans);
});
@@ -80,6 +95,8 @@
InspectionBean inspectionBean = new InspectionBean();
inspectionBean.setmInspectId(UUID.randomUUID().toString());
inspectionBean.setStartTime(DateUtils.getNowDateStr());
+ inspectionBean.setId(UUID.randomUUID().toString());
+ inspectionBean.setInspectorId(MyApplication.myApplication.userId);
// inspectionBean.
// 寮傛鎻掑叆鍒版暟鎹簱
DaoSingleton.getAsynchInstance(context)
@@ -90,7 +107,7 @@
.subscribe(() -> {
Log.i(TAG, "Inspection started and inserted successfully.");
}, throwable -> {
- Log.e(TAG, "Error inserting inspection data: "+throwable);
+ Log.e(TAG, "Error inserting inspection data: " + throwable);
});
// 鑾峰彇Dao骞舵墽琛屾彃鍏ユ搷浣�
return inspectionBean; // 鎻掑叆瀹屾垚鍚庡垏鎹㈠埌涓荤嚎绋�
@@ -115,6 +132,88 @@
;
}
+
+ //涓婁紶鍥犵綉缁滈棶棰樹骇鐢熺殑鏈笂浼犳暟鎹�
+ public static void aginPutInspectionData(Context context) {
+ //鏌ヨ娌℃湁涓婁紶鐨勬墍鏈夋湰鍦版暟鎹簱鐨勫贰妫�id
+ DaoSingleton.getAsynchInstance(context).inspectionLocationDao().getUnpostedMInspectIds()
+ .subscribeOn(Schedulers.io())
+ .observeOn(Schedulers.io())
+ .subscribe(strings -> {
+ //寰幆鏌ヨ鎵�鏈塱d
+ for (String data : strings) {
+ if (!TextUtils.isEmpty(data)) {
+ DaoSingleton.getAsynchInstance(context).inspectionDao().findBymInspectId(data)
+ .subscribeOn(Schedulers.io())
+ .observeOn(Schedulers.io())
+ .subscribe(inspectionBeans -> {
+ DaoSingleton.getAsynchInstance(context).inspectionLocationDao().findByNoPostAndInspectId(data)
+ .subscribeOn(Schedulers.io())
+ .observeOn(Schedulers.io())
+ .subscribe(inspectionLocationBeans -> {
+ if (inspectionLocationBeans != null && inspectionLocationBeans.size() > 0) {
+ postInspectionData(context, inspectionBeans, inspectionLocationBeans);
+ }
+ });
+ });
+ }
+ }
+
+ });
+ }
+
+
+ /**
+ * 涓婁紶鏈笂浼犳垚鍔熺殑鍧愭爣
+ *
+ * @param inspectionBean
+ * @param inspectionLocationBeans
+ */
+ private static void postInspectionData(Context context, InspectionBean inspectionBean, List<InspectionLocationBean> inspectionLocationBeans) {
+ MyLog.d("postInspectionData>>>涓婁紶鏈笂浼犳垚鍔熺殑鏁版嵁");
+ InspectionRequest inspectionRequest = new InspectionRequest();
+ inspectionRequest.setInspectId(inspectionBean.getInspectId());
+ inspectionRequest.setInspectorId(inspectionBean.getInspectorId());
+ inspectionRequest.setStartTime(inspectionBean.getStartTime());
+ if (!TextUtils.isEmpty(inspectionBean.getStopTime())) {
+ inspectionRequest.setStopTime(inspectionBean.getStopTime());
+ }
+ for (InspectionLocationBean inspectionLocationBean : inspectionLocationBeans) {
+ InspectionRequest.Track track = new InspectionRequest.Track();
+ track.setLat(inspectionLocationBean.getLat());
+ track.setLng(inspectionLocationBean.getLng());
+ track.setLocateTime(inspectionLocationBean.getLocateTime());
+ inspectionRequest.addTracks(track);
+ }
+ ApiManager.getInstance().requestPostHideLoading(context, BASE_URL + "/app/inspect/save", InsectionResult.class, inspectionRequest.toMap(inspectionRequest), new SubscriberListener<BaseResponse<List<InsectionResult>>>() {
+ @Override
+ public void onNext(BaseResponse<List<InsectionResult>> t) {
+ try {
+ if (t.isSuccess()) {
+ MyLog.d("postInspectionData>>>涓婁紶鏈笂浼犳垚鍔熺殑鏁版嵁銆嬨�嬨�嬨�嬫垚鍔�");
+ if (t.getContent() != null) {
+ inspectionBean.setInspectId(String.valueOf(t.getContent().get(0).getInspectId()));
+ InspectionUtils.upataInspectionData(context, inspectionBean);
+ }
+ DaoSingleton.getAsynchInstance(context).inspectionLocationDao().updataByInspectIdSetIsPost(inspectionBean.getmInspectId()).subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(() -> {
+ // 鎻掑叆鎴愬姛鐨勫洖璋�
+ Log.d(TAG, "updataByInspectIdSetIsPost鏁版嵁鎻掑叆鎴愬姛");
+ }, throwable -> {
+ // 澶勭悊閿欒
+ Log.e(TAG, "updataByInspectIdSetIsPost鏁版嵁鎻掑叆澶辫触", throwable);
+ });
+ } else {
+ MyLog.d("postInspectionData>>>涓婁紶鏈笂浼犳垚鍔熺殑鏁版嵁銆嬨�嬨�嬨�嬪け璐�");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ CrashReport.postCatchedException(e);
+ }
+
+ }
+ });
+ }
+
/**
* 淇敼宸℃璁板綍鍧愭爣
*
@@ -132,6 +231,21 @@
Log.e(TAG, "updateInspectionLocationData鏁版嵁鎻掑叆澶辫触", throwable);
});
;
+ }
+
+ /**
+ * 淇敼宸℃淇℃伅
+ *
+ * @param context
+ * @param inspectionBean
+ */
+ public static void upataInspectionData(Context context, InspectionBean inspectionBean) {
+ DaoSingleton.getAsynchInstance(context).inspectionDao().update(inspectionBean).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(() -> {
+ // 鎻掑叆鎴愬姛鐨勫洖璋�
+ Log.d(TAG, "uupataInspectionData鏁版嵁鎻掑叆鎴愬姛");
+ }, throwable -> {
+ Log.e(TAG, "upataInspectionData鏁版嵁鎻掑叆澶辫触", throwable);
+ });
}
/**
@@ -167,7 +281,6 @@
inspectionLocationBean.setmInspectId(mInspectionBean.getmInspectId());
inspectionLocationBean.setLocateTime(DateUtils.getNowDateStr());
inspectionLocationBean.setPost(false);
- inspectionLocationBean.setInspectorId(MyApplication.myApplication.userId);
inspectionLocationBean.setLng(String.valueOf(latLonBean.getLongitude()));
inspectionLocationBean.setLat(String.valueOf(latLonBean.getLatitude()));
return inspectionLocationBean;
--
Gitblit v1.8.0