| | |
| | | import android.webkit.WebResourceResponse; |
| | | import android.webkit.WebView; |
| | | import android.webkit.WebViewClient; |
| | | import android.widget.RelativeLayout; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | MyLog.i(data); |
| | | MarkerBean markerBean = markerBeanSet.get(data); |
| | | if (markerBean != null) { |
| | | setWebViewParams(false); |
| | | getInstakeDetail(markerBean); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | |
| | | 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 -> { |
| | |
| | | public void setMapMarker(MarkerBean markerBean) { |
| | | if (markerBean != null) { |
| | | if (webViewIsFinished) { |
| | | mWebView.evaluateJavascript("javascript:addMarker(\"" + markerBean.getId() + "\",\"" + markerBean.getLng() + "\",\"" + markerBean.getLat() + "\",\"" + markerBean.getName() + "\")", new ValueCallback<String>() { |
| | | @Override |
| | | public void onReceiveValue(String value) { |
| | | } |
| | | }); |
| | | markerBeanSet.put(markerBean.getId(), markerBean); |
| | | |
| | | if (!TextUtils.isEmpty(markerBean.getLng()) && !TextUtils.isEmpty(markerBean.getLat())) { |
| | | mWebView.evaluateJavascript("javascript:addMarker(\"" + markerBean.getId() + "\",\"" + markerBean.getLng() + "\",\"" + markerBean.getLat() + "\",\"" + markerBean.getName() + "\")", new ValueCallback<String>() { |
| | | @Override |
| | | public void onReceiveValue(String value) { |
| | | } |
| | | }); |
| | | markerBeanSet.put(markerBean.getId(), markerBean); |
| | | } else { |
| | | MyLog.d("setMapMarker>" + markerBean.getName() + "经纬度为空"); |
| | | } |
| | | } else { |
| | | webNoFinishMarkerData.add(markerBean); |
| | | } |
| | |
| | | */ |
| | | 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("暂停"); |
| | |
| | | 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 -> { |
| | | |
| | | }); |
| | | } |
| | | ); |
| | |
| | | }); |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |