From 6a44973461e2a91f62f7eed681b4db3abb026289 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期二, 24 十二月 2024 16:52:23 +0800
Subject: [PATCH] 1.优化地图相关代码,提高运行效率和可读性。 2.添加修改密码功能。 3.优化列表和详情页展示。
---
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
index 9266ffb..aff517f 100644
--- a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
+++ b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
@@ -17,7 +17,6 @@
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -38,7 +37,6 @@
import com.dayu.pipirrapp.bean.net.MarkerResult;
import com.dayu.pipirrapp.dao.DaoSingleton;
import com.dayu.pipirrapp.databinding.FragmentMapBinding;
-import com.dayu.pipirrapp.tool.MyWebViewInterface;
import com.dayu.pipirrapp.net.ApiManager;
import com.dayu.pipirrapp.net.BaseResponse;
import com.dayu.pipirrapp.net.Constants;
@@ -46,6 +44,7 @@
import com.dayu.pipirrapp.observer.MapFragmenObserver;
import com.dayu.pipirrapp.tool.InspectionUtils;
import com.dayu.pipirrapp.tool.MarkerUtils;
+import com.dayu.pipirrapp.tool.MyWebViewInterface;
import com.dayu.pipirrapp.utils.CommonData;
import com.dayu.pipirrapp.utils.CommonKeyName;
import com.dayu.pipirrapp.utils.DateUtils;
@@ -339,7 +338,6 @@
MyLog.i(data);
MarkerBean markerBean = markerBeanSet.get(data);
if (markerBean != null) {
- setWebViewParams(false);
getInstakeDetail(markerBean);
}
@@ -398,6 +396,7 @@
try {
if (t.isSuccess()) {
if (t.getContent() != null) {
+ MyLog.d("InspectId:" + String.valueOf(t.getContent().get(0).getInspectId()));
mInspectionBean.setInspectId(String.valueOf(t.getContent().get(0).getInspectId()));
InspectionUtils.upataInspectionData(MapFragment.this.getContext(), mInspectionBean);
}
@@ -429,6 +428,7 @@
lastLatLonBean = latLonBean;
Log.i("chageInspecState", "lat:" + latLonBean.getLatitude() + ",log:" + latLonBean.getLongitude());
InspectionLocationBean inspectionLocationBean = InspectionUtils.createInspectionLocation(latLonBean, mInspectionBean);
+ //娣诲姞宸℃璁板綍鍧愭爣
InspectionUtils.addInspectionLocationData(MapFragment.this.getContext(), inspectionLocationBean);
//鏇存柊鍒板湴鍥�
mWebView.evaluateJavascript("javascript:updateInspectionLocation(\"" + latLonBean.getLongitude() + "\",\"" + latLonBean.getLatitude() + "\")", value -> {
@@ -577,7 +577,7 @@
*/
private void startLocation() {
//鑾峰彇瀹氫綅鏈嶅姟浼犺繃鏉ョ殑鍧愭爣鐐�
- LiveEventBus.get(CommonKeyName.locationData).observeForever(locationObserver);
+ LiveEventBus.get(CommonKeyName.locationData).observe(this, locationObserver);
binding.inspectRL.setVisibility(View.VISIBLE);
binding.inspectButton.setVisibility(View.GONE);
binding.inspectPause.setText("鏆傚仠");
@@ -726,17 +726,20 @@
binding.lng.setText(markerBean.getLng());
//淇敼缁忕含搴�
binding.editePoint.setOnClickListener(v -> {
+
mWebView.evaluateJavascript("javascript:showPin(\"" + markerBean.getLng() + "\",\"" + markerBean.getLat() + "\")", value -> {
+ binding.pointRL.setVisibility(View.VISIBLE);
+ binding.pointCenterImg.setVisibility(View.VISIBLE);
+ MyLog.d("showPin>>" + value);
});
- binding.pointRL.setVisibility(View.VISIBLE);
- binding.pointCenterImg.setVisibility(View.VISIBLE);
- setWebViewParams(true);
+
});
//鍙栨秷淇敼缁忕含搴�
binding.pointCancel.setOnClickListener(v -> {
binding.pointCenterImg.setVisibility(View.GONE);
binding.pointRL.setVisibility(View.GONE);
mWebView.evaluateJavascript("javascript:cancelPin()", value -> {
+
});
}
);
@@ -750,14 +753,11 @@
});
}
- private void setWebViewParams(boolean isAbove) {
- RelativeLayout.LayoutParams paramsAnotherView = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.MATCH_PARENT,
- RelativeLayout.LayoutParams.MATCH_PARENT);
- if (isAbove) {
- paramsAnotherView.addRule(RelativeLayout.ABOVE, binding.bottomLL.getId());
- }
- binding.webViewRL.setLayoutParams(paramsAnotherView);
- }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ LiveEventBus.get(CommonKeyName.locationData).removeObserver(locationObserver);
+ }
}
--
Gitblit v1.8.0