| | |
| | | |
| | | import com.dayu.pipirrapp.R; |
| | | import com.dayu.pipirrapp.bean.db.InspectionLocationBean; |
| | | import com.dayu.pipirrapp.bean.net.InspectListResult; |
| | | import com.dayu.pipirrapp.bean.net.InspectPointResult; |
| | | import com.dayu.pipirrapp.dao.DaoSingleton; |
| | | import com.dayu.pipirrapp.net.ApiManager; |
| | | import com.dayu.pipirrapp.net.BaseResponse; |
| | | import com.dayu.pipirrapp.net.Constants; |
| | | import com.dayu.pipirrapp.net.subscribers.SubscriberListener; |
| | | import com.dayu.pipirrapp.utils.CommonData; |
| | | import com.dayu.pipirrapp.utils.MapJpgUtils; |
| | | import com.dayu.pipirrapp.view.TitleBar; |
| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; |
| | | import io.reactivex.rxjava3.schedulers.Schedulers; |
| | |
| | | // 查询当前未关闭的巡检记录下所有的坐标 |
| | | DaoSingleton.getAsynchInstance(this).inspectionLocationDao().findByInspectId(inspectId).subscribeOn(Schedulers.io()) |
| | | .observeOn(AndroidSchedulers.mainThread()).subscribe(inspectionLocationBeans -> { |
| | | aginShowLocation(inspectionLocationBeans); |
| | | if (inspectionLocationBeans != null && inspectionLocationBeans.size() > 0) { |
| | | aginShowLocation(inspectionLocationBeans); |
| | | } else { |
| | | getHttpLocation(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | } else { |
| | | isEnd = false; |
| | | } |
| | | Log.i("mWebView", "showHistoryLocation" + inspectionLocationBean.getLng() + "\",\"" + inspectionLocationBean.getLat()); |
| | | mWebView.evaluateJavascript("javascript:showHistoryLocation(\"" + inspectionLocationBean.getLng() + "\",\"" + inspectionLocationBean.getLat() + "\",\"" + isStart + "\",\"" + isEnd + "\")", value -> { |
| | | }); |
| | | putDataToWeb(inspectionLocationBean.getLng(), inspectionLocationBean.getLat(), isStart + "", isEnd + ""); |
| | | index++; |
| | | } |
| | | // 向 WebView 注入数据 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 向 WebView 注入数据 |
| | | * |
| | | * @param lng |
| | | * @param lat |
| | | * @param isStart |
| | | * @param isEnd |
| | | */ |
| | | private void putDataToWeb(String lng, String lat, String isStart, String isEnd) { |
| | | Log.i("mWebView", "showHistoryLocation" + lng + "\",\"" + lat); |
| | | mWebView.evaluateJavascript("javascript:showHistoryLocation(\"" + lng + "\",\"" + lat + "\",\"" + isStart + "\",\"" + isEnd + "\")", value -> { |
| | | }); |
| | | } |
| | | |
| | | public void getHttpLocation() { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("inspectId", inspectId); |
| | | ApiManager.getInstance().requestGet(this, Constants.BASE_URL + "/app/inspect/getInspects", InspectListResult.class, params, new SubscriberListener<BaseResponse<InspectListResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<InspectListResult> t) { |
| | | if (t.isSuccess()) { |
| | | if (t.getContent() != null) { |
| | | List<InspectionLocationBean> locationBeans = new ArrayList<>(); |
| | | if (t.getContent().getObj()!=null&&t.getContent().getObj().size()>0){ |
| | | for (InspectPointResult inspectPointResult : t.getContent().getObj().get(0).getTracks()) { |
| | | InspectionLocationBean inspectionLocationBean = new InspectionLocationBean(); |
| | | inspectionLocationBean.setLng(inspectPointResult.getLng()); |
| | | inspectionLocationBean.setLat(inspectPointResult.getLat()); |
| | | inspectionLocationBean.setInspectId(inspectId); |
| | | inspectionLocationBean.setId(inspectPointResult.getId()); |
| | | inspectionLocationBean.setLocateTime(inspectPointResult.getLocateTime()); |
| | | locationBeans.add(inspectionLocationBean); |
| | | } |
| | | } |
| | | aginShowLocation(locationBeans); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCloose() { |
| | | super.onCloose(); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(Throwable e) { |
| | | super.onError(e); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |