1.巡检记录列表页的实现
2.巡检记录地图展示路径的详情页。
3.处理巡检记录详情页因打开同一个网址导致的webView不显示问题。
4.实现地图页搜索后的地图跳转功能。
5.巡检记录详情页数据加载的优化,默认加载本地数据,当本地没有数据时从服务端获取数据。
| | |
| | | <activity android:name=".activity.AddIssueActivity" /> |
| | | <activity android:name=".activity.IssueListActivity" /> |
| | | <activity android:name=".activity.IssueDetailActivity" /> |
| | | <activity android:name=".activity.InspectListActivity"/> |
| | | <activity android:name=".activity.InspectDetailActivity"/> |
| | | |
| | | |
| | | <!-- <activity android:name=".activity.MainActivity" />--> |
New file |
| | |
| | | <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" |
| | | viewBox="0 0 24 24" width="24px" fill="#D81E06"> |
| | | <rect fill="none" height="24" width="24" /> |
| | | <path |
| | | d="M12,2L12,2C8.13,2,5,5.13,5,9c0,1.74,0.5,3.37,1.41,4.84c0.95,1.54,2.2,2.86,3.16,4.4c0.47,0.75,0.81,1.45,1.17,2.26 C11,21.05,11.21,22,12,22h0c0.79,0,1-0.95,1.25-1.5c0.37-0.81,0.7-1.51,1.17-2.26c0.96-1.53,2.21-2.85,3.16-4.4 C18.5,12.37,19,10.74,19,9C19,5.13,15.87,2,12,2z" /> |
| | | <text x="12" y="12" text-anchor="middle" fill="white" font-size="8" |
| | | font-family="Arial, sans-serif">终 |
| | | </text> |
| | | </svg> |
New file |
| | |
| | | <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" |
| | | viewBox="0 0 24 24" width="24px" fill="#1890FF"> |
| | | <rect fill="none" height="24" width="24" /> |
| | | <path |
| | | d="M12,2L12,2C8.13,2,5,5.13,5,9c0,1.74,0.5,3.37,1.41,4.84c0.95,1.54,2.2,2.86,3.16,4.4c0.47,0.75,0.81,1.45,1.17,2.26 C11,21.05,11.21,22,12,22h0c0.79,0,1-0.95,1.25-1.5c0.37-0.81,0.7-1.51,1.17-2.26c0.96-1.53,2.21-2.85,3.16-4.4 C18.5,12.37,19,10.74,19,9C19,5.13,15.87,2,12,2z" /> |
| | | <text x="12" y="12" text-anchor="middle" fill="white" font-size="8" |
| | | font-family="Arial, sans-serif">起 |
| | | </text> |
| | | </svg> |
| | |
| | | MARKER_BLUE: 'img/marker_blue.svg', |
| | | CENTER_PIN: 'img/push_pin.svg', |
| | | DIVIDE_BLUE: 'img/divide_home_blue.svg', |
| | | DIVIDE_RED: 'img/divide_home_red.svg' |
| | | DIVIDE_RED: 'img/divide_home_red.svg', |
| | | MARKER_START: 'img/marker_blue_start.svg', |
| | | MARKER_END: 'img/marker_blue_end.svg' |
| | | }, |
| | | MAP: { |
| | | DEFAULT_ZOOM: 12, |
| | |
| | | window.showAllWaterIntakes = showAllWaterIntakes; |
| | | window.hideAllDivides = hideAllDivides; |
| | | window.showAllDivides = showAllDivides; |
| | | window.showHistoryLocation = showHistoryLocation; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 手机获取到定位后显示定位 |
| | | function locationOverLay(lng, lag) { |
| | | // console.log("function》》》》》locationOverLay"); |
| | | // console.log("function》》》》》locationOverLay"); |
| | | map.centerAndZoom(new T.LngLat(lng, lag), map.getZoom()); |
| | | let icon = new T.Icon({ |
| | | iconUrl: CONFIG.IMAGES.LOCATION, |
| | |
| | | //设置地图中心点 |
| | | function setCenterAndZoom(lng, lat, thiszoom) { |
| | | zoom = thiszoom; |
| | | // console.log("function》》》》》setCenterAndZoom>>>>lng:" + lng + ",lat:" + lat); |
| | | // console.log("function》》》》》setCenterAndZoom>>>>lng:" + lng + ",lat:" + lat); |
| | | map.centerAndZoom(new T.LngLat(lng, lat), zoom); |
| | | } |
| | | |
| | |
| | | }, |
| | | |
| | | addPoint(lng, lat, isNewLine, isShow) { |
| | | // console.log(`Adding point: ${lng}, ${lat}, isNewLine: ${isNewLine}`); // 添加日志 |
| | | // console.log(`Adding point: ${lng}, ${lat}, isNewLine: ${isNewLine}`); // 添加日志 |
| | | |
| | | const point = new T.LngLat(lng, lat); |
| | | |
| | |
| | | }, |
| | | |
| | | showAll() { |
| | | // console.log("showAllpipe" + this.lines.length); |
| | | // console.log("showAllpipe" + this.lines.length); |
| | | this.lines.forEach(line => { |
| | | if (line.overlay) { |
| | | map.addOverLay(line.overlay); |
| | |
| | | }, |
| | | |
| | | hideAll() { |
| | | // console.log("hideAllpipe" + this.lines.length); |
| | | // console.log("hideAllpipe" + this.lines.length); |
| | | this.lines.forEach(line => { |
| | | if (line.overlay) { |
| | | map.removeOverLay(line.overlay); |
| | |
| | | map.addOverLay(item.label); |
| | | }); |
| | | } |
| | | var historyPoint = []; |
| | | //显示历史巡检记录 |
| | | function showHistoryLocation(lng, lat, start, end) { |
| | | // 调用 Android 提供的接口,获取数据 |
| | | console.log("aginShowLocation>>lng:" + lng + ">>>lat:" + lat+">>>start:"+start+">>>end:"+end); |
| | | var newPoint = new T.LngLat(lng, lat); |
| | | historyPoint.push(newPoint); |
| | | if (start === "true" || start === true) { |
| | | map.panTo(newPoint); |
| | | let marker = new T.Marker( |
| | | newPoint, |
| | | { icon: createIcon(CONFIG.IMAGES.MARKER_START, 35) } |
| | | ); |
| | | map.addOverLay(marker); |
| | | } else if (end === "true" || end === true) { |
| | | let marker = new T.Marker( |
| | | newPoint, |
| | | { icon: createIcon(CONFIG.IMAGES.MARKER_END, 35) } |
| | | ); |
| | | map.addOverLay(marker); |
| | | } |
| | | oldLineLayer.setLngLats(historyPoint); |
| | | map.addOverLay(oldLineLayer); |
| | | } |
| | | |
| | | })(); |
| | | } |
| | | |
| | | )(); |
New file |
| | |
| | | package com.dayu.pipirrapp.activity; |
| | | |
| | | |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.webkit.ConsoleMessage; |
| | | import android.webkit.WebChromeClient; |
| | | import android.webkit.WebResourceError; |
| | | import android.webkit.WebResourceRequest; |
| | | import android.webkit.WebResourceResponse; |
| | | import android.webkit.WebSettings; |
| | | import android.webkit.WebView; |
| | | import android.webkit.WebViewClient; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | |
| | | import com.dayu.pipirrapp.R; |
| | | import com.dayu.pipirrapp.bean.db.InspectionLocationBean; |
| | | import com.dayu.pipirrapp.dao.DaoSingleton; |
| | | import com.dayu.pipirrapp.net.ApiManager; |
| | | 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.List; |
| | | |
| | | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; |
| | | import io.reactivex.rxjava3.schedulers.Schedulers; |
| | | |
| | | /** |
| | | * InspectDetailActivity - 巡检详情页 |
| | | * |
| | | * @author zuoxiao |
| | | * @version 1.0 |
| | | * @since 2025-02-20 |
| | | */ |
| | | public class InspectDetailActivity extends BaseActivity { |
| | | |
| | | WebView mWebView; |
| | | String inspectId; |
| | | List<InspectionLocationBean> aginShowlocationBeans; |
| | | boolean webViewIsFinished; |
| | | |
| | | @Override |
| | | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | inspectId = getIntent().getStringExtra("inspectId"); |
| | | setContentView(R.layout.activity_inspect_detail); |
| | | new TitleBar(this).setTitleText("巡检详情").setLeftIco().setLeftIcoListening(v -> InspectDetailActivity.this.finish()); |
| | | mWebView = findViewById(R.id.InspectWebView); |
| | | |
| | | Log.d("InspectDetail", "开始初始化WebView"); |
| | | |
| | | // 初始化WebView设置 |
| | | WebSettings webSettings = mWebView.getSettings(); |
| | | mWebView.clearCache(true); |
| | | webSettings.setJavaScriptEnabled(true); |
| | | webSettings.setAllowFileAccess(true); |
| | | webSettings.setAllowFileAccessFromFileURLs(true); |
| | | webSettings.setAllowUniversalAccessFromFileURLs(true); |
| | | webSettings.setDomStorageEnabled(true); |
| | | webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); |
| | | webSettings.setDefaultTextEncodingName("utf-8"); |
| | | webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); |
| | | webSettings.setBlockNetworkImage(false); |
| | | webSettings.setBlockNetworkLoads(false); |
| | | webSettings.setDatabaseEnabled(true); |
| | | webSettings.setGeolocationEnabled(true); |
| | | |
| | | // 设置独立的数据目录 |
| | | File cacheDir = new File(getDir("webview", MODE_PRIVATE), "cache"); |
| | | if (!cacheDir.exists()) { |
| | | cacheDir.mkdirs(); |
| | | } |
| | | webSettings.setDatabasePath(cacheDir.getAbsolutePath()); |
| | | webSettings.setGeolocationDatabasePath(cacheDir.getAbsolutePath()); |
| | | |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | WebView.setWebContentsDebuggingEnabled(true); |
| | | } |
| | | |
| | | initWeb(); |
| | | Log.d("InspectDetail", "开始加载HTML页面"); |
| | | mWebView.loadUrl("file:///android_asset/index.html"); |
| | | showLocation(); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | if (mWebView != null) { |
| | | mWebView.loadUrl("about:blank"); |
| | | mWebView.clearHistory(); |
| | | mWebView.clearCache(true); |
| | | mWebView.removeAllViews(); |
| | | mWebView.destroy(); |
| | | mWebView = null; |
| | | } |
| | | super.onDestroy(); |
| | | } |
| | | |
| | | @Override |
| | | protected void onPause() { |
| | | super.onPause(); |
| | | if (mWebView != null) { |
| | | mWebView.onPause(); |
| | | mWebView.pauseTimers(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onResume() { |
| | | super.onResume(); |
| | | if (mWebView != null) { |
| | | mWebView.onResume(); |
| | | mWebView.resumeTimers(); |
| | | } |
| | | } |
| | | |
| | | private void initWeb() { |
| | | mWebView.setWebViewClient(new WebViewClient() { |
| | | @Override |
| | | public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { |
| | | String url = request.getUrl().toString(); |
| | | //判断当前是否为加载瓦片 |
| | | if (MapJpgUtils.getInsatance().isTianDiTuTileRequest(url)) { |
| | | String androidUrl = url.replace(CommonData.webKey, CommonData.androidKey); |
| | | // 检查本地缓存 |
| | | File cachedTile = MapJpgUtils.getInsatance().getCachedTile(androidUrl); |
| | | if (cachedTile != null && cachedTile.exists()) { |
| | | // Log.d(TAG, "本地缓存>>>" + androidUrl); |
| | | // if (MapJpgUtils.getInsatance().validateImageFile(androidUrl,request.)) |
| | | // 判断缓存是否过期 |
| | | // if (!MapJpgUtils.getInsatance(MapFragment.this.getContext()).isCacheExpired(cachedTile)) { |
| | | try { |
| | | // 从缓存加载瓦片 |
| | | return new WebResourceResponse("image/jpg", "utf-8", new FileInputStream(cachedTile)); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // } |
| | | } else { |
| | | //下载瓦片 |
| | | ApiManager.getInstance().donwLoadTile(InspectDetailActivity.this, androidUrl); |
| | | } |
| | | } |
| | | return super.shouldInterceptRequest(view, request); |
| | | } |
| | | |
| | | @Override |
| | | public void onReceivedError(WebView view, WebResourceRequest |
| | | request, WebResourceError error) { |
| | | super.onReceivedError(view, request, error); |
| | | String url = request.getUrl().toString(); |
| | | int errorCode = error.getErrorCode(); |
| | | String description = error.getDescription().toString(); |
| | | |
| | | Log.e("InspectDetail", String.format("加载错误 - URL: %s\n错误码: %d\n描述: %s", |
| | | url, errorCode, description)); |
| | | } |
| | | |
| | | @Override |
| | | public void onReceivedHttpError(WebView view, WebResourceRequest |
| | | request, WebResourceResponse errorResponse) { |
| | | super.onReceivedHttpError(view, request, errorResponse); |
| | | String url = request.getUrl().toString(); |
| | | int statusCode = errorResponse.getStatusCode(); |
| | | String description = errorResponse.getReasonPhrase(); |
| | | |
| | | Log.e("InspectDetail", String.format("HTTP错误 - URL: %s\n状态码: %d\n描述: %s", |
| | | url, statusCode, description)); |
| | | } |
| | | |
| | | @Override |
| | | public void onPageFinished(WebView view, String url) { |
| | | super.onPageFinished(view, url); |
| | | Log.d("InspectDetail", "页面加载完成: " + url); |
| | | webViewIsFinished = true; |
| | | // 注入一个标识,避免与MapFragment冲突 |
| | | mWebView.evaluateJavascript( |
| | | "window.WEBVIEW_TYPE = 'INSPECT_DETAIL';", |
| | | null |
| | | ); |
| | | aginShowLocation(null); |
| | | } |
| | | }); |
| | | |
| | | mWebView.setWebChromeClient(new WebChromeClient() { |
| | | @Override |
| | | public boolean onConsoleMessage(ConsoleMessage consoleMessage) { |
| | | Log.d("InspectDetail", "Console: " + consoleMessage.message() + |
| | | " at " + consoleMessage.sourceId() + ":" + consoleMessage.lineNumber()); |
| | | return true; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 加载巡检记录 |
| | | */ |
| | | private void showLocation() { |
| | | // 查询当前未关闭的巡检记录下所有的坐标 |
| | | DaoSingleton.getAsynchInstance(this).inspectionLocationDao().findByInspectId(inspectId).subscribeOn(Schedulers.io()) |
| | | .observeOn(AndroidSchedulers.mainThread()).subscribe(inspectionLocationBeans -> { |
| | | aginShowLocation(inspectionLocationBeans); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 意外退出后继续显示之前的坐标 |
| | | */ |
| | | public void aginShowLocation(List<InspectionLocationBean> locationBeans) { |
| | | if (locationBeans != null) { |
| | | aginShowlocationBeans = locationBeans; |
| | | } |
| | | if (webViewIsFinished) { |
| | | if (aginShowlocationBeans != null) { |
| | | int index = 0; |
| | | int size = aginShowlocationBeans.size(); |
| | | boolean isStart, isEnd; |
| | | for (InspectionLocationBean inspectionLocationBean : aginShowlocationBeans) { |
| | | |
| | | if (index == 0) { |
| | | isStart = true; |
| | | } else { |
| | | isStart = false; |
| | | } |
| | | if (index == size - 1) { |
| | | isEnd = true; |
| | | } else { |
| | | isEnd = false; |
| | | } |
| | | Log.i("mWebView", "showHistoryLocation" + inspectionLocationBean.getLng() + "\",\"" + inspectionLocationBean.getLat()); |
| | | mWebView.evaluateJavascript("javascript:showHistoryLocation(\"" + inspectionLocationBean.getLng() + "\",\"" + inspectionLocationBean.getLat() + "\",\"" + isStart + "\",\"" + isEnd + "\")", value -> { |
| | | }); |
| | | index++; |
| | | } |
| | | // 向 WebView 注入数据 |
| | | aginShowlocationBeans.clear(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public void getHttpLocation() { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.dayu.pipirrapp.activity; |
| | | |
| | | import android.os.Bundle; |
| | | import android.view.LayoutInflater; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | |
| | | import com.dayu.pipirrapp.MyApplication; |
| | | import com.dayu.pipirrapp.adapter.InspectAdapter; |
| | | import com.dayu.pipirrapp.bean.net.InspectListResult; |
| | | import com.dayu.pipirrapp.bean.net.InspectResult; |
| | | import com.dayu.pipirrapp.databinding.ActivityInspectListBinding; |
| | | 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.ToastUtil; |
| | | import com.dayu.pipirrapp.view.TitleBar; |
| | | import com.scwang.smart.refresh.footer.ClassicsFooter; |
| | | import com.scwang.smart.refresh.header.ClassicsHeader; |
| | | import com.scwang.smart.refresh.layout.api.RefreshLayout; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import io.reactivex.rxjava3.disposables.CompositeDisposable; |
| | | |
| | | /** |
| | | * InspectActivity - 巡检记录列表 |
| | | * |
| | | * @author zuoxiao |
| | | * @version 1.0 |
| | | * @since 2025-02-17 |
| | | */ |
| | | public class InspectListActivity extends BaseActivity { |
| | | private ActivityInspectListBinding binding; |
| | | private RefreshLayout myRefreshLayout; |
| | | private List<InspectResult> recordsList = new ArrayList<>(); |
| | | private InspectAdapter mAdapter; |
| | | private CompositeDisposable compositeDisposable = new CompositeDisposable(); |
| | | |
| | | @Override |
| | | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | binding = ActivityInspectListBinding.inflate(LayoutInflater.from(this)); |
| | | setContentView(binding.getRoot()); |
| | | initView(); |
| | | getData(true); |
| | | } |
| | | |
| | | private void initView() { |
| | | new TitleBar(this).setTitleText("巡检记录").setLeftIco().setLeftIcoListening(v -> InspectListActivity.this.finish()); |
| | | myRefreshLayout = binding.refreshLayout; |
| | | myRefreshLayout.setRefreshHeader(new ClassicsHeader(this)); |
| | | myRefreshLayout.setRefreshFooter(new ClassicsFooter(this)); |
| | | |
| | | myRefreshLayout.setOnRefreshListener(refreshlayout -> { |
| | | recordsList.clear(); |
| | | getData(true); |
| | | }); |
| | | myRefreshLayout.setOnLoadMoreListener(refreshlayout -> { |
| | | getData(false); |
| | | }); |
| | | |
| | | mAdapter = new InspectAdapter(this, recordsList); |
| | | LinearLayoutManager layoutManager = new LinearLayoutManager(this); |
| | | binding.recyclerView.setLayoutManager(layoutManager); |
| | | binding.recyclerView.setAdapter(mAdapter); |
| | | } |
| | | |
| | | // private void getData(boolean isRefresh) { |
| | | // if (isRefresh) { |
| | | // recordsList.clear(); |
| | | // } |
| | | // |
| | | // compositeDisposable.add( |
| | | // DaoSingleton.getAsynchInstance(this).inspectionDao().findAll() |
| | | // .subscribeOn(Schedulers.io()) |
| | | // .observeOn(AndroidSchedulers.mainThread()) |
| | | // .subscribe(inspectionList -> { |
| | | // if (inspectionList != null && !inspectionList.isEmpty()) { |
| | | // recordsList.addAll(inspectionList); |
| | | // } |
| | | // mAdapter.notifyDataSetChanged(); |
| | | // layoutFinish(myRefreshLayout, isRefresh); |
| | | // }, throwable -> { |
| | | // // 处理错误 |
| | | // layoutFinish(myRefreshLayout, isRefresh); |
| | | // }) |
| | | // ); |
| | | // } |
| | | |
| | | private void getData(boolean isRefresh) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | if (isRefresh) { |
| | | page = 1; |
| | | recordsList.clear(); |
| | | } |
| | | params.put("pageSize", pageSize); |
| | | params.put("pageCurr", page); |
| | | params.put("inspectorId", MyApplication.myApplication.userId); |
| | | |
| | | ApiManager.getInstance().requestGetHideLoading(this, Constants.BASE_URL + "/app/inspect/getInspectRecords", InspectListResult.class, params, new SubscriberListener<BaseResponse<InspectListResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<InspectListResult> t) { |
| | | if (t.isSuccess()) { |
| | | if (t.isSuccess()) { |
| | | if (t.getContent().getObj() != null && t.getContent().getObj().size() > 0) { |
| | | recordsList.addAll(t.getContent().getObj()); |
| | | if (t.getContent().getPageTotal() == page) { |
| | | myRefreshLayout.finishLoadMoreWithNoMoreData(); |
| | | } |
| | | } else { |
| | | myRefreshLayout.finishLoadMoreWithNoMoreData(); |
| | | } |
| | | } |
| | | } else { |
| | | ToastUtil.showToast(InspectListActivity.this, t.getMsg()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCloose() { |
| | | super.onCloose(); |
| | | layoutFinish(myRefreshLayout, isRefresh); |
| | | mAdapter.notifyDataSetChanged(); |
| | | |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | compositeDisposable.clear(); |
| | | } |
| | | } |
| | |
| | | AddPictureAdapter mAdapter; |
| | | int maxSelectNum = 10;//最大照片 |
| | | int maxSelectVideoNum = 0;//最大视频 |
| | | int videoMaxSecond = 60; |
| | | private final List<LocalMedia> mData = new ArrayList<>(); |
| | | private ActivityResultLauncher<Intent> launcherResult; |
| | | private ImageEngine imageEngine; |
| | |
| | | private void mOpenPicture() { |
| | | // 进入相册 |
| | | PictureSelectionModel selectionModel = PictureSelector.create(this) |
| | | .openGallery(SelectMimeType.ofImage()) |
| | | .openGallery(SelectMimeType.ofAll()) |
| | | .setMaxSelectNum(maxSelectNum) |
| | | .setMaxVideoSelectNum(maxSelectVideoNum) |
| | | .setImageEngine(imageEngine) |
| | | //设置图片压缩 |
| | | .setCompressEngine(new ImageFileCompressEngine()) |
| | | //设置视频图片一起在相册选择 |
| | | .isWithSelectVideoImage(true) |
| | | //设置最大视频时长 |
| | | .setRecordVideoMaxSecond(videoMaxSecond) |
| | | // 过滤视频最大时长 |
| | | .setFilterVideoMaxSecond(videoMaxSecond) |
| | | // 拍照是否纠正旋转图片 |
| | | .isCameraRotateImage(true) |
| | | .setSelectedData(mAdapter.getData()); |
| | | |
| | | selectionModel.forResult(launcherResult); |
New file |
| | |
| | | package com.dayu.pipirrapp.adapter; |
| | | |
| | | import android.content.Context; |
| | | import android.view.LayoutInflater; |
| | | import android.view.ViewGroup; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.databinding.DataBindingUtil; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import com.dayu.pipirrapp.R; |
| | | import com.dayu.pipirrapp.activity.InspectDetailActivity; |
| | | import com.dayu.pipirrapp.activity.InspectListActivity; |
| | | import com.dayu.pipirrapp.bean.net.InspectResult; |
| | | import com.dayu.pipirrapp.databinding.ItemInspectBinding; |
| | | import com.dayu.pipirrapp.databinding.ItemNoMoreBinding; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class InspectAdapter extends BaseRecyclerAdapter<RecyclerView.ViewHolder> { |
| | | private InspectListActivity activity; |
| | | private List<InspectResult> list; |
| | | |
| | | public InspectAdapter(InspectListActivity activity, List<InspectResult> list) { |
| | | this.activity = activity; |
| | | this.list = list; |
| | | } |
| | | |
| | | @NonNull |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| | | if (viewType == VIEW_TYPE_EMPTY) { |
| | | ItemNoMoreBinding emptyView = DataBindingUtil.inflate((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE), |
| | | R.layout.item_no_more, parent, false); |
| | | return new BaseRecyclerAdapter.ViewHolderEmpty(emptyView); |
| | | } else { |
| | | ItemInspectBinding binding = DataBindingUtil.inflate((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE), |
| | | R.layout.item_inspect, parent, false); |
| | | return new ViewHolder(binding); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
| | | if (holder instanceof ViewHolder && list != null && list.size() > 0) { |
| | | InspectResult item = list.get(position); |
| | | ViewHolder viewHolder = (ViewHolder) holder; |
| | | viewHolder.binding.tvInspectId.setText("巡检ID: " + item.getInspectId()); |
| | | viewHolder.binding.tvStartTime.setText("开始时间: " + item.getStartTime()); |
| | | viewHolder.binding.tvStopTime.setText("结束时间: " + item.getStopTime()); |
| | | viewHolder.binding.tvInspectDistance.setText("巡检距离: " + item.getInspectDistance()+" KM"); |
| | | |
| | | // 添加点击事件 |
| | | viewHolder.itemView.setOnClickListener(v -> { |
| | | android.content.Intent intent = new android.content.Intent(activity, InspectDetailActivity.class); |
| | | intent.putExtra("inspectId", item.getInspectId()); |
| | | activity.startActivity(intent); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getItemCount() { |
| | | if (list != null) { |
| | | if (list.size() == 0) { |
| | | return 1; |
| | | } |
| | | return list.size(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public int getItemViewType(int position) { |
| | | if (list != null) { |
| | | if (list.size() == 0) { |
| | | return VIEW_TYPE_EMPTY; |
| | | } |
| | | return VIEW_TYPE_ITEM; |
| | | } |
| | | return VIEW_TYPE_EMPTY; |
| | | } |
| | | |
| | | static class ViewHolder extends RecyclerView.ViewHolder { |
| | | ItemInspectBinding binding; |
| | | |
| | | public ViewHolder(ItemInspectBinding binding) { |
| | | super(binding.getRoot()); |
| | | this.binding = binding; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dayu.pipirrapp.bean.db; |
| | | |
| | | /** |
| | | * 搜索结果Bean |
| | | */ |
| | | public class SearchResultBean { |
| | | private String name; // 名称 |
| | | private String type; // 类型:divide-分水房,marker-取水口 |
| | | private String lat; // 纬度 |
| | | private String lng; // 经度 |
| | | private String address; // 地址 |
| | | private String id; // ID |
| | | |
| | | public SearchResultBean(String name, String type, String lat, String lng, String address, String id) { |
| | | this.name = name; |
| | | this.type = type; |
| | | this.lat = lat; |
| | | this.lng = lng; |
| | | this.address = address; |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getLat() { |
| | | return lat; |
| | | } |
| | | |
| | | public void setLat(String lat) { |
| | | this.lat = lat; |
| | | } |
| | | |
| | | public String getLng() { |
| | | return lng; |
| | | } |
| | | |
| | | public void setLng(String lng) { |
| | | this.lng = lng; |
| | | } |
| | | |
| | | public String getAddress() { |
| | | return address; |
| | | } |
| | | |
| | | public void setAddress(String address) { |
| | | this.address = address; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dayu.pipirrapp.bean.net; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * InspectListResult - |
| | | * |
| | | * @author zuoxiao |
| | | * @version 1.0 |
| | | * @since 2025-02-18 |
| | | */ |
| | | public class InspectListResult { |
| | | |
| | | int itemTotal; |
| | | int pageCurr; |
| | | int pageSize; |
| | | int pageTotal; |
| | | List<InspectResult> obj; |
| | | |
| | | public int getItemTotal() { |
| | | return itemTotal; |
| | | } |
| | | |
| | | public void setItemTotal(int itemTotal) { |
| | | this.itemTotal = itemTotal; |
| | | } |
| | | |
| | | public int getPageCurr() { |
| | | return pageCurr; |
| | | } |
| | | |
| | | public void setPageCurr(int pageCurr) { |
| | | this.pageCurr = pageCurr; |
| | | } |
| | | |
| | | public int getPageSize() { |
| | | return pageSize; |
| | | } |
| | | |
| | | public void setPageSize(int pageSize) { |
| | | this.pageSize = pageSize; |
| | | } |
| | | |
| | | public int getPageTotal() { |
| | | return pageTotal; |
| | | } |
| | | |
| | | public void setPageTotal(int pageTotal) { |
| | | this.pageTotal = pageTotal; |
| | | } |
| | | |
| | | public List<InspectResult> getObj() { |
| | | return obj; |
| | | } |
| | | |
| | | public void setObj(List<InspectResult> obj) { |
| | | this.obj = obj; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dayu.pipirrapp.bean.net; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * InspectResult - |
| | | * |
| | | * @author zuoxiao |
| | | * @version 1.0 |
| | | * @since 2025-02-19 |
| | | */ |
| | | public class InspectResult { |
| | | |
| | | private String inspectorId; // 巡检员ID |
| | | private String inspectorName; // 巡检员姓名 |
| | | private String inspectId; // 巡检ID |
| | | private String startTime; // 开始时间 |
| | | private String stopTime; // 结束时间 |
| | | private Double inspectDistance; // 巡检距离 |
| | | private List<String> tracks; // 巡检节点列表 |
| | | |
| | | // 构造函数 |
| | | public InspectResult(String inspectorId, String inspectorName, String inspectId, String startTime, String stopTime, Double inspectDistance, List<String> tracks) { |
| | | this.inspectorId = inspectorId; |
| | | this.inspectorName = inspectorName; |
| | | this.inspectId = inspectId; |
| | | this.startTime = startTime; |
| | | this.stopTime = stopTime; |
| | | this.inspectDistance = inspectDistance; |
| | | this.tracks = tracks; |
| | | } |
| | | |
| | | // Getter 和 Setter 方法 |
| | | public String getInspectorId() { |
| | | return inspectorId; |
| | | } |
| | | |
| | | public void setInspectorId(String inspectorId) { |
| | | this.inspectorId = inspectorId; |
| | | } |
| | | |
| | | public String getInspectorName() { |
| | | return inspectorName; |
| | | } |
| | | |
| | | public void setInspectorName(String inspectorName) { |
| | | this.inspectorName = inspectorName; |
| | | } |
| | | |
| | | public String getInspectId() { |
| | | return inspectId; |
| | | } |
| | | |
| | | public void setInspectId(String inspectId) { |
| | | this.inspectId = inspectId; |
| | | } |
| | | |
| | | public String getStartTime() { |
| | | return startTime; |
| | | } |
| | | |
| | | public void setStartTime(String startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public String getStopTime() { |
| | | return stopTime; |
| | | } |
| | | |
| | | public void setStopTime(String stopTime) { |
| | | this.stopTime = stopTime; |
| | | } |
| | | |
| | | public Double getInspectDistance() { |
| | | return inspectDistance; |
| | | } |
| | | |
| | | public void setInspectDistance(Double inspectDistance) { |
| | | this.inspectDistance = inspectDistance; |
| | | } |
| | | |
| | | public List<String> getTracks() { |
| | | return tracks; |
| | | } |
| | | |
| | | public void setTracks(List<String> tracks) { |
| | | this.tracks = tracks; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.dayu.pipirrapp.bean.db.InspectionBean; |
| | | |
| | | import java.util.List; |
| | | |
| | | import io.reactivex.rxjava3.core.Completable; |
| | | import io.reactivex.rxjava3.core.Maybe; |
| | | import io.reactivex.rxjava3.core.Single; |
| | | |
| | | |
| | |
| | | @Query("SELECT * FROM InspectionBean WHERE mInspectId =:mInspectId ORDER BY startTime DESC LIMIT 1") |
| | | Single<InspectionBean> findBymInspectId(String mInspectId); |
| | | |
| | | |
| | | /** |
| | | * 获取所有巡检记录 |
| | | * @return |
| | | */ |
| | | @Query("SELECT * FROM InspectionBean ORDER BY startTime DESC LIMIT 1") |
| | | Maybe<List<InspectionBean>> findAll(); |
| | | } |
| | |
| | | |
| | | //查询所有该巡检id的坐标 |
| | | @Query("select * from InspectionLocationBean where mInspectId=:mInspectId ORDER BY locateTime ASC") |
| | | Single<List<InspectionLocationBean>> findByInspectId(String mInspectId); |
| | | Single<List<InspectionLocationBean>> findBymInspectId(String mInspectId); |
| | | |
| | | |
| | | //查询所有该巡检id的坐标 |
| | | @Query("select * from InspectionLocationBean where InspectId=:inspectId ORDER BY locateTime ASC") |
| | | Single<List<InspectionLocationBean>> findByInspectId(String inspectId); |
| | | |
| | | |
| | | |
| | | //查询所有未上传的mInspectId |
| | | @Query("SELECT DISTINCT mInspectId FROM InspectionLocationBean WHERE isPost = false") |
| | |
| | | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; |
| | | import io.reactivex.rxjava3.disposables.CompositeDisposable; |
| | | import io.reactivex.rxjava3.schedulers.Schedulers; |
| | | import kotlin.Triple; |
| | | import kotlin.Unit; |
| | | import kotlin.jvm.functions.Function1; |
| | | |
| | | /** |
| | | * author: zuo |
| | |
| | | import androidx.annotation.Nullable; |
| | | |
| | | import com.dayu.pipirrapp.activity.ChangePSActivity; |
| | | import com.dayu.pipirrapp.activity.InspectListActivity; |
| | | import com.dayu.pipirrapp.activity.IssueListActivity; |
| | | import com.dayu.pipirrapp.activity.LoginActivity; |
| | | import com.dayu.pipirrapp.bean.db.LoginBean; |
| | |
| | | Intent intent = new Intent(MyFragment.this.getContext(), IssueListActivity.class); |
| | | MyFragment.this.getActivity().startActivity(intent); |
| | | }); |
| | | binding.refreshDataTV.setOnClickListener(v->{ |
| | | binding.refreshDataTV.setOnClickListener(v -> { |
| | | // 发送刷新事件通知MapFragment刷新数据 |
| | | LiveEventBus.get(CommonKeyName.refreshData).post(true); |
| | | }); |
| | | binding.inspectListRL.setOnClickListener(v -> { |
| | | Intent intent = new Intent(MyFragment.this.getContext(), InspectListActivity.class); |
| | | MyFragment.this.getActivity().startActivity(intent); |
| | | }); |
| | | } |
| | | |
| | | private void initData() { |
| | |
| | | .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); |
| | | }); |
| | |
| | | * 备注:公共参数 |
| | | */ |
| | | public class CommonData { |
| | | //天地图 |
| | | public static String webKey = "d8beed89b43160a9a185e5aff431f85d"; |
| | | public static String androidKey = "4dace6fd6dad43a9bc08d1ed94ec28d8"; |
| | | |
| | | //天地图API密钥 |
| | | public static String webKey = "d8beed89b43160a9a185e5aff431f85d"; // Web端使用的密钥 |
| | | public static String androidKey = "4dace6fd6dad43a9bc08d1ed94ec28d8"; // Android端使用的密钥 |
| | | |
| | | // 获取当前使用的密钥 |
| | | public static String getCurrentMapKey() { |
| | | return androidKey; // 在Android应用中优先使用androidKey |
| | | } |
| | | |
| | | public final static String NoTag = "-1"; |
| | | public final static int TestTag = 0; |
| | | public final static int YuanMouTag = 1; |
| | | |
| | | |
| | | } |
| | |
| | | <vector xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:width="24dp" |
| | | android:height="2dp" |
| | | android:height="1dp" |
| | | android:viewportWidth="24" |
| | | android:viewportHeight="2"> |
| | | android:viewportHeight="1"> |
| | | |
| | | <path |
| | | android:pathData="M0,1L24,1" |
| | | android:strokeWidth="2" |
| | | android:pathData="M0,0.5L24,0.5" |
| | | android:strokeWidth="1" |
| | | android:strokeColor="#1890FF" |
| | | android:strokeLineCap="round"/> |
| | | </vector> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <include |
| | | android:id="@+id/title" |
| | | layout="@layout/top_title" /> |
| | | |
| | | <WebView |
| | | android:id="@+id/InspectWebView" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_below="@+id/title" /> |
| | | </RelativeLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical"> |
| | | |
| | | <include |
| | | android:id="@+id/title" |
| | | layout="@layout/top_title" /> |
| | | |
| | | <com.scwang.smart.refresh.layout.SmartRefreshLayout |
| | | android:id="@+id/refresh_layout" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <androidx.recyclerview.widget.RecyclerView |
| | | android:id="@+id/recycler_view" |
| | | android:layout_width="match_parent" |
| | | |
| | | android:layout_height="match_parent" |
| | | android:padding="10dp" /> |
| | | |
| | | </com.scwang.smart.refresh.layout.SmartRefreshLayout> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:id="@+id/listView" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | |
| | | android:divider="@android:color/darker_gray" |
| | | android:dividerHeight="0.5dp" |
| | | android:maxHeight="300dp" /> |
| | |
| | | android:layout_marginRight="15dp" |
| | | android:src="@drawable/ic_right" /> |
| | | </RelativeLayout> |
| | | <RelativeLayout |
| | | android:id="@+id/inspectListRL" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/item_height" |
| | | android:layout_below="@+id/issueListRL"> |
| | | |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/item_height" |
| | | android:background="@color/white" |
| | | android:gravity="center_vertical" |
| | | android:paddingLeft="30dp" |
| | | android:text="巡检记录" |
| | | android:layout_marginTop="1dp" |
| | | android:textColor="@color/black" |
| | | android:textSize="@dimen/my_item_text_size" /> |
| | | |
| | | <ImageView |
| | | android:layout_width="25dp" |
| | | android:layout_height="25dp" |
| | | android:layout_alignParentRight="true" |
| | | android:layout_centerVertical="true" |
| | | android:layout_marginRight="15dp" |
| | | android:src="@drawable/ic_right" /> |
| | | </RelativeLayout> |
| | | |
| | | <RelativeLayout |
| | | android:id="@+id/passwordRL" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/item_height" |
| | | android:layout_below="@+id/issueListRL" |
| | | android:layout_below="@+id/inspectListRL" |
| | | android:layout_marginTop="1dp"> |
| | | |
| | | <TextView |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <layout xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="5dp" |
| | | android:background="@drawable/ic_choose_gray_edge" |
| | | android:orientation="vertical" |
| | | android:padding="16dp"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_inspect_id" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:textColor="#333333" |
| | | android:textSize="16sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_start_time" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="8dp" |
| | | android:textColor="#666666" |
| | | android:textSize="14sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_stop_time" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="8dp" |
| | | android:textColor="#666666" |
| | | android:textSize="14sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_inspectDistance" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="8dp" |
| | | android:textColor="#666666" |
| | | android:textSize="14sp" /> |
| | | |
| | | </LinearLayout> |
| | | </layout> |