From f163344ffeb1e699fa1a2dfb8a70055bb1b9be7e Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期一, 09 九月 2024 15:09:17 +0800
Subject: [PATCH] 首页界面优化,地图模块优化,部分下载地图瓦片功能代码
---
app/src/main/res/drawable/bottom_order_white.xml | 26 +
app/src/main/java/com/dayu/pipirrapp/utils/WebViewUtils.java | 85 +++
app/src/main/assets/js/map.js | 243 ++++++++++
app/src/main/java/com/dayu/pipirrapp/service/PushService.java | 14
app/src/main/res/drawable/bottom_circle_bg.xml | 6
app/src/main/java/com/dayu/pipirrapp/MyApplication.java | 6
app/src/main/res/drawable/bottom_my_white.xml | 27 +
app/src/main/res/drawable/bottom_map_black.xml | 28 +
app/src/main/res/drawable/vector_location.xml | 5
app/src/main/res/values/colors.xml | 3
app/src/main/res/drawable/vector_timer.xml | 10
app/src/main/res/drawable/vector_adjust.xml | 5
app/src/main/res/drawable/vector_close.xml | 5
app/src/main/res/drawable/bottom_map_white.xml | 28 +
app/src/main/res/drawable/vector_btn_date.xml | 5
app/src/main/assets/img/marker_black.svg | 1
app/src/main/res/layout/activity_main.xml | 140 ++++-
app/src/main/assets/img/marker_red.svg | 1
app/src/main/java/com/dayu/pipirrapp/service/MyCommonService.java | 6
app/build.gradle | 35 +
app/src/main/res/drawable/vector_photo_camera.xml | 6
app/src/main/res/values/dimens.xml | 1
app/src/main/res/drawable/vector_loop.xml | 5
app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java | 64 +
app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java | 10
app/src/main/assets/img/location.png | 0
app/src/main/java/com/dayu/pipirrapp/utils/MapJpgUtils.java | 150 ++++++
app/src/main/AndroidManifest.xml | 14
app/src/main/java/com/dayu/pipirrapp/js/MyWebViewInterface.java | 19
app/src/main/res/drawable/bottom_my_black.xml | 27 +
app/src/main/java/com/dayu/pipirrapp/tool/RocketMQConsumer.java | 62 ++
app/src/main/res/drawable/vector_location_clock.xml | 5
app/src/main/res/drawable/bottom_order_black.xml | 26 +
app/src/main/res/drawable/vector_list.xml | 5
app/src/main/res/layout/fragment_map.xml | 13
app/src/main/assets/index.html | 35 +
app/src/main/res/menu/main_bottom_nav_menu.xml | 18
app/src/main/java/com/dayu/pipirrapp/activity/MainActivity.java | 105 +++-
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java | 165 ++++--
app/src/main/res/drawable/vector_distance.xml | 10
app/src/main/java/com/dayu/pipirrapp/net/ApiService.java | 5
app/src/main/res/layout/top_title.xml | 1
42 files changed, 1,247 insertions(+), 178 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index fb73009..59acc35 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -67,6 +67,18 @@
viewBinding {
enabled = true;
}
+ packagingOptions {
+ exclude 'META-INF/DEPENDENCIES'
+ // 濡傛灉浣犺繕閬囧埌鍏朵粬閲嶅鐨凪ETA-INF鏂囦欢锛屼篃鍙互娣诲姞绫讳技鐨勬帓闄よ鍒�
+ exclude 'META-INF/LICENSE'
+ exclude 'META-INF/LICENSE.txt'
+ exclude 'META-INF/NOTICE'
+ exclude 'META-INF/NOTICE.txt'
+ // RocketMQ鐗规湁鐨勬帓闄ら」锛堝鏋滈渶瑕侊級
+ exclude 'META-INF/INDEX.LIST'
+ exclude 'META-INF/spring.factories'
+ exclude 'META-INF/spring.handlers'
+ }
}
@@ -115,31 +127,31 @@
// //鎺ㄩ�佺浉鍏�
// // 姝ゅ浠Push 5.0.0 鐗堟湰涓轰緥锛�5.0.0 鐗堟湰寮�濮嬪彲浠ヨ嚜鍔ㄦ媺鍙� JCore 鍖咃紝鏃犻渶鍙﹀閰嶇疆
- implementation 'cn.jiguang.sdk:jpush:5.2.2'
+// implementation 'cn.jiguang.sdk:jpush:5.2.2'
// //鑻ヤ笉闆嗘垚鍘傚晢閫氶亾锛屽彲鐩存帴璺宠繃浠ヤ笅渚濊禆
// // 鏋佸厜鍘傚晢鎻掍欢鐗堟湰涓庢帴鍏� JPush 鐗堟湰淇濇寔涓�鑷达紝涓嬪悓
// // 鎺ュ叆鍗庝负鍘傚晢
- implementation 'com.huawei.hms:push:6.5.0.300'
- implementation 'cn.jiguang.sdk.plugin:huawei:5.2.2'
+// implementation 'com.huawei.hms:push:6.5.0.300'
+// implementation 'cn.jiguang.sdk.plugin:huawei:5.2.2'
// // 鎺ュ叆 FCM 鍘傚晢
// implementation 'com.google.firebase:firebase-messaging:23.0.5'
// implementation 'cn.jiguang.sdk.plugin:fcm:5.2.2'
// // 鎺ュ叆榄呮棌鍘傚晢
- implementation 'cn.jiguang.sdk.plugin:meizu:5.2.2'
+// implementation 'cn.jiguang.sdk.plugin:meizu:5.2.2'
// // 鎺ュ叆 VIVO 鍘傚晢
- implementation 'cn.jiguang.sdk.plugin:vivo:5.2.2'
+// implementation 'cn.jiguang.sdk.plugin:vivo:5.2.2'
// // 鎺ュ叆灏忕背鍘傚晢
- implementation 'cn.jiguang.sdk.plugin:xiaomi:5.2.2'
+// implementation 'cn.jiguang.sdk.plugin:xiaomi:5.2.2'
// // 鎺ュ叆 OPPO 鍘傚晢
// implementation 'cn.jiguang.sdk.plugin:oppo:5.2.2'
// // JPush Android SDK v4.6.0 寮�濮嬶紝闇�瑕佸崟鐙紩鍏� oppo 鍘傚晢 aar 锛岃涓嬭浇瀹樼綉 SDK 鍖呭苟鎶� jpush-android-xxx-release/third-push/oppo/libs 涓嬬殑 aar 鏂囦欢鍗曠嫭鎷疯礉涓�浠藉埌搴旂敤 module/libs 涓�
// implementation(name: 'com.heytap.msp-push-3.1.0', ext: 'aar')
// //浠ヤ笅涓� OPPO 3.1.0 aar闇�瑕佷緷璧�
- implementation 'com.google.code.gson:gson:2.6.2'
- implementation 'commons-codec:commons-codec:1.6'
- implementation 'androidx.annotation:annotation:1.1.0'
+// implementation 'com.google.code.gson:gson:2.6.2'
+// implementation 'commons-codec:commons-codec:1.6'
+// implementation 'androidx.annotation:annotation:1.1.0'
// // 鎺ュ叆鑽h��鍘傚晢
- implementation 'cn.jiguang.sdk.plugin:honor:5.2.2'
+// implementation 'cn.jiguang.sdk.plugin:honor:5.2.2'
// apply plugin: 'com.google.gms.google-services'
// apply plugin: 'com.huawei.agconnect'
@@ -150,4 +162,7 @@
//骞挎挱閫氫俊
implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0'
+
+ //闃块噷鐨凴ocketMQ
+ implementation 'org.apache.rocketmq:rocketmq-client:4.9.4'
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 18f83ca..5773a76 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -95,13 +95,13 @@
<!--鐧惧害瀹氫綅-->
- <meta-data
- android:name="com.baidu.lbsapi.API_KEY"
- android:value="Ky5wvrB9A9Rztsh3rQO8v8oNRgQM27NV"></meta-data>
- <service
- android:name="com.baidu.location.f"
- android:enabled="true"
- android:process=":remote"></service>
+<!-- <meta-data-->
+<!-- android:name="com.baidu.lbsapi.API_KEY"-->
+<!-- android:value="Ky5wvrB9A9Rztsh3rQO8v8oNRgQM27NV"></meta-data>-->
+<!-- <service-->
+<!-- android:name="com.baidu.location.f"-->
+<!-- android:enabled="true"-->
+<!-- android:process=":remote"></service>-->
</application>
diff --git a/app/src/main/assets/img/location.png b/app/src/main/assets/img/location.png
new file mode 100644
index 0000000..e1e4ad3
--- /dev/null
+++ b/app/src/main/assets/img/location.png
Binary files differ
diff --git a/app/src/main/assets/img/marker_black.svg b/app/src/main/assets/img/marker_black.svg
new file mode 100644
index 0000000..c3bf707
--- /dev/null
+++ b/app/src/main/assets/img/marker_black.svg
@@ -0,0 +1 @@
+<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="#000000"><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 M12,11.75c-1.38,0-2.5-1.12-2.5-2.5s1.12-2.5,2.5-2.5s2.5,1.12,2.5,2.5 S13.38,11.75,12,11.75z"/></svg>
\ No newline at end of file
diff --git a/app/src/main/assets/img/marker_red.svg b/app/src/main/assets/img/marker_red.svg
new file mode 100644
index 0000000..24e6869
--- /dev/null
+++ b/app/src/main/assets/img/marker_red.svg
@@ -0,0 +1 @@
+<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 M12,11.75c-1.38,0-2.5-1.12-2.5-2.5s1.12-2.5,2.5-2.5s2.5,1.12,2.5,2.5 S13.38,11.75,12,11.75z"/></svg>
\ No newline at end of file
diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html
new file mode 100644
index 0000000..69d3cf5
--- /dev/null
+++ b/app/src/main/assets/index.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>澶╁湴鍥�</title>
+ <style>
+ /* 纭繚 body 鍜� html 鍏呮弧鏁翠釜瑙嗗彛 */
+ html, body {
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+ overflow: hidden; /* 闃叉婊氬姩鏉″嚭鐜� */
+ }
+ /* 纭繚鍦板浘瀹瑰櫒鍏呮弧鏁翠釜瑙嗗彛 */
+ #mapDiv {
+ width: 100%;
+ height: 100%;
+ position: absolute; /* 淇濊瘉鍦板浘鍏ㄥ睆 */
+ top: 0;
+ left: 0;
+ }
+ </style>
+ <script src="http://api.tianditu.gov.cn/api?v=4.0&tk=d8beed89b43160a9a185e5aff431f85d"
+ type="text/javascript"></script>
+</head>
+
+<body>
+ <div id="mapDiv"></div>
+ <script src="js/map.js"></script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/app/src/main/assets/js/map.js b/app/src/main/assets/js/map.js
new file mode 100644
index 0000000..8254aa0
--- /dev/null
+++ b/app/src/main/assets/js/map.js
@@ -0,0 +1,243 @@
+(function () {
+ // 鍥剧墖璺緞
+ const locationIMGPath = 'img/location.png';
+ const markerBalckPath = 'img/marker_black.svg';
+ const markerRedPath = 'img/marker_red.svg';
+
+ let map;
+ let lastMarker = null;
+ let lastClickedMarker = null;
+ let isShowWaterIntakeDetail = false;
+ let zoom=12;
+
+
+ document.addEventListener('DOMContentLoaded', function () {
+
+ initMap();
+ // buttonOverLay();
+ mountMethodToWindow();
+
+ });
+ window.onload = function() {
+ //鍔犺浇鍧愭爣鐐�
+ window.Android.loadMarker();
+ };
+ // 鍒濆鍖栧湴鍥�
+ function initMap() {
+ var imageURL = "http://t0.tianditu.gov.cn/img_w/wmts?" +
+ "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
+ "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=d8beed89b43160a9a185e5aff431f85d";
+ //鍒涘缓鑷畾涔夊浘灞傚璞�
+ var lay = new T.TileLayer(imageURL, { minZoom: 1, maxZoom: 18 });
+ var config = { layers: [lay] };
+ map = new T.Map("mapDiv", config);
+ map.centerAndZoom(new T.LngLat(116.40769, 39.89945), zoom); //鍦板浘鐨勫垵濮嬪寲涓績鐐癸紝姝や负鍖椾含鐨勭粡绾害
+ map.addEventListener("click", closeWaterIntakeDetail);
+ }
+
+ // 鍦板浘鐐瑰嚮鍚庤幏鍙栫粡绾害
+ function getLngLat(lnglat) {
+ console.log(lnglat.lng.toFixed(6) + "," + lnglat.lat.toFixed(6));
+ addClickOverLay(lnglat);
+ }
+
+ // 鐐瑰嚮鍚庢坊鍔犲潗鏍囩偣
+ function addClickOverLay(lnglat) {
+ removeMyOverLay();
+
+ let marker = new T.Marker(
+ new T.LngLat(lnglat.lng, lnglat.lat) // 鍒涘缓鏍囨敞
+ );
+ map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+
+ // 璁剧疆寮瑰嚭鐨勭獥鍙f牱寮�
+ let infoWin = new T.InfoWindow();
+ let sContent =
+ "<div style='margin:0px;'>" +
+ "<div style='margin:10px 10px; '>" +
+ "<div >鐢佃瘽 : (010)88187700 <br>鍦板潃锛氬寳浜競椤轰箟鍖烘満鍦轰笢璺浗闂ㄥ晢鍔″尯鍦扮悊淇℃伅浜т笟鍥�2鍙锋ゼ澶╁湴鍥惧ぇ鍘�" +
+ "</div>" +
+ "<input width: 80px;height: 24px; text-align: center; background: #5596de;color: #FFF;border: none;display: block;cursor: pointer;' type='button' value='璺宠浆璇︽儏' onClick=\"showToast()\">" +
+ "</div>" +
+ "</div>";
+ infoWin.setContent(sContent);
+
+ // 娣诲姞鐐瑰嚮浜嬩欢
+ marker.addEventListener("click", function () {
+ marker.openInfoWindow(infoWin);
+ });
+
+ lastMarker = marker;
+ }
+
+ // 鍒犻櫎涓婃鐐瑰嚮鍚庢坊鍔犵殑鏍囨敞
+ function removeMyOverLay() {
+ if (lastMarker !== null) {
+ map.removeOverLay(lastMarker); // 灏嗘爣娉ㄤ粠鍦板浘涓Щ闄�
+ }
+ }
+
+ // 妯℃嫙娣诲姞鍙栨按鍙f爣娉�
+ function buttonOverLay() {
+ map.clearOverLays(); // 娓呯悊鍦板浘涓婄殑鎵�鏈夎鐩栫墿
+
+ let data_info = [
+ [116.417854, 39.921988, "235鍙栨按鍙�"],
+ [116.406605, 39.921585, "237鍙栨按鍙�"],
+ [116.412222, 39.912345, "236鍙栨按鍙�"]
+ ];
+
+ for (let i = 0; i < data_info.length; i++) {
+ let icon = new T.Icon({
+ iconUrl: markerBalckPath,
+ iconSize: new T.Point(27, 27),
+ iconAnchor: new T.Point(10, 25)
+ });
+
+ let marker = new T.Marker(
+ new T.LngLat(data_info[i][0], data_info[i][1]), // 鍒涘缓鏍囨敞
+ { icon: icon }
+ );
+
+ marker.addEventListener("click", function (data) {
+ addMarkerListener(data);
+ });
+
+ map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+
+ let label = new T.Label({
+ text: data_info[i][2],
+ position: marker.getLngLat(),
+ offset: new T.Point(-50, 10), // 璁剧疆鏍囨敞鏂囧瓧鐨勪綅缃�
+ opacity: 1, // 璁剧疆鏂囨湰鐨勬樉绀轰笉閫忔槑搴︼紙鑼冨洿0-1锛�
+ });
+ label.setBorderLine(0); // 璁剧疆鏂囨湰鐨勮竟妗嗙嚎瀹�
+ label.setBackgroundColor("transparent"); // 璁剧疆鏂囨湰鐨勮儗鏅壊锛堥�忔槑鑹诧級
+ label.setFontColor("#0000FF");
+ label.setFontSize(10);
+ map.addOverLay(label);
+ }
+ }
+
+ // 鏄剧ず鏍囨敞鐐瑰嚮鍚庣殑绐楀彛
+ function openInfo(content, e) {
+ let point = e.lnglat;
+ let markerInfoWin = new T.InfoWindow(content, {
+ offset: new T.Point(0, -30)
+ });
+ map.openInfoWindow(markerInfoWin, point); // 寮�鍚俊鎭獥鍙�
+ }
+
+ // 鎵嬫満鑾峰彇鍒板畾浣嶅悗鏄剧ず瀹氫綅
+ function locationOverLay(lng, lag) {
+ map.centerAndZoom(new T.LngLat(lng, lag), 18);
+
+ let icon = new T.Icon({
+ iconUrl: locationIMGPath,
+ iconSize: new T.Point(27, 27),
+ iconAnchor: new T.Point(10, 25)
+ });
+
+ let marker = new T.Marker(new T.LngLat(lng, lag), { icon: icon });
+ map.addOverLay(marker);
+ }
+
+ // 灏嗘柟娉曟寕杞藉埌 window 涓�
+ function mountMethodToWindow() {
+ window.locationOverLay = locationOverLay;
+ window.showToast = showToast;
+ window.addMarker = addMarker;
+ }
+
+ // 璋冪敤鍘熺敓瀹夊崜鏂规硶鏄剧ず鍙栨按鍙h鎯�
+ function showWaterIntakeDetail(data) {
+ isShowWaterIntakeDetail = true;
+ window.Android.showWaterIntakeView(data);
+ }
+
+ // 璋冪敤鍘熺敓瀹夊崜鏂规硶闅愯棌鍙栨按鍙h鎯�
+ function closeWaterIntakeDetail(data) {
+ if (lastClickedMarker!== null) {
+ // 濡傛灉鏈夌偣鍑诲彇姘村彛鍒欏皢鍙栨按鍙f仮澶嶆垚榛戣壊
+ // 涓婃鐐瑰嚮鐨勬爣娉ㄦ敼涓洪粦鑹�
+ var defaulticon = new T.Icon({
+ iconUrl: markerBalckPath,
+ iconSize: new T.Point(27, 27),
+ iconAnchor: new T.Point(10, 25)
+ });
+ lastClickedMarker.setIcon(defaulticon);
+ }
+ if (isShowWaterIntakeDetail) {
+ // 鍋囧鏄剧ず浜嗗彇姘村彛璇︽儏鍒欓殣钘忓彇姘村彛璇︽儏
+ isShowWaterIntakeDetail = false;
+ window.Android.closeWaterIntakeView();
+ } else {
+ // 鍋囧娌℃湁鏄剧ず鍙栨按鍙e垯娣诲姞鐐瑰嚮鐨勫潗鏍�
+ getLngLat(data.lnglat);
+ }
+ }
+
+ // 鐐瑰嚮鏍囨敞鐨勪簨浠�
+ function addMarkerListener(data) {
+ chageMarkerIcon(data);
+ showWaterIntakeDetail("妯℃嫙鏁版嵁");
+ }
+
+ // 淇敼鐐瑰嚮鏍囨敞鐨勫浘鏍�
+ function chageMarkerIcon(data) {
+ // 鐐瑰嚮鐨勬爣娉ㄦ敼涓虹孩鑹�
+ var currentMarker = data.target;
+ // 鐐瑰嚮鍚庡浘鏍�
+ var clickedIcon = new T.Icon({
+ iconUrl: markerRedPath,
+ iconSize: new T.Point(27, 27),
+ iconAnchor: new T.Point(10, 25)
+ });
+ // 璁剧疆褰撳墠鐐瑰嚮鐨� marker 涓虹偣鍑诲悗鍥炬爣
+ currentMarker.setIcon(clickedIcon);
+ // 鍒ゆ柇鐐瑰嚮鐨勪笉鏄悓涓�涓潗鏍�
+ if (lastClickedMarker!== null) {
+ if (!isEqualsLngLat(data.target.getLngLat(), lastClickedMarker.getLngLat())) {
+ var defaulticon = new T.Icon({
+ iconUrl: markerBalckPath,
+ iconSize: new T.Point(27, 27),
+ iconAnchor: new T.Point(10, 25)
+ });
+ lastClickedMarker.setIcon(defaulticon);
+ }
+ }
+ lastClickedMarker = data.target;
+ }
+ //璋冨畨鍗撳師鐢�
+ function showToast() {
+ // 璋冪敤 JavaScript 鎺ュ彛瀵硅薄鐨勬柟娉�
+ window.Android.showToast('Hello, Android!');
+ }
+ // 鍒ゆ柇涓や釜鍧愭爣鏄惁涓�鑷�
+ function isEqualsLngLat(data1, data2) {
+ return data1.lat === data2.lat && data1.lng === data2.lng;
+ }
+ //娣诲姞浠庡師鐢熶紶杩囨潵鐨勫潗鏍囧苟鏄剧ず鍦ㄥ湴鍥句笂
+ function addMarker(jsonData) {
+ console.log("function銆嬨�嬨�嬨�嬨�媋ddMarker");
+ var array = JSON.parse(jsonData);
+ var icon = new T.Icon({
+ iconUrl: markerBalckPath,
+ iconSize: new T.Point(27, 27),
+ iconAnchor: new T.Point(10, 25)
+ });
+ array.forEach(element => {
+ let marker = new T.Marker(
+ new T.LngLat(element[0], element[1]) // 鍒涘缓鏍囨敞
+ , { icon: icon });
+ //娣诲姞鐐瑰嚮浜嬩欢
+ marker.addEventListener("click", (data) => {
+ addMarkerListener(data)
+ });
+ map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+ });
+ return "addMarker鍔犺浇鎴愬姛"
+ }
+
+
+})();
diff --git a/app/src/main/java/com/dayu/pipirrapp/MyApplication.java b/app/src/main/java/com/dayu/pipirrapp/MyApplication.java
index 6beaa1c..b2eb42f 100644
--- a/app/src/main/java/com/dayu/pipirrapp/MyApplication.java
+++ b/app/src/main/java/com/dayu/pipirrapp/MyApplication.java
@@ -5,7 +5,7 @@
import com.dayu.pipirrapp.net.ApiManager;
import com.tencent.bugly.crashreport.CrashReport;
-import cn.jpush.android.api.JPushInterface;
+//import cn.jpush.android.api.JPushInterface;
/**
* author: zuo
@@ -23,8 +23,8 @@
ApiManager.init();
- JPushInterface.setDebugMode(true);
- JPushInterface.init(this);
+// JPushInterface.setDebugMode(true);
+// JPushInterface.init(this);
CrashReport.initCrashReport(getApplicationContext(), "3d4bcf7046", false);
}
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/activity/MainActivity.java b/app/src/main/java/com/dayu/pipirrapp/activity/MainActivity.java
index 52163b4..e06568d 100644
--- a/app/src/main/java/com/dayu/pipirrapp/activity/MainActivity.java
+++ b/app/src/main/java/com/dayu/pipirrapp/activity/MainActivity.java
@@ -3,16 +3,15 @@
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
+import com.dayu.pipirrapp.R;
import com.dayu.pipirrapp.adapter.TabAdapter;
import com.dayu.pipirrapp.databinding.ActivityMainBinding;
-import com.dayu.pipirrapp.fragment.BaseFragment;
import com.dayu.pipirrapp.fragment.MainFragment;
import com.dayu.pipirrapp.fragment.MapFragment;
import com.dayu.pipirrapp.fragment.MyFragment;
@@ -20,47 +19,49 @@
import java.util.ArrayList;
import java.util.List;
-
/**
- *
+ * 棣栭〉
*/
-public class MainActivity extends BaseActivity {
- ActivityMainBinding binding;
- List<Fragment> mFragment = new ArrayList<>();
+public class MainActivity extends AppCompatActivity {
+ private ActivityMainBinding binding;
+ private List<Fragment> fragments = new ArrayList<>();
+ private long mExitTime;
+ private enum Tab {
+ ORDER, MAP, MY
+ }
@Override
protected void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(LayoutInflater.from(this));
- MapFragment mapFragment = new MapFragment();
setContentView(binding.getRoot());
- mFragment.add(mapFragment);
- mFragment.add(new MainFragment());
- mFragment.add(new MyFragment());
+
+ setupFragments();
+ initView();
initTab();
}
- private void getPermission(){
-
+ private void setupFragments() {
+ fragments.add(new MainFragment());
+ fragments.add(new MapFragment());
+ fragments.add(new MyFragment());
}
-
+ private void initView() {
+ binding.orderLL.setOnClickListener(v -> changeBottomState(Tab.ORDER));
+ binding.mapLL.setOnClickListener(v -> changeBottomState(Tab.MAP));
+ binding.myLL.setOnClickListener(v -> changeBottomState(Tab.MY));
+ }
private void initTab() {
- TabAdapter adapter = new TabAdapter(getSupportFragmentManager(), mFragment);
+ TabAdapter adapter = new TabAdapter(getSupportFragmentManager(), fragments);
binding.viewPager.setAdapter(adapter);
binding.viewPager.setPagingEnabled(false);
- //璁剧疆缂撳瓨view 鐨勪釜鏁�
- binding.viewPager.setOffscreenPageLimit(3);
- // 灏� ViewPager 涓� TabLayout 鍏宠仈
- binding.tabLayout.setupWithViewPager(binding.viewPager);
+ binding.viewPager.setOffscreenPageLimit(fragments.size());
+ binding.viewPager.setCurrentItem(1); // 榛樿鏄剧ず鍦板浘椤�
}
- long mExitTime;
-
- //鐐瑰嚮涓ゆ閫�鍑虹▼搴� 鏈夋椂闂撮棿闅� 闂撮殧鍐呯偣鍑诲垯閫�鍑虹▼搴� 鍚﹀垯 鍒欐彁绀�
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
@@ -68,11 +69,63 @@
Toast.makeText(MainActivity.this, "鍐嶆寜涓�娆¢��鍑虹▼搴�", Toast.LENGTH_SHORT).show();
mExitTime = System.currentTimeMillis();
} else {
- MainActivity.this.finish();
+ finish();
}
return true;
}
return super.onKeyDown(keyCode, event);
}
-}
\ No newline at end of file
+ /**
+ * 淇敼搴曢儴鐘舵��
+ */
+ private void changeBottomState(Tab tab) {
+ resetTabState();
+ switch (tab) {
+ case ORDER:
+ updateTabUI(0, R.drawable.bottom_order_white, R.color.white);
+ break;
+ case MAP:
+ updateTabUI(1, R.drawable.bottom_map_white, R.color.white);
+ break;
+ case MY:
+ updateTabUI(2, R.drawable.bottom_my_white, R.color.white);
+ break;
+ }
+ }
+
+ /**
+ * 鏇存柊鏌愪釜 Tab 鐨� UI 鐘舵��
+ */
+ private void updateTabUI(int position, int iconResId, int textColorResId) {
+ binding.viewPager.setCurrentItem(position);
+ switch (position) {
+ case 0:
+ binding.orderImg.setImageDrawable(ContextCompat.getDrawable(this, iconResId));
+ binding.orderText.setTextColor(ContextCompat.getColor(this, textColorResId));
+ break;
+ case 1:
+ binding.mapImg.setImageDrawable(ContextCompat.getDrawable(this, iconResId));
+ binding.mapText.setTextColor(ContextCompat.getColor(this, textColorResId));
+ break;
+ case 2:
+ binding.myImg.setImageDrawable(ContextCompat.getDrawable(this, iconResId));
+ binding.myText.setTextColor(ContextCompat.getColor(this, textColorResId));
+ break;
+ }
+ }
+
+ /**
+ * 閲嶇疆鎵�鏈� Tab 鐨勯粯璁ょ姸鎬�
+ */
+ private void resetTabState() {
+ binding.orderImg.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.bottom_order_black));
+ binding.orderText.setTextColor(ContextCompat.getColor(this, R.color.black));
+
+ binding.mapImg.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.bottom_map_black));
+ binding.mapText.setTextColor(ContextCompat.getColor(this, R.color.black));
+
+ binding.myImg.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.bottom_my_black));
+ binding.myText.setTextColor(ContextCompat.getColor(this, R.color.black));
+ }
+}
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 6c07ea7..d2bff28 100644
--- a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
+++ b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
@@ -4,30 +4,32 @@
import android.content.Intent;
import android.location.LocationManager;
import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.webkit.JsResult;
-import android.webkit.WebChromeClient;
-import android.webkit.WebSettings;
+import android.webkit.ValueCallback;
+import android.webkit.WebResourceError;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebResourceResponse;
import android.webkit.WebView;
+import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.lifecycle.DefaultLifecycleObserver;
-import androidx.lifecycle.LifecycleOwner;
import com.dayu.pipirrapp.databinding.FragmentMapBinding;
import com.dayu.pipirrapp.js.MyWebViewInterface;
import com.dayu.pipirrapp.observer.MapFragmenObserver;
import com.dayu.pipirrapp.service.MyLocationService;
+import com.dayu.pipirrapp.utils.MapJpgUtils;
import com.dayu.pipirrapp.utils.MyLog;
-import com.dayu.pipirrapp.utils.ToastUtil;
+import com.dayu.pipirrapp.utils.WebViewUtils;
-import java.util.List;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Random;
/**
* author: zuo
@@ -60,14 +62,54 @@
binding = FragmentMapBinding.inflate(inflater, container, false);
Log.i("MapFragment", "onCreateView");
mWebView = binding.webView;
- initWebView();
- mWebView.loadUrl("http://192.168.3.178:3000/");
+ mWebView = WebViewUtils.initWebView(mWebView);
+ MyWebViewInterface myWebViewInterface = new MyWebViewInterface(MapFragment.this);
+ mWebView.addJavascriptInterface(myWebViewInterface, "Android");
+ mWebView.loadUrl("file:///android_asset/index.html");
+
initView();
//寮�鍚畾浣�
Intent location = new Intent(this.getActivity(), MyLocationService.class);
location.putExtra("isSingle", false);
this.getActivity().startService(location);
return binding.getRoot();
+ }
+
+ /**
+ * 娣诲姞鏍囨敞鐐�
+ */
+ public void addMarker() {
+ Random random = new Random();
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("[");
+
+ // 涓浗缁忕含搴﹁寖鍥�
+ double minLongitude = 73.43;
+ double maxLongitude = 135.05;
+ double minLatitude = 3.52;
+ double maxLatitude = 53.57;
+
+ for (int i = 0; i < 1000; i++) {
+ stringBuilder.append("[");
+ // 鐢熸垚闅忔満缁忓害
+ double longitude = minLongitude + (maxLongitude - minLongitude) * random.nextDouble();
+ stringBuilder.append(longitude);
+ stringBuilder.append(",");
+ // 鐢熸垚闅忔満绾害
+ double latitude = minLatitude + (maxLatitude - minLatitude) * random.nextDouble();
+ stringBuilder.append(latitude);
+ stringBuilder.append(",\"237鍙栨按鍙"],");
+ }
+ stringBuilder.append("[116.417854,39.921988,\"235鍙栨按鍙"]]");
+ String jsonData = stringBuilder.toString().replace("\\", "\\\\").replace("\"", "\\\"");
+// String jsonData = "[[116.417854,39.921988,\"235鍙栨按鍙"],[116.406605,39.921585,\"237鍙栨按鍙"],[116.412222,39.912345,\"236鍙栨按鍙"]]";
+ Log.i("mWebView", "addMarker????????????" + jsonData);
+ mWebView.evaluateJavascript("javascript:addMarker(\"" + jsonData + "\")", new ValueCallback<String>() {
+ @Override
+ public void onReceiveValue(String value) {
+ Log.i("mWebView", "addMarker锛侊紒锛侊紒锛侊紒锛侊紒锛�" + value);
+ }
+ });
}
@@ -81,7 +123,9 @@
@Override
public void onPause() {
super.onPause();
+ //
mWebView.onPause(); // 閫氳繃 onPause 鍔ㄤ綔閫氱煡鍐呮牳鏆傚仠鎵�鏈夌殑鍔ㄤ綔锛屽 DOM 鐨勮В鏋愩�乸lugin 鐨勬墽琛屻�丣avaScript 鎵ц绛�
+
}
@Override
@@ -91,73 +135,66 @@
mWebView.destroy(); // 褰� Activity 瑕� destroy 鏃讹紝搴斿厛灏� WebView 绉婚櫎锛屽啀 destroy 鎺�
}
- void initWebView() {
-// getActivity().getWindow().setFlags(
-// WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
-// WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
- // WebView 閰嶇疆
- WebSettings webSettings = mWebView.getSettings();
- // 鐢熷懡鍛ㄦ湡
-// 鍓嶈繘鍚庨��
- if (mWebView.canGoBack()) {
- mWebView.goBack();
- }
- if (mWebView.canGoForward()) {
- mWebView.goForward();
- }
- // 缂撳瓨鐩稿叧
- mWebView.clearCache(false); // 娓呴櫎缂撳瓨
-// mWebView.clearHistory(); // 娓呴櫎鍘嗗彶
-// mWebView.clearFormData(); // 娓呴櫎琛ㄥ崟鏁版嵁
- webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);// 璁剧疆缂撳瓨妯″紡
- webSettings.setDatabaseEnabled(true);
- webSettings.setDomStorageEnabled(true);//寮�鍚疍OM缂撳瓨锛屽叧闂殑璇滺5鑷韩鐨勪竴浜涙搷浣滄槸鏃犳晥鐨�
-// 缂撳瓨妯″紡
-// LOAD_DEFAULT: 榛樿锛屾牴鎹� cache-control 鍐冲畾鏄惁浠庣綉缁滀笂鍙栨暟鎹�
-// LOAD_NORMAL: API level 17 涓凡缁忓簾寮�, 浠嶢PI level 11寮�濮嬩綔鐢ㄥ悓 LOAD_DEFAULT 妯″紡
-// LOAD_CACHE_ELSE_NETWORK: 鍙鏈湴鏈夛紝鏃犺鏄惁杩囨湡锛屾垨鑰� no-cache锛岄兘浣跨敤缂撳瓨涓殑鏁版嵁
-// LOAD_NO_CACHE: 涓嶄娇鐢ㄧ紦瀛橈紝鍙粠缃戠粶鑾峰彇鏁版嵁
-// LOAD_CACHE_ONLY: 涓嶄娇鐢ㄧ綉缁滐紝鍙鍙栨湰鍦扮紦瀛樻暟鎹�
- // js 鐩稿叧
- webSettings.setJavaScriptEnabled(true); // 鏀寔 js銆傚鏋滅鍒板悗鍙版棤娉曢噴鏀� js 瀵艰嚧鑰楃數锛屽簲鍦� onStop 鍜� onResume 閲屽垎鍒鎴� false 鍜� true
- // mWebView.addJavascriptInterface(new WebAppInterface(this), "android"); // js 鎺ュ彛
-
- // webSettings.setPluginsEnabled(true); // 鏀寔鎻掍欢
- // 璁剧疆鑷�傚簲灞忓箷锛屼袱鑰呭悎鐢�
- webSettings.setUseWideViewPort(true); // 灏嗗浘鐗囪皟鏁村埌閫傚悎 WebView 鐨勫ぇ灏�
- webSettings.setLoadWithOverviewMode(true); // 缂╂斁鑷冲睆骞曠殑澶у皬
- // 缂╂斁鎿嶄綔
- webSettings.setSupportZoom(true); // 鏀寔缂╂斁锛岄粯璁や负 true
- webSettings.setBuiltInZoomControls(true); // 璁剧疆鍐呯疆鐨勭缉鏀炬帶浠讹紝鑻ヤ负 false锛屽垯璇� WebView 涓嶅彲缂╂斁
- webSettings.setDisplayZoomControls(false); // 闅愯棌鍘熺敓鐨勭缉鏀炬帶浠�
- webSettings.setLoadsImagesAutomatically(true);//棰勫姞杞�
- //webView寮笿sAlert
- mWebView.setWebChromeClient(new WebChromeClient() {
- @Override
- public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
- return super.onJsAlert(view, url, message, result);
- }
- });
- MyWebViewInterface myWebViewInterface=new MyWebViewInterface(this);
- mWebView.addJavascriptInterface(myWebViewInterface,"Android");
- }
void initView() {
+ //璺宠浆鍒版寚瀹氫綅缃�
binding.flyBtn.setOnClickListener(v -> {
mWebView.evaluateJavascript("javascript:locationOverLay(116.399565,39.89432)", value -> {
});
});
+ mWebView.setWebViewClient(new WebViewClient() {
+ @Override
+ public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
+ String url = request.getUrl().toString();
+ // 妫�鏌ユ湰鍦扮紦瀛�
+ File cachedTile = MapJpgUtils.getInsatance(MapFragment.this.getContext()).getCachedTile(url);
+ if (cachedTile != null && cachedTile.exists()) {
+ // 鍒ゆ柇缂撳瓨鏄惁杩囨湡
+ if (!MapJpgUtils.getInsatance(MapFragment.this.getContext()).isCacheExpired(cachedTile)) {
+ try {
+ // 浠庣紦瀛樺姞杞界摝鐗�
+ return new WebResourceResponse("image/jpg", "utf-8", new FileInputStream(cachedTile));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return super.shouldInterceptRequest(view, request);
+ }
+
+ @Override
+ public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
+ super.onReceivedError(view, request, error);
+ // 鎹曡幏鍔犺浇杩囩▼涓彂鐢熺殑閿欒
+ int errorCode = error.getErrorCode();
+ String description = error.getDescription().toString();
+ String failingUrl = request.getUrl().toString();
+ Log.e("setWebViewClient", "errorCode:" + errorCode + ">>>>description:" + description + ">>>>failingUrl:" + failingUrl);
+ // 澶勭悊閿欒锛屼緥濡傛樉绀洪敊璇〉闈㈡垨鎻愮ず鐢ㄦ埛
+ // view.loadUrl("file:///android_asset/error.html");
+ }
+
+ @Override
+ public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
+ super.onReceivedHttpError(view, request, errorResponse);
+ // 鎹曡幏HTTP閿欒锛堝404, 500绛夛級
+ int statusCode = errorResponse.getStatusCode();
+ String description = errorResponse.getReasonPhrase();
+ Log.e("setWebViewClient", "statusCode:" + statusCode + ">>>>description:" + description);
+ // 鏍规嵁HTTP鐘舵�佺爜澶勭悊閿欒
+ }
+ });
}
- public void showWaterIntakeDetail(String data){
+ public void showWaterIntakeDetail(String data) {
MyLog.i(data);
binding.bottomLL.setVisibility(View.VISIBLE);
}
-
- public void closeWaterIntakeDetail(){
+ public void closeWaterIntakeDetail() {
binding.bottomLL.setVisibility(View.GONE);
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/js/MyWebViewInterface.java b/app/src/main/java/com/dayu/pipirrapp/js/MyWebViewInterface.java
index b453c5c..56fb79b 100644
--- a/app/src/main/java/com/dayu/pipirrapp/js/MyWebViewInterface.java
+++ b/app/src/main/java/com/dayu/pipirrapp/js/MyWebViewInterface.java
@@ -1,6 +1,5 @@
package com.dayu.pipirrapp.js;
-import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.webkit.JavascriptInterface;
@@ -66,4 +65,22 @@
}
}
+ @JavascriptInterface
+ public void loadMarker(){
+ if (myContext instanceof MapFragment) {
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
+ @Override
+ public void run() {
+ // 鍦ㄤ富绾跨▼涓婃墽琛孶I鎿嶄綔
+ // 鏇存柊鎴栨搷浣淯I鍏冪礌鐨勪唬鐮�
+ myContext.addMarker();
+ }
+ });
+ }
+ }
+
+
+
+
+
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java b/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
index 186cf43..58a4dd0 100644
--- a/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
+++ b/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
@@ -1,38 +1,27 @@
package com.dayu.pipirrapp.net;
import android.content.Context;
-
+import android.util.Log;
import com.dayu.pipirrapp.bean.WeatherResponse;
import com.dayu.pipirrapp.net.subscribers.BaseProgressSubscriber;
import com.dayu.pipirrapp.net.subscribers.ProgressSubscriber;
import com.dayu.pipirrapp.net.subscribers.SubscriberListener;
+import com.dayu.pipirrapp.utils.MapJpgUtils;
import com.dayu.pipirrapp.utils.MyJsonParser;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
-import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
-import io.reactivex.rxjava3.core.Observer;
-import io.reactivex.rxjava3.disposables.Disposable;
+import io.reactivex.rxjava3.disposables.CompositeDisposable;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.schedulers.Schedulers;
-import okhttp3.MediaType;
-import okhttp3.MultipartBody;
-import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
-import retrofit2.Response;
/**
@@ -43,11 +32,14 @@
*/
public class ApiManager {
+ static String TAG = "ApiManager";
+
static ApiManager apiManager;
//鏂囦欢涓婁紶澶辫触閲嶅娆℃暟
int uplodFilerepeatSize = 3;
ApiService apiService;
+ private CompositeDisposable compositeDisposable = new CompositeDisposable(); // 绠$悊璁㈤槄浜嬩欢
/**
* 鍒濆鍖栭�氫俊妗嗘灦
@@ -60,6 +52,7 @@
public ApiManager() {
apiService = RetrofitClient.getInstance().getApiService();
+
}
public static ApiManager getInstance() {
@@ -157,14 +150,14 @@
}
-
/**
- * 鑾峰彇澶╂皵
- * @param data 缁忕含搴︼紙鏍煎紡鏄� 绾害:缁忓害锛岃嫳鏂囧啋鍙峰垎闅旓級
+ * 鑾峰彇澶╂皵
+ *
+ * @param data 缁忕含搴︼紙鏍煎紡鏄� 绾害:缁忓害锛岃嫳鏂囧啋鍙峰垎闅旓級
* @param callback
* @param <T>
*/
- public <T> void requestWeather(String data,Callback<WeatherResponse> callback) {
+ public <T> void requestWeather(String data, Callback<WeatherResponse> callback) {
Map<String, Object> params = new HashMap<>();
params.put("key", "S6Tq4pvOakMuWRrg0");
params.put("location", data);
@@ -176,4 +169,39 @@
}
+ public void donwLoadTile(Context context, String urlPath) {
+ Observable<ResponseBody> observable;
+ observable = apiService.downloadTile(urlPath);
+
+
+ compositeDisposable.add(
+ observable
+ .subscribeOn(Schedulers.io()) // 缃戠粶璇锋眰鍦� I/O 绾跨▼涓繘琛�
+ .observeOn(Schedulers.io()) // 鍥炶皟澶勭悊涔熷湪 I/O 绾跨▼
+ .subscribe(
+ responseBody -> {
+ boolean success = false;
+ if (!MapJpgUtils.getInsatance(context).isHasFiles(urlPath)) {
+ success = MapJpgUtils.getInsatance(context).saveTileToCache(urlPath, responseBody);
+ }
+ if (success) {
+ Log.d(TAG, "Download success for tile: " + urlPath);
+ } else {
+ Log.e(TAG, "Failed to save tile to disk: " + urlPath);
+ }
+ },
+ throwable -> Log.e(TAG, "Download failed for tile: " + urlPath)
+ )
+ );
+
+
+ }
+
+ // 鍋滄绾跨▼姹狅紝閲婃斁璧勬簮
+ public void clearDisposables() {
+ if (!compositeDisposable.isDisposed()) {
+ compositeDisposable.dispose();
+ }
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java b/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java
index 5c29ff7..c725a0a 100644
--- a/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java
+++ b/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java
@@ -1,7 +1,6 @@
package com.dayu.pipirrapp.net;
-
import com.dayu.pipirrapp.bean.WeatherResponse;
import java.util.Map;
@@ -58,4 +57,8 @@
@POST(Constants.BASE_URL + "file/upload")
Call<BaseResponse> uploadFile(@Part("description") RequestBody description, @Part MultipartBody.Part file);
+
+ @GET("{url}}")
+ Observable<ResponseBody> downloadTile(@Path("url") String url);
+
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/service/MyCommonService.java b/app/src/main/java/com/dayu/pipirrapp/service/MyCommonService.java
index 46f6593..35b0fe4 100644
--- a/app/src/main/java/com/dayu/pipirrapp/service/MyCommonService.java
+++ b/app/src/main/java/com/dayu/pipirrapp/service/MyCommonService.java
@@ -1,6 +1,6 @@
package com.dayu.pipirrapp.service;
-import cn.jpush.android.service.JCommonService;
+//import cn.jpush.android.service.JCommonService;
/**
* author: zuo
@@ -8,5 +8,5 @@
* Time: 11:51
* 澶囨敞锛�
*/
-public class MyCommonService extends JCommonService {
-}
+//public class MyCommonService extends JCommonService {
+//}
diff --git a/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java b/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java
index 7eb9e0e..f3c75e0 100644
--- a/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java
+++ b/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java
@@ -87,7 +87,7 @@
super.onCreate();
createNativeLocation();
- createBDLocation();
+// createBDLocation();
}
@@ -252,10 +252,10 @@
if (locationManager != null) {
locationManager.removeUpdates(listener);
}
- if (mBDLocationClient != null) {
- mBDLocationClient.stop();
- mBDLocationClient.unRegisterLocationListener(mBDLocationListener);
- }
+// if (mBDLocationClient != null) {
+// mBDLocationClient.stop();
+// mBDLocationClient.unRegisterLocationListener(mBDLocationListener);
+// }
} catch (Exception e) {
CrashReport.postCatchedException(e);
diff --git a/app/src/main/java/com/dayu/pipirrapp/service/PushService.java b/app/src/main/java/com/dayu/pipirrapp/service/PushService.java
index 0163877..b6359dd 100644
--- a/app/src/main/java/com/dayu/pipirrapp/service/PushService.java
+++ b/app/src/main/java/com/dayu/pipirrapp/service/PushService.java
@@ -1,12 +1,6 @@
package com.dayu.pipirrapp.service;
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-
-import androidx.annotation.Nullable;
-
-import cn.jpush.android.service.JPushMessageService;
+//import cn.jpush.android.service.JPushMessageService;
/**
* author: zuo
@@ -14,6 +8,6 @@
* Time: 10:29
* 澶囨敞锛氭帹閫佺殑鏈嶅姟
*/
-public class PushService extends JPushMessageService {
-
-}
+//public class PushService extends JPushMessageService {
+//
+//}
diff --git a/app/src/main/java/com/dayu/pipirrapp/tool/RocketMQConsumer.java b/app/src/main/java/com/dayu/pipirrapp/tool/RocketMQConsumer.java
new file mode 100644
index 0000000..2ab6fac
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/tool/RocketMQConsumer.java
@@ -0,0 +1,62 @@
+package com.dayu.pipirrapp.tool;
+
+import android.util.Log;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+/**
+ * author: zuo
+ * Date: 2024-09-03
+ * Time: 13:51
+ * 澶囨敞锛歁Q娑堟伅闃熷垪妯″潡
+ */
+public class RocketMQConsumer {
+
+ private DefaultMQPushConsumer consumer;
+
+ public void start() {
+ try {
+ // 鍒涘缓涓�涓秷璐硅�呭疄渚�
+ consumer = new DefaultMQPushConsumer("YourConsumerGroup");
+
+ // 璁剧疆NameServer鍦板潃
+ consumer.setNamesrvAddr("YourNameServerAddress");
+
+ // 璁㈤槄涓�涓垨澶氫釜Topic
+ consumer.subscribe("YourTopic", "*");
+
+ // 娉ㄥ唽娑堟伅鐩戝惉鍣�
+ consumer.registerMessageListener(new MessageListenerConcurrently() {
+ @Override
+ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
+ for (MessageExt msg : msgs) {
+ // 澶勭悊娑堟伅
+ Log.d("RocketMQ", "Receive message: " + new String(msg.getBody()));
+ // 杩欓噷鍙互瑙﹀彂鏈湴閫氱煡鎴栬�呮洿鏂癠I
+ }
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+
+ // 鍚姩娑堣垂鑰�
+ consumer.start();
+
+ } catch (MQClientException e) {
+ e.printStackTrace();
+ Log.e("RocketMQ", "Consumer failed to start: " + e.getMessage());
+ }
+ }
+
+ public void stop() {
+ if (consumer != null) {
+ consumer.shutdown();
+ }
+ }
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/utils/MapJpgUtils.java b/app/src/main/java/com/dayu/pipirrapp/utils/MapJpgUtils.java
new file mode 100644
index 0000000..80c5055
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/utils/MapJpgUtils.java
@@ -0,0 +1,150 @@
+package com.dayu.pipirrapp.utils;
+
+import android.content.Context;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import okhttp3.ResponseBody;
+
+/**
+ * author: zuo
+ * Date: 2024-09-06
+ * Time: 17:59
+ * 澶囨敞锛� 瀹屾垚鍦板浘缂撳瓨绛栫暐
+ */
+public class MapJpgUtils {
+ static MapJpgUtils mapJpgUtils;
+ Context context;
+
+ public static MapJpgUtils getInsatance(Context context) {
+ if (mapJpgUtils == null) {
+ mapJpgUtils = new MapJpgUtils();
+ }
+ mapJpgUtils.context = context;
+ return mapJpgUtils;
+ }
+
+
+ // 鑾峰彇缂撳瓨鐡︾墖鏂囦欢
+ public File getCachedTile(String url) {
+ String fileName = hashUrl(url); // URL 杞崲涓哄敮涓�鐨勫搱甯屽�兼垨鏂囦欢鍚�
+ File cacheDir = new File(context.getCacheDir(), "mapCache"); // 鐡︾墖瀛樺偍鐩綍
+ if (!cacheDir.exists()) {
+ cacheDir.mkdirs();
+ }
+ return new File(cacheDir, fileName);
+ }
+
+ // 浣跨敤 MD5 鍝堝笇 URL 浣滀负鏂囦欢鍚�
+ private String hashUrl(String url) {
+ try {
+ MessageDigest digest = MessageDigest.getInstance("MD5");
+ digest.update(url.getBytes());
+ byte[] hashBytes = digest.digest();
+ StringBuilder sb = new StringBuilder();
+ for (byte b : hashBytes) {
+ sb.append(String.format("%02x", b));
+ }
+ return sb.toString();
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ return String.valueOf(url.hashCode());
+ }
+ }
+
+ // 淇濆瓨鐡︾墖鍒扮紦瀛�
+ public boolean saveTileToCache(String url, ResponseBody body) {
+
+ try {
+ File tileFile = new File(context.getCacheDir() + File.separator + hashUrl(url) + ".png");
+
+ if (!tileFile.getParentFile().exists()) {
+ tileFile.getParentFile().mkdirs();
+ }
+
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+
+ try {
+ byte[] fileReader = new byte[4096];
+ long fileSizeDownloaded = 0;
+
+ inputStream = body.byteStream();
+ outputStream = new FileOutputStream(tileFile);
+
+ while (true) {
+ int read = inputStream.read(fileReader);
+
+ if (read == -1) {
+ break;
+ }
+ outputStream.write(fileReader, 0, read);
+ fileSizeDownloaded += read;
+ }
+
+ outputStream.flush();
+ // 淇濆瓨瀹屾垚鍚庯紝璁板綍缂撳瓨鍒涘缓鏃堕棿
+ tileFile.setLastModified(System.currentTimeMillis());
+ return true;
+ } catch (Exception e) {
+ return false;
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * 鍒ゆ柇鏂囦欢鏄惁瀛樺湪
+ *
+ * @param url
+ * @return
+ */
+ public boolean isHasFiles(String url) {
+ String fileName = hashUrl(url); // URL 杞崲涓哄敮涓�鐨勫搱甯屽�兼垨鏂囦欢鍚�
+ File cacheDir = new File(context.getCacheDir(), "mapCache"); // 鐡︾墖瀛樺偍鐩綍
+ if (!cacheDir.exists()) {
+ cacheDir.mkdirs();
+ }
+ if (new File(cacheDir, fileName).exists()) {
+ return true;
+ }
+ return false;
+ }
+
+ // 鍒ゆ柇缂撳瓨鏄惁杩囨湡
+ public boolean isCacheExpired(File cachedFile) {
+ final long cacheValidity = 24 * 60 * 60 * 1000; // 1 澶╂湁鏁堟湡
+ long lastModified = cachedFile.lastModified();
+ return (System.currentTimeMillis() - lastModified) > cacheValidity;
+ }
+
+ // 娓呯悊鏃х紦瀛�
+ private void clearOldCacheFiles() {
+ File cacheDir = new File(context.getCacheDir(), "mapCache");
+ if (cacheDir.exists()) {
+ File[] files = cacheDir.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ // 娓呯悊瓒呰繃 7 澶╃殑缂撳瓨鏂囦欢
+ if (System.currentTimeMillis() - file.lastModified() > 7 * 24 * 60 * 60 * 1000) {
+ file.delete();
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/utils/WebViewUtils.java b/app/src/main/java/com/dayu/pipirrapp/utils/WebViewUtils.java
new file mode 100644
index 0000000..d7d04bb
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/utils/WebViewUtils.java
@@ -0,0 +1,85 @@
+package com.dayu.pipirrapp.utils;
+
+import android.util.Log;
+import android.webkit.ConsoleMessage;
+import android.webkit.JsResult;
+import android.webkit.WebChromeClient;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+
+/**
+ * author: zuo
+ * Date: 2024-09-03
+ * Time: 15:43
+ * 澶囨敞锛�
+ */
+public class WebViewUtils {
+
+
+ public static WebView initWebView(WebView mWebView) {
+
+// getActivity().getWindow().setFlags(
+// WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
+// WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
+ // WebView 閰嶇疆
+ WebSettings webSettings = mWebView.getSettings();
+ // 鐢熷懡鍛ㄦ湡
+// 鍓嶈繘鍚庨��
+ if (mWebView.canGoBack()) {
+ mWebView.goBack();
+ }
+ if (mWebView.canGoForward()) {
+ mWebView.goForward();
+ }
+
+ // 缂撳瓨鐩稿叧
+ mWebView.clearCache(false); // 娓呴櫎缂撳瓨
+// mWebView.clearHistory(); // 娓呴櫎鍘嗗彶
+// mWebView.clearFormData(); // 娓呴櫎琛ㄥ崟鏁版嵁
+ webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);// 璁剧疆缂撳瓨妯″紡
+ webSettings.setDatabaseEnabled(true);
+ webSettings.setDomStorageEnabled(true);//寮�鍚疍OM缂撳瓨锛屽叧闂殑璇滺5鑷韩鐨勪竴浜涙搷浣滄槸鏃犳晥鐨�
+// 缂撳瓨妯″紡
+// LOAD_DEFAULT: 榛樿锛屾牴鎹� cache-control 鍐冲畾鏄惁浠庣綉缁滀笂鍙栨暟鎹�
+// LOAD_NORMAL: API level 17 涓凡缁忓簾寮�, 浠嶢PI level 11寮�濮嬩綔鐢ㄥ悓 LOAD_DEFAULT 妯″紡
+// LOAD_CACHE_ELSE_NETWORK: 鍙鏈湴鏈夛紝鏃犺鏄惁杩囨湡锛屾垨鑰� no-cache锛岄兘浣跨敤缂撳瓨涓殑鏁版嵁
+// LOAD_NO_CACHE: 涓嶄娇鐢ㄧ紦瀛橈紝鍙粠缃戠粶鑾峰彇鏁版嵁
+// LOAD_CACHE_ONLY: 涓嶄娇鐢ㄧ綉缁滐紝鍙鍙栨湰鍦扮紦瀛樻暟鎹�
+ // js 鐩稿叧
+ webSettings.setJavaScriptEnabled(true); // 鏀寔 js銆傚鏋滅鍒板悗鍙版棤娉曢噴鏀� js 瀵艰嚧鑰楃數锛屽簲鍦� onStop 鍜� onResume 閲屽垎鍒鎴� false 鍜� true
+ // mWebView.addJavascriptInterface(new WebAppInterface(this), "android"); // js 鎺ュ彛
+
+ // webSettings.setPluginsEnabled(true); // 鏀寔鎻掍欢
+ // 璁剧疆鑷�傚簲灞忓箷锛屼袱鑰呭悎鐢�
+ webSettings.setUseWideViewPort(true); // 灏嗗浘鐗囪皟鏁村埌閫傚悎 WebView 鐨勫ぇ灏�
+ webSettings.setLoadWithOverviewMode(true); // 缂╂斁鑷冲睆骞曠殑澶у皬
+ // 缂╂斁鎿嶄綔
+ webSettings.setSupportZoom(true); // 鏀寔缂╂斁锛岄粯璁や负 true
+ webSettings.setBuiltInZoomControls(true); // 璁剧疆鍐呯疆鐨勭缉鏀炬帶浠讹紝鑻ヤ负 false锛屽垯璇� WebView 涓嶅彲缂╂斁
+ webSettings.setDisplayZoomControls(false); // 闅愯棌鍘熺敓鐨勭缉鏀炬帶浠�
+ webSettings.setLoadsImagesAutomatically(true);//棰勫姞杞�
+ //娣诲姞璁块棶鏉冮檺
+ webSettings.setAllowFileAccess(true);
+ webSettings.setAllowFileAccessFromFileURLs(true);
+ webSettings.setAllowUniversalAccessFromFileURLs(true);
+
+ //webView寮笿sAlert
+ mWebView.setWebChromeClient(new WebChromeClient() {
+ @Override
+ public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
+ return super.onJsAlert(view, url, message, result);
+ }
+ @Override
+ public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
+ Log.d("WebView", consoleMessage.message()
+ + " -- From line "
+ + consoleMessage.lineNumber() + " of "
+ + consoleMessage.sourceId());
+ return true;
+ }
+ });
+
+
+ return mWebView;
+ }
+}
diff --git a/app/src/main/res/drawable/bottom_circle_bg.xml b/app/src/main/res/drawable/bottom_circle_bg.xml
new file mode 100644
index 0000000..5ee26e0
--- /dev/null
+++ b/app/src/main/res/drawable/bottom_circle_bg.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <solid android:color="@color/bottom_color" /> <!-- 鎸夐挳鐨勮儗鏅壊 -->
+ <corners android:radius="90dp" /> <!-- 璁╂寜閽殑鍥涗釜瑙掑彉鎴愬渾褰� -->
+ <size android:width="200dp" android:height="100dp" /> <!-- 璁剧疆鎸夐挳鐨勫楂� -->
+</shape>
\ No newline at end of file
diff --git a/app/src/main/res/drawable/bottom_map_black.xml b/app/src/main/res/drawable/bottom_map_black.xml
new file mode 100644
index 0000000..2bf984e
--- /dev/null
+++ b/app/src/main/res/drawable/bottom_map_black.xml
@@ -0,0 +1,28 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <path
+ android:pathData="M24,44C35.046,44 44,35.046 44,24C44,12.954 35.046,4 24,4C12.954,4 4,12.954 4,24C4,35.046 12.954,44 24,44Z"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"/>
+ <path
+ android:pathData="M4,20.84C7.015,19.417 9.245,19.219 10.689,20.245C12.857,21.786 13.128,28.064 18.058,25.063C22.987,22.063 15.947,20.84 17.475,16.494C19.003,12.147 24.008,15.524 24.506,10.763C24.837,7.589 21.041,6.374 13.116,7.119"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"/>
+ <path
+ android:pathData="M36,8C30.286,12.989 28.29,16.001 30.013,17.037C32.597,18.592 33.693,16.403 36.847,17.037C40,17.671 39.317,21.946 37.659,21.946C36,21.946 27.41,20.852 27.843,25.865C28.275,30.878 33.442,31.62 33.442,34.421C33.442,36.288 32.299,39.146 30.013,42.994"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M6.104,32.926C7.016,32.529 7.701,32.237 8.16,32.052C12.007,30.498 14.862,30.131 16.724,30.953C20.016,32.406 18.75,35.34 19.782,36.421C20.813,37.502 23.388,37.188 23.388,39.244C23.388,40.615 22.927,42.164 22.007,43.89"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"
+ android:strokeLineCap="round"/>
+</vector>
diff --git a/app/src/main/res/drawable/bottom_map_white.xml b/app/src/main/res/drawable/bottom_map_white.xml
new file mode 100644
index 0000000..e589b3b
--- /dev/null
+++ b/app/src/main/res/drawable/bottom_map_white.xml
@@ -0,0 +1,28 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M24,44C35.046,44 44,35.046 44,24C44,12.954 35.046,4 24,4C12.954,4 4,12.954 4,24C4,35.046 12.954,44 24,44Z"
+ android:strokeWidth="4"
+ android:strokeColor="#fff" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M4,20.84C7.015,19.417 9.245,19.219 10.689,20.245C12.857,21.786 13.128,28.064 18.058,25.063C22.987,22.063 15.947,20.84 17.475,16.494C19.003,12.147 24.008,15.524 24.506,10.763C24.837,7.589 21.041,6.374 13.116,7.119"
+ android:strokeWidth="4"
+ android:strokeColor="#fff" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M36,8C30.286,12.989 28.29,16.001 30.013,17.037C32.597,18.592 33.693,16.403 36.847,17.037C40,17.671 39.317,21.946 37.659,21.946C36,21.946 27.41,20.852 27.843,25.865C28.275,30.878 33.442,31.62 33.442,34.421C33.442,36.288 32.299,39.146 30.013,42.994"
+ android:strokeWidth="4"
+ android:strokeColor="#fff"
+ android:strokeLineCap="round" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M6.104,32.926C7.016,32.529 7.701,32.237 8.16,32.052C12.007,30.498 14.862,30.131 16.724,30.953C20.016,32.406 18.75,35.34 19.782,36.421C20.813,37.502 23.388,37.188 23.388,39.244C23.388,40.615 22.927,42.164 22.007,43.89"
+ android:strokeWidth="4"
+ android:strokeColor="#fff"
+ android:strokeLineCap="round" />
+</vector>
diff --git a/app/src/main/res/drawable/bottom_my_black.xml b/app/src/main/res/drawable/bottom_my_black.xml
new file mode 100644
index 0000000..ea809b9
--- /dev/null
+++ b/app/src/main/res/drawable/bottom_my_black.xml
@@ -0,0 +1,27 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <path
+ android:pathData="M24,44C35.046,44 44,35.046 44,24C44,12.954 35.046,4 24,4C12.954,4 4,12.954 4,24C4,35.046 12.954,44 24,44Z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#333"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M24,23C26.761,23 29,20.761 29,18C29,15.239 26.761,13 24,13C21.239,13 19,15.239 19,18C19,20.761 21.239,23 24,23Z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"/>
+ <path
+ android:pathData="M10.022,38.332C10.366,33.121 14.702,29 20,29H28C33.291,29 37.623,33.11 37.977,38.311"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"
+ android:strokeLineCap="round"/>
+</vector>
diff --git a/app/src/main/res/drawable/bottom_my_white.xml b/app/src/main/res/drawable/bottom_my_white.xml
new file mode 100644
index 0000000..139782e
--- /dev/null
+++ b/app/src/main/res/drawable/bottom_my_white.xml
@@ -0,0 +1,27 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <path
+ android:pathData="M24,44C35.046,44 44,35.046 44,24C44,12.954 35.046,4 24,4C12.954,4 4,12.954 4,24C4,35.046 12.954,44 24,44Z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#fff"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M24,23C26.761,23 29,20.761 29,18C29,15.239 26.761,13 24,13C21.239,13 19,15.239 19,18C19,20.761 21.239,23 24,23Z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#fff"/>
+ <path
+ android:pathData="M10.022,38.332C10.366,33.121 14.702,29 20,29H28C33.291,29 37.623,33.11 37.977,38.311"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#fff"
+ android:strokeLineCap="round"/>
+</vector>
diff --git a/app/src/main/res/drawable/bottom_order_black.xml b/app/src/main/res/drawable/bottom_order_black.xml
new file mode 100644
index 0000000..049673d
--- /dev/null
+++ b/app/src/main/res/drawable/bottom_order_black.xml
@@ -0,0 +1,26 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <path
+ android:pathData="M33.05,7H38C39.105,7 40,7.895 40,9V42C40,43.105 39.105,44 38,44H10C8.895,44 8,43.105 8,42L8,9C8,7.895 8.895,7 10,7H16H17V10H31V7H33.05Z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"/>
+ <path
+ android:pathData="M17,4h14v6h-14z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M27,19L19,27.001H29.004L21,35.002"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#333"
+ android:strokeLineCap="round"/>
+</vector>
diff --git a/app/src/main/res/drawable/bottom_order_white.xml b/app/src/main/res/drawable/bottom_order_white.xml
new file mode 100644
index 0000000..339b3b4
--- /dev/null
+++ b/app/src/main/res/drawable/bottom_order_white.xml
@@ -0,0 +1,26 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <path
+ android:pathData="M33.05,7H38C39.105,7 40,7.895 40,9V42C40,43.105 39.105,44 38,44H10C8.895,44 8,43.105 8,42L8,9C8,7.895 8.895,7 10,7H16H17V10H31V7H33.05Z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#ffffff"/>
+ <path
+ android:pathData="M17,4h14v6h-14z"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#fff"
+ android:strokeLineCap="round"/>
+ <path
+ android:pathData="M27,19L19,27.001H29.004L21,35.002"
+ android:strokeLineJoin="round"
+ android:strokeWidth="4"
+ android:fillColor="#00000000"
+ android:strokeColor="#fff"
+ android:strokeLineCap="round"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_adjust.xml b/app/src/main/res/drawable/vector_adjust.xml
new file mode 100644
index 0000000..85ad1a6
--- /dev/null
+++ b/app/src/main/res/drawable/vector_adjust.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M12,2C6.49,2 2,6.49 2,12s4.49,10 10,10 10,-4.49 10,-10S17.51,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM15,12c0,1.66 -1.34,3 -3,3s-3,-1.34 -3,-3 1.34,-3 3,-3 3,1.34 3,3z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_btn_date.xml b/app/src/main/res/drawable/vector_btn_date.xml
new file mode 100644
index 0000000..af31c7f
--- /dev/null
+++ b/app/src/main/res/drawable/vector_btn_date.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#CCCCCC"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M9,11L7,11v2h2v-2zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM19,4h-1L18,2h-2v2L8,4L8,2L6,2v2L5,4c-1.11,0 -1.99,0.9 -1.99,2L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20L5,9h14v11z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_close.xml b/app/src/main/res/drawable/vector_close.xml
new file mode 100644
index 0000000..fa7591c
--- /dev/null
+++ b/app/src/main/res/drawable/vector_close.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#CCCCCC"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_distance.xml b/app/src/main/res/drawable/vector_distance.xml
new file mode 100644
index 0000000..0ac168a
--- /dev/null
+++ b/app/src/main/res/drawable/vector_distance.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M12,10.9c-0.61,0 -1.1,0.49 -1.1,1.1s0.49,1.1 1.1,1.1c0.61,0 1.1,-0.49 1.1,-1.1s-0.49,-1.1 -1.1,-1.1zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM14.19,14.19L6,18l3.81,-8.19L18,6l-3.81,8.19z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_list.xml b/app/src/main/res/drawable/vector_list.xml
new file mode 100644
index 0000000..c4c6db1
--- /dev/null
+++ b/app/src/main/res/drawable/vector_list.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14,17L7,17v-2h7v2zM17,13L7,13v-2h10v2zM17,9L7,9L7,7h10v2z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_location.xml b/app/src/main/res/drawable/vector_location.xml
new file mode 100644
index 0000000..1fd7c47
--- /dev/null
+++ b/app/src/main/res/drawable/vector_location.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M12,2C8.14,2 5,5.14 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.86 -3.14,-7 -7,-7zM16,10h-3v3h-2v-3L8,10L8,8h3L11,5h2v3h3v2z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_location_clock.xml b/app/src/main/res/drawable/vector_location_clock.xml
new file mode 100644
index 0000000..99cf00b
--- /dev/null
+++ b/app/src/main/res/drawable/vector_location_clock.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#606060"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_loop.xml b/app/src/main/res/drawable/vector_loop.xml
new file mode 100644
index 0000000..f16a1b0
--- /dev/null
+++ b/app/src/main/res/drawable/vector_loop.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M12,4L12,1L8,5l4,4L12,6c3.31,0 6,2.69 6,6 0,1.01 -0.25,1.97 -0.7,2.8l1.46,1.46C19.54,15.03 20,13.57 20,12c0,-4.42 -3.58,-8 -8,-8zM12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24,7.74C4.46,8.97 4,10.43 4,12c0,4.42 3.58,8 8,8v3l4,-4 -4,-4v3z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_photo_camera.xml b/app/src/main/res/drawable/vector_photo_camera.xml
new file mode 100644
index 0000000..c5a1c4c
--- /dev/null
+++ b/app/src/main/res/drawable/vector_photo_camera.xml
@@ -0,0 +1,6 @@
+<vector android:height="10dp" android:tint="#D4D4D6"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="10dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
+ <path android:fillColor="@android:color/white" android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
+</vector>
diff --git a/app/src/main/res/drawable/vector_timer.xml b/app/src/main/res/drawable/vector_timer.xml
new file mode 100644
index 0000000..1897572
--- /dev/null
+++ b/app/src/main/res/drawable/vector_timer.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M15,1L9,1v2h6L15,1zM11,14h2L13,8h-2v6zM19.03,7.39l1.42,-1.42c-0.43,-0.51 -0.9,-0.99 -1.41,-1.41l-1.42,1.42C16.07,4.74 14.12,4 12,4c-4.97,0 -9,4.03 -9,9s4.02,9 9,9 9,-4.03 9,-9c0,-2.12 -0.74,-4.07 -1.97,-5.61zM12,20c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
+</vector>
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 4f2f815..0bbf29c 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -12,35 +11,128 @@
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_above="@id/tabLayout" />
+ android:layout_above="@id/bottom_navigation" />
- <com.google.android.material.tabs.TabLayout
- android:id="@+id/tabLayout"
+ <LinearLayout
+ android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="70dp"
android:layout_alignParentBottom="true"
- android:background="?attr/colorPrimary"
- app:tabGravity="fill"
- app:tabIndicatorColor="#FFC107"
- app:tabMode="fixed"
- app:tabSelectedTextColor="#FFC107"
- app:tabTextColor="#000000">
+ android:layout_marginTop="-20dp"
+ android:background="#00ffffff"
+ android:gravity="bottom"
+ android:orientation="horizontal">
-<!-- <com.google.android.material.tabs.TabItem-->
-<!-- android:layout_width="match_parent"-->
-<!-- android:layout_height="match_parent"-->
-<!-- android:text="棣栭〉" />-->
+ <LinearLayout
+ android:id="@+id/orderLL"
+ android:layout_width="0dp"
+ android:layout_height="50dp"
+ android:layout_weight="1"
+ android:background="@color/bottom_color"
+ android:gravity="center"
+ android:orientation="vertical">
-<!-- <com.google.android.material.tabs.TabItem-->
-<!-- android:layout_width="match_parent"-->
-<!-- android:layout_height="match_parent"-->
-<!-- android:text="鍦板浘" />-->
+ <ImageView
+ android:id="@+id/orderImg"
+ android:layout_width="wrap_content"
+ android:layout_height="25dp"
+ android:layout_marginTop="8dp"
+ android:src="@drawable/bottom_order_black" />
-<!-- <com.google.android.material.tabs.TabItem-->
-<!-- android:layout_width="match_parent"-->
-<!-- android:layout_height="match_parent"-->
-<!-- android:text="鎴戠殑" />-->
- </com.google.android.material.tabs.TabLayout>
+ <TextView
+ android:id="@+id/orderText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="3dp"
+ android:text="宸ュ崟"
+ android:textSize="12sp" />
+
+ </LinearLayout>
+
+ <FrameLayout
+ android:id="@+id/mapLL"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="bottom"
+ android:orientation="vertical">
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_gravity="bottom"
+ android:background="@color/bottom_color"
+ android:orientation="vertical" />
+
+ <LinearLayout
+ android:layout_width="80dp"
+ android:layout_height="70dp"
+ android:layout_gravity="center"
+ android:background="@drawable/bottom_circle_bg"
+ android:gravity="center"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/mapImg"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_marginTop="8dp"
+ android:src="@drawable/bottom_map_white" />
+
+ <TextView
+ android:id="@+id/mapText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍦板浘"
+ android:textColor="@color/white"
+ android:textSize="15sp" />
+
+ </LinearLayout>
+
+ </FrameLayout>
+
+ <LinearLayout
+ android:id="@+id/myLL"
+ android:layout_width="0dp"
+ android:layout_height="50dp"
+ android:layout_weight="1"
+ android:background="@color/bottom_color"
+ android:gravity="center"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/myImg"
+ android:layout_width="wrap_content"
+ android:layout_height="25dp"
+ android:layout_marginTop="8dp"
+ android:src="@drawable/bottom_my_black" />
+
+ <TextView
+ android:id="@+id/myText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="3dp"
+ android:text="鎴戠殑"
+ android:textSize="12sp" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+
+ <!-- <!– BottomNavigationView 鐢ㄤ簬搴曢儴瀵艰埅 –>-->
+ <!-- <com.google.android.material.bottomnavigation.BottomNavigationView-->
+ <!-- android:id="@+id/bottom_navigation"-->
+ <!-- android:layout_width="match_parent"-->
+ <!-- android:layout_height="wrap_content"-->
+ <!-- android:layout_alignParentBottom="true"-->
+ <!-- android:background="@color/bottom_color"-->
+ <!-- app:menu="@menu/main_bottom_nav_menu"-->
+ <!-- app:itemIconTint="@color/bottom_selector_nav_item"-->
+ <!-- app:itemTextColor="@color/bottom_selector_nav_item"-->
+
+ <!-- />-->
+
</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_map.xml b/app/src/main/res/layout/fragment_map.xml
index 5e3491b..6bb6bf0 100644
--- a/app/src/main/res/layout/fragment_map.xml
+++ b/app/src/main/res/layout/fragment_map.xml
@@ -3,11 +3,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <com.github.lzyzsd.jsbridge.BridgeWebView
- android:id="@+id/webView"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
+<!-- <com.github.lzyzsd.jsbridge.BridgeWebView-->
+<!-- android:id="@+id/webView"-->
+<!-- android:layout_width="match_parent"-->
+<!-- android:layout_height="match_parent" />-->
+ <WebView
+ android:id="@+id/webView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
<TextView
android:id="@+id/flyBtn"
diff --git a/app/src/main/res/layout/top_title.xml b/app/src/main/res/layout/top_title.xml
index 249aca8..f242220 100644
--- a/app/src/main/res/layout/top_title.xml
+++ b/app/src/main/res/layout/top_title.xml
@@ -27,7 +27,6 @@
android:id="@+id/tv_title_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
-
android:layout_centerInParent="true"
android:textColor="@color/white"
android:textSize="@dimen/title_center_text_size" />
diff --git a/app/src/main/res/menu/main_bottom_nav_menu.xml b/app/src/main/res/menu/main_bottom_nav_menu.xml
new file mode 100644
index 0000000..6010c0c
--- /dev/null
+++ b/app/src/main/res/menu/main_bottom_nav_menu.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/navigation_order"
+ android:icon="@drawable/bottom_order_black"
+ android:title="宸ュ崟"/>
+
+ <item
+ android:id="@+id/navigation_map"
+ android:icon="@drawable/bottom_map_black"
+ android:title="鍦板浘"/>
+
+ <item
+ android:id="@+id/navigation_profile"
+ android:icon="@drawable/bottom_my_black"
+ android:title="鎴戠殑"/>
+</menu>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 94b9732..06e2d6c 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -8,4 +8,7 @@
<color name="title_color">#1890FF</color>
<color name="bg_color">#F5F5F5</color>
<color name="grey">#757575</color>
+ <color name="colorSelected">#ffffff</color>
+ <color name="colorUnselected">#000000</color>
+ <color name="bottom_color">#1890FF</color>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 5fe6e86..fbc6431 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -6,4 +6,5 @@
<dimen name="my_item_text_size">17sp</dimen>
<dimen name="common_btn_text_size">20sp</dimen>
<dimen name="title_height">45dp</dimen>
+ <dimen name="title_center_text_size">18sp</dimen>
</resources>
\ No newline at end of file
--
Gitblit v1.8.0