管灌系统巡查员智能手机App
zuoxiao
2025-01-18 b3e7f379e72111f55a28c302804702ee7c66bfa2
1.管网的js相关代码
7个文件已修改
11个文件已添加
950 ■■■■■ 已修改文件
app/src/main/assets/js/map.js 258 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/bean/db/DivideBean.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/bean/db/PipeNetworkBean.java 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/bean/net/DivideResult.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkListResult.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkResult.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java 195 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/tool/MyWebViewInterface.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/fragment_map.xml 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/.gitignore 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/build.gradle 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/consumer-rules.pro 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/proguard-rules.pro 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/src/androidTest/java/com/example/expand_button/ExampleInstrumentedTest.kt 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/src/main/AndroidManifest.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/src/main/java/com/example/expand_button/ExpandButton.kt 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
expand_button/src/test/java/com/example/expand_button/ExampleUnitTest.kt 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
settings.gradle 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/js/map.js
@@ -4,9 +4,11 @@
        IMAGES: {
            LOCATION: 'img/location.png',
            MARKER_BLACK: 'img/marker_black.svg',
            MARKER_RED: 'img/marker_red.svg',
            MARKER_RED: 'img/marker_red.svg',
            MARKER_BLUE: 'img/marker_blue.svg',
            CENTER_PIN: 'img/push_pin.svg'
            CENTER_PIN: 'img/push_pin.svg',
            DIVIDE_BLUE: 'img/divide_home_blue.svg',
            DIVIDE_RED: 'img/divide_home_red.svg'
        },
        MAP: {
            DEFAULT_ZOOM: 12,
@@ -16,8 +18,14 @@
    let map;
    let lastMarker = null;
    let lastClickedMarker = null;
    let lastClickedDivide = null;
    let isShowWaterIntakeDetail = false;
    let isShowDivideDetail = false;
    let zoom = 12;
    // 存储所有管网线路的数组
    let pipeLineList = [];
    let currentPipePath = [];
    // 将方法挂载到 window 上
    function mountMethodToWindow() {
@@ -33,7 +41,11 @@
        window.showPin = showPin;
        window.cancelPin = cancelPin;
        window.refreshMarker = refreshMarker;
        window.addDivide = addDivide;
        window.showAllPipeLines = showAllPipeLines;
        window.hideAllPipeLines = hideAllPipeLines;
        window.clearAllPipeLines = clearAllPipeLines;
        window.addPipeNetwork = addPipeNetwork;
    }
@@ -129,7 +141,7 @@
            iconAnchor: new T.Point(10, 10)
        });
        let marker = new T.Marker(
            new T.LngLat(lng, lag),
            new T.LngLat(lng, lag),
            { icon: icon }
        );
        map.addOverLay(marker);
@@ -158,7 +170,7 @@
            if (lastClickedMarker !== null) {
                lastClickedMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
            }
            if (isShowWaterIntakeDetail) {
            if (isShowWaterIntakeDetail || isShowDivideDetail) {
                // 假如显示了取水口详情则隐藏取水口详情
                isShowWaterIntakeDetail = false;
                window.Android.closeWaterIntakeView();
@@ -167,7 +179,6 @@
                getLngLat(data.lnglat);
            }
        }
    }
    // 点击标注的事件
@@ -175,7 +186,7 @@
        if (!isShowCenterPin) {
            chageMarkerIcon(data);
            showWaterIntakeDetail(id);
        }else {
        } else {
            showToast("当前正在修改选中取水口的经纬度,完成或退出后才可选择其他!");
        }
@@ -186,11 +197,14 @@
        // 点击的标注改为红色
        var currentMarker = data.target;
        currentMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_RED));
        if (lastClickedMarker !== null) {
            if (!isEqualsLngLat(data.target.getLngLat(), lastClickedMarker.getLngLat())) {
                lastClickedMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
            }
        }
        if (lastClickedDivide !== null) {
            lastClickedDivide.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
        }
        lastClickedMarker = data.target;
        map.panTo(currentMarker.getLngLat());
