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