From 8788613dd28f3e7b042f33514ceef1435e257818 Mon Sep 17 00:00:00 2001 From: yezhiqiu <983577727@qq.com> Date: Tue, 3 Feb 2026 15:26:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E6=AC=A1=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=EF=BC=8C=E6=9C=AA=E5=AE=9A=E5=88=B0=E4=BD=8D=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=AE=A0=E7=89=A9=EF=BC=8C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=94=A8=E6=88=B7=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tracker/ui/common/map/HomeMapCommonV3.kt | 4 +++ .../tracker/ui/fragment/map/MapV3Fragment.kt | 32 +++++++++++++++---- .../abbidot/tracker/vm/GeoCoderViewModel.kt | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt b/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt index 7fe34d4..8aad477 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/common/map/HomeMapCommonV3.kt @@ -190,6 +190,10 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() { } } + fun getUserGoogleLatLng(): LatLng? { + return mHomeMapGoogleMapFragment?.mUserLatLng + } + // fun getAddressShowMarkerInfoWindow(historyDataBean: HistoryDataBean) { // if (null != mHomeMapBaiduMapFragment) { // mHomeMapBaiduMapFragment!!.showMarkerInfoWindow(historyDataBean) diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt index 7087aed..f865ff5 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt @@ -44,6 +44,7 @@ import com.abbidot.tracker.ui.common.map.HomeMapCommonV3 import com.abbidot.tracker.util.Util import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil +import com.abbidot.tracker.vm.CountDownTimerViewModel import com.abbidot.tracker.vm.FencesMapViewModel import com.abbidot.tracker.vm.MapViewModel import com.clj.fastble.BleManager @@ -62,6 +63,7 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i private val mFencesMapViewModel: FencesMapViewModel by viewModels() private val mMapViewModel: MapViewModel by viewModels() + private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels() private lateinit var mLocationManager: LocationManager @@ -166,7 +168,6 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i // (mActivity as FragmentActivity).supportFragmentManager.commit { // add(R.id.fc_home_map_fragment, mFragment) // } - locationPermissionsTip(1) } @@ -240,6 +241,10 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i }, showLoading = false, isRequestErrorTip = false) } + mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) { + mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.text = + getHomeV2Activity()?.getPet()?.petName + } //删除围栏通知 XEventBus.observe(this, EventName.DeleteFences) { updateMapDeviceStatus() @@ -527,16 +532,31 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i //设置循环查询时间间隔 30秒 mMapViewModel.updateMillisInFuture(0.5f) + if (latitude == 0.0 && longitude == 0.0) { + mHomeMapCommon.clearMarker() + isMoveCamera = true + mHomeMapCommon.getUserGoogleLatLng()?.let { + mHomeMapCommon.refreshPetCurrentLocation( + it.latitude, it.longitude, isMoveCamera + ) + } + mCountDownTimerViewModel.startCountDown(30) + mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.setText(R.string.txt_locating) + mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE + } else { +// mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.text = +// getHomeV2Activity()?.getPet()?.petName +// mCountDownTimerViewModel.stopCountDown() + mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera) + isMoveCamera = false + } + mHomeMapCommon.startRefreshUserLocation() + if (isShowFence) { fences?.let { fences -> mFencesMapViewModel.setFencesData(mContext!!, fences, mFragment) } } - - mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera) - mHomeMapCommon.startRefreshUserLocation() - - isMoveCamera = false } } diff --git a/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt b/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt index 6b62cf4..f64d41f 100644 --- a/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt +++ b/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt @@ -56,6 +56,7 @@ class GeoCoderViewModel : ViewModel() { * @param showDetailAddress 是否显示最详细的地址 */ fun getLatLonAddress(latitude: Double, longitude: Double, showDetailAddress: Boolean = true) { + if (latitude == 0.0 && longitude == 0.0) return isShowDetailAddress = showDetailAddress diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 161df8e..1544f22 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1068,5 +1068,6 @@ /day x%s "ABBIDOT APP collects location data,The route and distance between the current location and the device can be calculated." (Renew at $%s per %s day thereafter) + Locating… \ No newline at end of file