@@ -232,8 +246,8 @@
        label.setFontColor("#FFFFFF");
        label.setFontSize(10);
        marker.label = label;
        if (isRed){
            lastClickedMarker=marker;
        if (isRed) {
            lastClickedMarker = marker;
        }
        map.addOverLay(label);
        map.addOverLay(marker); // 将标注添加到地图中
@@ -250,9 +264,9 @@
            iconSize: new T.Point(20, 20),
            iconAnchor: new T.Point(10, 10)
        });
        locationMarker = new T.Marker(
            newPoint,
            newPoint,
            { icon: icon }
        );
        map.addOverLay(locationMarker);
@@ -264,15 +278,144 @@
    let locationMarker;
    function updateInspectionLocation(log, lat) {
        var lastLat = lat;
        // const intervalId = setInterval(() => {
        // lastLat=lastLat+0.0001;
        var newPoint = new T.LngLat(log, lastLat);
        path.push(newPoint);
        lineLayer.setLngLats(path);
        map.addOverLay(lineLayer);
        // 移动地图视角到最后一个位置
    }
        // }, 500);
    var pipePath = [];
    var pipeLineLayer = new T.Polyline([], { color: '#E9900A', weight: 3, opacity: 0.8 });
    // 管网线路管理
    const PipelineManager = {
        lines: [],  // 存储所有完成的线路
        currentLine: {
            points: [],  // 当前线路的点
            overlay: null  // 当前线路的图层对象
        },
        // 线路样式配置
        style: {
            color: '#1890FF',
            weight: 3,
            opacity: 0.8
        },
        /**
         * 添加点到管网线路
         * @param {number} lng 经度
         * @param {number} lat 纬度
         * @param {boolean} isNewLine 是否开始新的线路
         */
        addPoint(lng, lat, isNewLine) {
            if (isNewLine) {
                this.finishCurrentLine();
            }
            const point = new T.LngLat(lng, lat);
            this.currentLine.points.push(point);
            if (this.currentLine.points.length > 1) {
                this.updateCurrentLineDisplay();
            }
        },
        /**
         * 更新当前线路的显示
         */
        updateCurrentLineDisplay() {
            if (!this.currentLine.overlay) {
                // 创建新的线路图层
                this.currentLine.overlay = new T.Polyline(this.currentLine.points, this.style);
                map.addOverLay(this.currentLine.overlay);
            } else {
                // 更新现有线路的点
                this.currentLine.overlay.setLngLats(this.currentLine.points);
            }
        },
        /**
         * 完成当前线路
         */
        finishCurrentLine() {
            if (this.currentLine.points.length > 1) {
                if (this.currentLine.overlay) {
                    // 将当前线路添加到完成列表
                    this.lines.push(this.currentLine.overlay);
                }
            } else if (this.currentLine.overlay) {
                // 如果点数不足,清除图层
                map.removeOverLay(this.currentLine.overlay);
            }
            // 重置当前线路
            this.currentLine = {
                points: [],
                overlay: null
            };
        },
        /**
         * 显示所有线路
         */
        showAll() {
            this.lines.forEach(line => map.addOverLay(line));
            if (this.currentLine.overlay) {
                map.addOverLay(this.currentLine.overlay);
            }
        },
        /**
         * 隐藏所有线路
         */
        hideAll() {
            this.lines.forEach(line => map.removeOverLay(line));
            if (this.currentLine.overlay) {
                map.removeOverLay(this.currentLine.overlay);
            }
        },
        /**
         * 清除所有线路
         */
        clearAll() {
            this.hideAll();
            this.lines = [];
            this.currentLine = {
                points: [],
                overlay: null
            };
        }
    };
    /**
     * 添加管网线路点
     */
    function addPipeNetwork(lng, lat, isNewLine) {
        PipelineManager.addPoint(lng, lat, isNewLine);
    }
    /**
     * 显示所有管网线路
     */
    function showAllPipeLines() {
        PipelineManager.showAll();
    }
    /**
     * 隐藏所有管网线路
     */
    function hideAllPipeLines() {
        PipelineManager.hideAll();
    }
    /**
     * 清除所有管网线路
     */
    function clearAllPipeLines() {
        PipelineManager.clearAll();
    }
    var aginPath = [];
