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 | 191 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 184 insertions(+), 7 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 eb3a256..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,15 +1,30 @@
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;
+
+import com.dayu.pipirrapp.MyApplication;
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;
@@ -26,17 +41,46 @@
private static final String TAG = "InspectionUtils";
//鎵撶偣鐨勬渶灏忎袱鐐规渶灏忚窛绂�
private static final int MinMeters = 10;
+ //0娌℃湁寮�濮嬶紝1寮�濮嬶紝2鏆傚仠,3鍏抽棴,4鏄偣鍑荤殑寮�濮嬫寜閽�
+ public static final int NO_INSPECTION = 0;
+ public static final int STAT_INSPECTION = 1;
+ public static final int STAT_INSPECTION_ONCLICK = 4;
+ public static final int PAUSE_INSPECTION = 2;
+ public static final int STOP_INSPECTION = 3;
+
/**
* 鑾峰彇褰撳墠宸℃璁板綍ID
*
- * @param context
+ * @param fragment
* @return
*/
- public static String getInspectionId(Context context) {
+ 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()
+ .subscribeOn(Schedulers.io())
+ .observeOn(Schedulers.io()).subscribe(inspectionBean -> {
+ fragment.mInspectionBean = inspectionBean;
+ // 鏌ヨ褰撳墠鏈叧闂殑宸℃璁板綍涓嬫墍鏈夌殑鍧愭爣
+ DaoSingleton.getAsynchInstance(fragment.getContext()).inspectionLocationDao().findBymInspectId(inspectionBean.getmInspectId()).subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread()).subscribe(inspectionLocationBeans -> {
+ fragment.aginShowLocation(inspectionLocationBeans);
+ });
+ });
}
@@ -49,8 +93,11 @@
public static InspectionBean startInspection(Context context) {
// 鍒涘缓宸℃璁板綍
InspectionBean inspectionBean = new InspectionBean();
- inspectionBean.setInspectId(UUID.randomUUID().toString());
+ inspectionBean.setmInspectId(UUID.randomUUID().toString());
inspectionBean.setStartTime(DateUtils.getNowDateStr());
+ inspectionBean.setId(UUID.randomUUID().toString());
+ inspectionBean.setInspectorId(MyApplication.myApplication.userId);
+// inspectionBean.
// 寮傛鎻掑叆鍒版暟鎹簱
DaoSingleton.getAsynchInstance(context)
.inspectionDao()
@@ -60,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; // 鎻掑叆瀹屾垚鍚庡垏鎹㈠埌涓荤嚎绋�
@@ -74,7 +121,97 @@
* @param locationBean
*/
public static void addInspectionLocationData(Context context, InspectionLocationBean locationBean) {
- DaoSingleton.getAsynchInstance(context).inspectionLocationDao().insert(locationBean).subscribeOn(Schedulers.io());
+ DaoSingleton.getAsynchInstance(context).inspectionLocationDao().insert(locationBean).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
+ .subscribe(() -> {
+ // 鎻掑叆鎴愬姛鐨勫洖璋�
+ Log.d(TAG, "addInspectionLocationData鏁版嵁鎻掑叆鎴愬姛");
+ }, throwable -> {
+ // 澶勭悊閿欒
+ Log.e(TAG, "addInspectionLocationData鏁版嵁鎻掑叆澶辫触", throwable);
+ });
+ ;
+ }
+
+
+ //涓婁紶鍥犵綉缁滈棶棰樹骇鐢熺殑鏈笂浼犳暟鎹�
+ 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);
+ }
+
+ }
+ });
}
/**
@@ -83,8 +220,32 @@
* @param context
* @param locationBean
*/
+ @Transaction
public static void updateInspectionLocationData(Context context, InspectionLocationBean locationBean) {
- DaoSingleton.getAsynchInstance(context).inspectionLocationDao().update(locationBean).subscribeOn(Schedulers.io());
+ DaoSingleton.getAsynchInstance(context).inspectionLocationDao().update(locationBean).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
+ .subscribe(() -> {
+ // 鎻掑叆鎴愬姛鐨勫洖璋�
+ Log.d(TAG, "updateInspectionLocationData鏁版嵁鎻掑叆鎴愬姛");
+ }, throwable -> {
+ // 澶勭悊閿欒
+ 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);
+ });
}
/**
@@ -109,4 +270,20 @@
}
}
+
+ /**
+ * 鍒涘缓InspectionLocationBean
+ */
+ public static InspectionLocationBean createInspectionLocation(LatLonBean latLonBean, InspectionBean mInspectionBean) {
+ InspectionLocationBean inspectionLocationBean = new InspectionLocationBean();
+ inspectionLocationBean.setId(UUID.randomUUID().toString());
+ inspectionLocationBean.setInspectId(mInspectionBean.getInspectId());
+ inspectionLocationBean.setmInspectId(mInspectionBean.getmInspectId());
+ inspectionLocationBean.setLocateTime(DateUtils.getNowDateStr());
+ inspectionLocationBean.setPost(false);
+ inspectionLocationBean.setLng(String.valueOf(latLonBean.getLongitude()));
+ inspectionLocationBean.setLat(String.valueOf(latLonBean.getLatitude()));
+ return inspectionLocationBean;
+ }
+
}
--
Gitblit v1.8.0