@@ -316,7 +459,7 @@
        isShowCenterPin = true;
        map.addEventListener("moveend", mapMoveEnd);
        window.Android.refreshCenter(map.getCenter().getLng(), map.getCenter().getLat());
       return true;
        return true;
    }
    //取消修改定位
    function cancelPin() {
@@ -341,8 +484,8 @@
    // 添加防抖函数
    function debounce(fn, delay) {
        let timer = null;
        return function() {
            if(timer) clearTimeout(timer);
        return function () {
            if (timer) clearTimeout(timer);
            timer = setTimeout(() => {
                fn.apply(this, arguments);
            }, delay);
@@ -356,8 +499,83 @@
        return new T.Icon({
            iconUrl: iconUrl,
            iconSize: new T.Point(size, size),
            iconAnchor: new T.Point(size/2, size)
            iconAnchor: new T.Point(size / 2, size)
        });
    }
    //添加分水房
    function addDivide(id, lng, lat, name) {
        addDivide(id, lng, lat, name, false)
    }
    //添加分水房
    function addDivide(id, lng, lat, name, isRed) {
        console.log("function》》》》》addMarker>>>id:" + id);
        const iconUrl = isRed ? CONFIG.IMAGES.DIVIDE_RED : CONFIG.IMAGES.DIVIDE_BLUE;
        let marker = new T.Marker(
            new T.LngLat(lng, lat),
            { icon: createIcon(iconUrl) }
        );
        //添加点击事件
        marker.addEventListener("click", (data) => {
            addDivideListener(id, data)
        });
        let label = new T.Label({
            text: `<div style='position:absolute;left:-50%;transform: translateX(-50%);'>${name}<div>`,
            position: marker.getLngLat(),
            offset: new T.Point(0, 8), // 设置标注文字的位置
            opacity: 1, // 设置文本的显示不透明度(范围0-1)
        });
        label.setBorderLine(0); // 设置文本的边框线宽
        label.setBackgroundColor("transparent"); // 设置文本的背景色(透明色)
        label.setFontColor("#FFFFFF");
        label.setFontSize(10);
        marker.label = label;
        if (isRed) {
            lastClickedMarker = marker;
        }
        map.addOverLay(label);
        map.addOverLay(marker); // 将标注添加到地图中
        return "addMarker加载成功 id:" + id
    }
    // 修改点击标注的图标
    function chageDivideIcon(data) {
        // 点击的标注改为红色
        var currentMarker = data.target;
        currentMarker.setIcon(createIcon(CONFIG.IMAGES.DIVIDE_RED));
        if (lastClickedDivide !== null) {
            if (!isEqualsLngLat(data.target.getLngLat(), lastClickedDivide.getLngLat())) {
                lastClickedDivide.setIcon(createIcon(CONFIG.IMAGES.DIVIDE_BLUE));
            }
        }
        if (lastClickedMarker !== null) {
            lastClickedMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
        }
        lastClickedDivide = data.target;
        map.panTo(currentMarker.getLngLat());
    }
    // 点击标注的事件
    function addDivideListener(id, data) {
        // if (!isShowCenterPin) {
        chageDivideIcon(data);
        showDivideDetail(id);
        // } else {
        //     showToast("当前正在修改选中取水口的经纬度,完成或退出后才可选择其他!");
        // }
    }
    // 调用原生安卓方法显示取水口详情
    function showDivideDetail(data) {
        isShowDivideDetail = true;
        window.Android.showDivideDetail(data);
    }
})();
app/src/main/java/com/dayu/pipirrapp/bean/db/DivideBean.java
@@ -87,7 +87,7 @@
    /**
     * 覆盖面积
     */
    private double area;
    private String area;
    // Getters and Setters
@@ -99,11 +99,11 @@
        this.address = address;
    }
    public double getArea() {
    public String getArea() {
        return area;
    }
    public void setArea(double area) {
    public void setArea(String area) {
        this.area = area;
    }
app/src/main/java/com/dayu/pipirrapp/bean/db/PipeNetworkBean.java
New file
@@ -0,0 +1,103 @@
package com.dayu.pipirrapp.bean.db;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import com.dayu.pipirrapp.bean.net.PipeNetworkResult;
import java.util.List;
/**
 * PipeNetworkBean -
 *
 * @author zuoxiao
 * @version 1.0
 * @since 2025-01-17
 */
@Entity
public class PipeNetworkBean {
    @PrimaryKey(autoGenerate = true)
    public long id;
    String type;
    String networkId;
    List<PipeNetworkResult.Data> data;
    public class Data {
        public class Coordinate {
            String lat;
            String lng;
            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;
            }
        }
        List<PipeNetworkResult.Data.Coordinate> coordinates;
        String type;
        String networkId;
        public List<PipeNetworkResult.Data.Coordinate> getCoordinates() {
            return coordinates;
        }
        public void setCoordinates(List<PipeNetworkResult.Data.Coordinate> coordinates) {
            this.coordinates = coordinates;
        }
        public String getType() {
            return type;
        }
        public void setType(String type) {
            this.type = type;
        }
        public String getNetworkId() {
            return networkId;
        }
        public void setNetworkId(String networkId) {
            this.networkId = networkId;
        }
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getNetworkId() {
        return networkId;
    }
    public void setNetworkId(String networkId) {
        this.networkId = networkId;
    }
    public List<PipeNetworkResult.Data> getData() {
        return data;
    }
    public void setData(List<PipeNetworkResult.Data> data) {
        this.data = data;
    }
}
app/src/main/java/com/dayu/pipirrapp/bean/net/DivideResult.java
@@ -29,9 +29,14 @@
    private String divideId;
    /**
     * 分水房名称
     * 分水房名称(列表接口返回)
     */
    private String divideName;
    /**
     * 分水房名称(详情接口返回)
     */
    private String name;
    /**
     * 负责人
@@ -41,17 +46,17 @@
    /**
     * 编号
     */
    private int id;
    private String id;
    /**
     * 纬度
     */
    private double lat;
    private String lat;
    /**
     * 经度
     */
    private double lng;
    private String lng;
    /**
     * 操作时间
@@ -81,8 +86,15 @@
    /**
     * 覆盖面积
     */
    private double area;
    private String area;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    // Getters and Setters
    public String getAddress() {
@@ -93,11 +105,11 @@
        this.address = address;
    }
    public double getArea() {
    public String getArea() {
        return area;
    }
    public void setArea(double area) {
    public void setArea(String area) {
        this.area = area;
    }
@@ -141,27 +153,28 @@
        this.header = header;
    }
    public int getId() {
    public String getId() {
        return id;
    }
    public void setId(int id) {
    public void setId(String id) {
        this.id = id;
    }
    public double getLat() {
    public String getLat() {
        return lat;
    }
    public void setLat(double lat) {
    public void setLat(String lat) {
        this.lat = lat;
    }
    public double getLng() {
    public String getLng() {
        return lng;
    }
    public void setLng(double lng) {
    public void setLng(String lng) {
        this.lng = lng;
    }
app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkListResult.java
New file
@@ -0,0 +1,58 @@
package com.dayu.pipirrapp.bean.net;
import java.util.List;
/**
 * PipeNetworkListResult -
 *
 * @author zuoxiao
 * @version 1.0
 * @since 2025-01-17
 */
public class PipeNetworkListResult {
    int itemTotal;
    int pageCurr;
    int pageSize;
    int pageTotal;
    List<PipeNetworkResult> 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<PipeNetworkResult> getObj() {
        return obj;
    }
    public void setObj(List<PipeNetworkResult> obj) {
        this.obj = obj;
    }
}
app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkResult.java
New file
@@ -0,0 +1,92 @@
package com.dayu.pipirrapp.bean.net;
import java.util.List;
/**
 * PipeNetworkResult - 管网实例
 *
 * @author zuoxiao
 * @version 1.0
 * @since 2025-01-17
 */
public class PipeNetworkResult {
    String type;
    String networkId;
    List<Data> data;
    public class Data {
        public class Coordinate {
            String lat;
            String lng;
            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;
            }
        }
        List<Coordinate> coordinates;
        String type;
        String networkId;
        public List<Coordinate> getCoordinates() {
            return coordinates;
        }
        public void setCoordinates(List<Coordinate> coordinates) {
            this.coordinates = coordinates;
        }
        public String getType() {
            return type;
        }
        public void setType(String type) {
            this.type = type;
        }
        public String getNetworkId() {
            return networkId;
        }
        public void setNetworkId(String networkId) {
            this.networkId = networkId;
        }
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getNetworkId() {
        return networkId;
    }
    public void setNetworkId(String networkId) {
        this.networkId = networkId;
    }
    public List<Data> getData() {
        return data;
    }
    public void setData(List<Data> data) {
        this.data = data;
    }
}
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
@@ -31,6 +31,7 @@
import com.dayu.pipirrapp.bean.db.InspectionLocationBean;
import com.dayu.pipirrapp.bean.db.LatLonBean;
import com.dayu.pipirrapp.bean.db.MarkerBean;
import com.dayu.pipirrapp.bean.db.PipeNetworkBean;
import com.dayu.pipirrapp.bean.net.CenterPointResult;
import com.dayu.pipirrapp.bean.net.DivideListResult;
import com.dayu.pipirrapp.bean.net.DivideResult;
@@ -38,6 +39,8 @@
import com.dayu.pipirrapp.bean.net.InspectionRequest;
import com.dayu.pipirrapp.bean.net.MarkerListResult;
import com.dayu.pipirrapp.bean.net.MarkerResult;
import com.dayu.pipirrapp.bean.net.PipeNetworkListResult;
import com.dayu.pipirrapp.bean.net.PipeNetworkResult;
import com.dayu.pipirrapp.dao.DaoSingleton;
import com.dayu.pipirrapp.databinding.FragmentMapBinding;
import com.dayu.pipirrapp.net.ApiManager;
@@ -148,7 +151,9 @@
        getCenterPoint();
        initView();
        initWeb();
        getMarkerData();
        getDivideList();
        chageInspecState(mInspectionState);
        return binding.getRoot();
@@ -213,7 +218,7 @@
                super.onPageFinished(view, url);
                //页面加载完成
                webViewIsFinished = true;
                initLocalData();
                webFinishInitLocalData();
                aginShowLocation(null);
            }
@@ -221,9 +226,9 @@
    }
    /**
     * 初始化本地数据
     * web加载完初始化本地数据
     */
    public void initLocalData() {
    public void webFinishInitLocalData() {
        //跳转中心点
        centerPointBean = DaoSingleton.getInstance(MapFragment.this.getContext()).centerPointDao().findFirst();
        jumpCenterPoint();
@@ -231,6 +236,11 @@
        if (!webNoFinishMarkerData.isEmpty()) {
            for (MarkerBean bean : webNoFinishMarkerData) {
                setMapMarker(bean);
            }
        }
        if (!webNoFinishDivideData.isEmpty()) {
            for (DivideBean bean : webNoFinishDivideData) {
                setMapDivide(bean);
            }
        }
        //显示所有取水口
@@ -252,9 +262,7 @@
            @Override
            public void onNext(BaseResponse<MarkerListResult> t) {
                if (t.isSuccess()) {
                    if (t.getContent().getObj() != null && !t.getContent().getObj().isEmpty()) {
                        List<MarkerBean> markerBeans = t.getContent().getObj().stream()
                                .map(result -> {
                                    MarkerBean markerBean = new MarkerBean();
@@ -349,6 +357,20 @@
    }
    /**
     * 显示分水房详情
     *
     * @param data
     */
    public void showDivideDetail(String data) {
        MyLog.i(data);
        DivideBean markerBean = divideBeanMap.get(data);
        if (markerBean != null) {
            binding.bottomLL.setVisibility(View.GONE);
            getDivideDetail(markerBean);
        }
    }
    /**
     * 获取地图中心点
@@ -581,18 +603,18 @@
    /**
     * 添加取水口标注
     */
    public void setDivide(DivideBean divide) {
    public void setMapDivide(DivideBean divide) {
        if (divide != null) {
            if (webViewIsFinished) {
                if (!TextUtils.isEmpty(divide.getLng()) && !TextUtils.isEmpty(divide.getLat())) {
                    mWebView.evaluateJavascript("javascript:addMarker(\"" + divide.getId() + "\",\"" + divide.getLng() + "\",\"" + divide.getLat() + "\",\"" + divide.getDivideName() + "\")", new ValueCallback<String>() {
                    mWebView.evaluateJavascript("javascript:addDivide(\"" + divide.getId() + "\",\"" + divide.getLng() + "\",\"" + divide.getLat() + "\",\"" + divide.getDivideName() + "\")", new ValueCallback<String>() {
                        @Override
                        public void onReceiveValue(String value) {
                        }
                    });
                    divideBeanMap.put(divide.getId(), divide);
                } else {
                    MyLog.d("setMapMarker>" + divide.getDivideName() + "经纬度为空");
                    MyLog.d("setMapDivide>" + divide.getDivideName() + "经纬度为空");
                }
            } else {
                webNoFinishDivideData.add(divide);
@@ -600,6 +622,28 @@
        }
    }
    /**
     * 添加取水口标注
     */
    public void setMapDivide(PipeNetworkBean pipeNetworkBean) {
//        if (divide != null) {
//            if (webViewIsFinished) {
//                for ()
//                if (!TextUtils.isEmpty(divide.getLng()) && !TextUtils.isEmpty(divide.getLat())) {
//                    mWebView.evaluateJavascript("javascript:addDivide(\"" + divide.getId() + "\",\"" + divide.getLng() + "\",\"" + divide.getLat() + "\",\"" + divide.getDivideName() + "\")", new ValueCallback<String>() {
//                        @Override
//                        public void onReceiveValue(String value) {
//                        }
//                    });
//                    divideBeanMap.put(divide.getId(), divide);
//                } else {
//                    MyLog.d("setMapDivide>" + divide.getDivideName() + "经纬度为空");
//                }
//            } else {
//                webNoFinishDivideData.add(divide);
//            }
//        }
    }
    /**
     * 开始巡检的相关逻辑
@@ -748,8 +792,32 @@
        });
    }
    /**
     * 显示取水口详情
     */
    private void getDivideDetail(DivideBean divideBean) {
        ApiManager.getInstance().requestGet(this.getContext(), Constants.BASE_URL + "/project/divide/getone/" + divideBean.getDivideId(), DivideResult.class, null, new SubscriberListener<BaseResponse<DivideResult>>() {
            @Override
            public void onNext(BaseResponse<DivideResult> t) {
                if (t.isSuccess()) {
                    DivideBean divideBean = getDivideBean(t.getContent());
                    showDivideMarker(divideBean);
                } else {
                    ToastUtil.showToast(MapFragment.this.getContext(), t.getMsg());
                }
            }
        });
    }
    /**
     * 显示取水口详情
     */
    private void showMarker(MarkerBean markerBean) {
        binding.bottomLL.setVisibility(View.VISIBLE);
        binding.phoneLL.setVisibility(View.GONE);
        binding.headerLL.setVisibility(View.GONE);
        binding.editePoint.setVisibility(View.VISIBLE);
        binding.markerAddress.setText(markerBean.getAddress());
        binding.markerName.setText(markerBean.getName());
        binding.markerBlockName.setText(markerBean.getBlockName());
@@ -785,23 +853,112 @@
    }
    /**
     * 显示分水房详情
     *
     * @param divideBean
     */
    private void showDivideMarker(DivideBean divideBean) {
        binding.bottomLL.setVisibility(View.VISIBLE);
        binding.phoneLL.setVisibility(View.VISIBLE);
        binding.headerLL.setVisibility(View.VISIBLE);
        binding.editePoint.setVisibility(View.GONE);
        binding.markerAddress.setText(divideBean.getAddress());
        binding.markerName.setText(divideBean.getDivideName());
        binding.markerBlockName.setText(divideBean.getBlockName());
        binding.phone.setText(divideBean.getPhone());
        binding.header.setText(divideBean.getHeader());
        binding.lat.setText(divideBean.getLat());
        binding.lng.setText(divideBean.getLng());
        //修改经纬度
        binding.editePoint.setOnClickListener(v -> {
            mWebView.evaluateJavascript("javascript:showPin(\"" + divideBean.getLng() + "\",\"" + divideBean.getLat() + "\")", value -> {
                binding.pointRL.setVisibility(View.VISIBLE);
                binding.pointCenterImg.setVisibility(View.VISIBLE);
                MyLog.d("showPin>>" + value);
            });
        });
        //取消修改经纬度
        binding.pointCancel.setOnClickListener(v -> {
                    binding.pointCenterImg.setVisibility(View.GONE);
                    binding.pointRL.setVisibility(View.GONE);
                    mWebView.evaluateJavascript("javascript:cancelPin()", value -> {
                    });
                }
        );
        //确认修改经纬度
        binding.pointEdt.setOnClickListener(v -> {
            ConfirmDialog confirmDialog = new ConfirmDialog(MapFragment.this.getActivity(), "确认修改到该位置吗?", (confirmDialog1, v1) -> {
                confirmDialog1.dismiss();
//                updataInstake(markerBean);
            });
            confirmDialog.show();
        });
    }
    /**
     * 获取分水房
     */
    private void getDivideList() {
        ApiManager.getInstance().requestPost(MapFragment.this.getContext(), BASE_URL + "/project/divide/getDivides", DivideListResult.class, null, new SubscriberListener<BaseResponse<DivideListResult>>() {
        ApiManager.getInstance().requestGetHideLoading(MapFragment.this.getContext(), BASE_URL + "/project/divide/getDivides", DivideListResult.class, null, new SubscriberListener<BaseResponse<DivideListResult>>() {
            @Override
            public void onNext(BaseResponse<DivideListResult> t) {
                try {
                    if (t.isSuccess()) {
                        if (t.getContent().getObj() != null && t.getContent().getObj().isEmpty()) {
                        if (t.getContent().getObj() != null && !t.getContent().getObj().isEmpty()) {
                            List<DivideBean> divideBeans = new ArrayList<>();
                            for (DivideResult divideResult : t.getContent().getObj()) {
                                DivideBean divideBean = getDivideBean(divideResult);
                                setMapDivide(divideBean);
                                divideBeans.add(divideBean);
                            }
                            // 使用 RxJava 异步插入数据
                            DaoSingleton.getAsynchInstance(MapFragment.this.getContext()).divideDao().insertAll(divideBeans)
                                    .subscribeOn(Schedulers.io()) // 在 IO 线程上执行
                                    .observeOn(AndroidSchedulers.mainThread()) // 在主线程上观察
                                    .subscribe(() -> {
                                        // 插入成功
                                        Log.i("mWebView", "数据插入成功");
                                    }, throwable -> {
                                        // 插入失败
                                        Log.e("mWebView", "数据插入失败: " + throwable.getMessage());
                                    });
                        }
                    } else {
                        ToastUtil.showToastLong(MapFragment.this.getContext(), t.getMsg());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    CrashReport.postCatchedException(e);
                }
            }
        });
    }
    /**
     * 获取管网
     */
    private void getPipeNetworkList() {
        ApiManager.getInstance().requestGetHideLoading(MapFragment.this.getContext(), BASE_URL + "/project/network/all", PipeNetworkListResult.class, null, new SubscriberListener<BaseResponse<PipeNetworkListResult>>() {
            @Override
            public void onNext(BaseResponse<PipeNetworkListResult> t) {
                try {
                    if (t.isSuccess()) {
                        if (t.getContent().getObj() != null && !t.getContent().getObj().isEmpty()) {
                            List<DivideBean> divideBeans = new ArrayList<>();
                            for (PipeNetworkResult divideResult : t.getContent().getObj()) {
                                PipeNetworkBean divideBean = getPipeNetworkBean(divideResult);
                                setMapDivide(divideBean);
//                                divideBeans.add(divideBean);
                            }
                            // 使用 RxJava 异步插入数据
                            DaoSingleton.getAsynchInstance(MapFragment.this.getContext()).divideDao().insertAll(divideBeans)
                                    .subscribeOn(Schedulers.io()) // 在 IO 线程上执行
@@ -838,11 +995,16 @@
        divideBean.setBlockId(divideResult.getBlockId());
        divideBean.setBlockName(divideResult.getBlockName());
        divideBean.setDivideId(divideResult.getDivideId());
        divideBean.setDivideName(divideResult.getDivideName());
        if (!TextUtils.isEmpty(divideResult.getDivideName())) {
            divideBean.setDivideName(divideResult.getDivideName());
        } else {
            divideBean.setDivideName(divideResult.getName());
        }
        divideBean.setHeader(divideResult.getHeader());
        divideBean.setId(String.valueOf(divideResult.getId()));
        divideBean.setLat(String.valueOf(divideResult.getLat()));
        divideBean.setLng(String.valueOf(divideResult.getLng()));
        divideBean.setId(divideResult.getId());
        divideBean.setLat(divideResult.getLat());
        divideBean.setLng(divideResult.getLng());
        divideBean.setOperateDt(divideResult.getOperateDt());
        divideBean.setOperator(divideResult.getOperator());
        divideBean.setPhone(divideResult.getPhone());
@@ -852,6 +1014,11 @@
        return divideBean;
    }
    private static @NonNull PipeNetworkBean getPipeNetworkBean(PipeNetworkResult divideResult) {
        PipeNetworkBean pipeNetworkBean = new PipeNetworkBean();
        return pipeNetworkBean;
    }
    @Override
    public void onDestroy() {
app/src/main/java/com/dayu/pipirrapp/tool/MyWebViewInterface.java
@@ -43,7 +43,6 @@
                    myContext.showWaterIntakeDetail(data);
                }
            });
        }
    }
@@ -98,4 +97,23 @@
            });
        }
    }
    /**
     * 显示分水房详情
     * @param id
     */
    @JavascriptInterface
    public void showDivideDetail(String id){
        if (myContext instanceof MapFragment) {
            new Handler(Looper.getMainLooper()).post(new Runnable() {
                @Override
                public void run() {
                    // 在主线程上执行UI操作
                    // 更新或操作UI元素的代码
                    myContext.showDivideDetail(id);
                }
            });
        }
    }
}
app/src/main/res/layout/fragment_map.xml
@@ -11,8 +11,7 @@
    <RelativeLayout
        android:id="@+id/webViewRL"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
        android:layout_height="match_parent">
        <WebView
@@ -272,6 +271,57 @@
                        android:src="@drawable/ic_edit_btn" />
                </LinearLayout>
                <LinearLayout
                    android:id="@+id/headerLL"
                    android:layout_width="match_parent"
                    android:layout_height="25dp"
                    android:gravity="center"
                    android:orientation="horizontal">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="负责人:"
                        android:textColor="@color/black"
                        android:textSize="@dimen/common_text_size_little" />
                    <TextView
                        android:id="@+id/header"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:text=""
                        android:textColor="@color/black"
                        android:textSize="@dimen/common_text_size_little" />
                </LinearLayout>
                <LinearLayout
                    android:id="@+id/phoneLL"
                    android:layout_width="match_parent"
                    android:layout_height="25dp"
                    android:gravity="center"
                    android:orientation="horizontal">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="联系电话:"
                        android:textColor="@color/black"
                        android:textSize="@dimen/common_text_size_little" />
                    <TextView
                        android:id="@+id/phone"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:text=""
                        android:textColor="@color/black"
                        android:textSize="@dimen/common_text_size_little" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="25dp"
@@ -296,7 +346,6 @@
                        android:textColor="@color/black"
                        android:textSize="@dimen/common_text_size_little" />
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
expand_button/.gitignore
New file
@@ -0,0 +1 @@
/build
expand_button/build.gradle
New file
@@ -0,0 +1,41 @@
plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
}
android {
    namespace 'com.example.expand_button'
    compileSdk 34
    defaultConfig {
        minSdk 24
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}
dependencies {
    implementation 'androidx.core:core-ktx:1.13.1'
    implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}
expand_button/consumer-rules.pro
expand_button/proguard-rules.pro
New file
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
expand_button/src/androidTest/java/com/example/expand_button/ExampleInstrumentedTest.kt
New file
@@ -0,0 +1,24 @@
package com.example.expand_button
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun useAppContext() {
        // Context of the app under test.
        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
        assertEquals("com.example.expand_button.test", appContext.packageName)
    }
}
expand_button/src/main/AndroidManifest.xml
New file
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
expand_button/src/main/java/com/example/expand_button/ExpandButton.kt
New file
@@ -0,0 +1,14 @@
package com.example.expand_button
class ExpandButton {
}
expand_button/src/test/java/com/example/expand_button/ExampleUnitTest.kt
New file
@@ -0,0 +1,17 @@
package com.example.expand_button
import org.junit.Test
import org.junit.Assert.*
/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }
}
settings.gradle
@@ -1,2 +1,4 @@
rootProject.name = "pipIrrApp"
include ':app'
include ':mylibrary'
include ':expand_button'