1.新增一键定位功能

2.g30隐藏直播按钮,g40显示直播按钮
3.map页雷达按钮增加显示蓝牙连接状态
This commit is contained in:
yezhiqiu
2026-03-19 15:36:31 +08:00
parent 13035c6037
commit d495e0571a
20 changed files with 362 additions and 61 deletions

View File

@@ -30,7 +30,7 @@ android {
targetSdkVersion 35 targetSdkVersion 35
versionCode 2110 versionCode 2110
// versionName "2.1.10" // versionName "2.1.10"
versionName "2.1.10-Beta6" versionName "2.1.10-Beta9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -36,9 +36,10 @@ data class MapDeviceBean(
var startTime: String, var startTime: String,
var endTime: String, var endTime: String,
var deviceType: Int, var deviceType: Int,
var canShowBattery: Boolean, var notifyLocationFail: Boolean,
var isCloseBattery: Boolean, var canShowBattery: Boolean,//是否可以显示电池提示布局
var isCloseMsg: Boolean var isCloseBattery: Boolean,//是否关闭电池提示
var isCloseMsg: Boolean //是否关闭消息提示
) : Parcelable { ) : Parcelable {
constructor() : this( constructor() : this(
"", "",
@@ -73,6 +74,7 @@ data class MapDeviceBean(
1, 1,
false, false,
false, false,
false,
false false
) )
} }

View File

@@ -1409,4 +1409,11 @@ interface INetworkService {
@Field("macID") macID: String, @Field("macID") macID: String,
@Field("logFileUrl") logFileUrl: String @Field("logFileUrl") logFileUrl: String
): BaseResponse<String> ): BaseResponse<String>
/**
* 设备一键定位
*/
@FormUrlEncoded
@POST("map/setupRefreshLocation")
suspend fun setupRefreshLocation(@Field("deviceId") deviceId: String): BaseResponse<String>
} }

View File

@@ -739,6 +739,13 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
service.getMapDeviceStatus(deviceId) service.getMapDeviceStatus(deviceId)
} }
/**
* 设备一键定位
*/
suspend fun setupRefreshLocation(deviceId: String) = getResult {
service.setupRefreshLocation(deviceId)
}
/** /**
* 打开关闭直播 * 打开关闭直播
*/ */

View File

@@ -11,6 +11,7 @@ import android.text.TextUtils
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.view.get import androidx.core.view.get
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@@ -106,6 +107,9 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
//是否检查套餐过期 //是否检查套餐过期
private var isCheckPackageExpire = true private var isCheckPackageExpire = true
//是否一键定位
var isNotifyRefreshLocation = false
private val mFragments = mutableListOf<Fragment>( private val mFragments = mutableListOf<Fragment>(
ActivityV2Fragment.newInstance(this), ActivityV2Fragment.newInstance(this),
RouteV2Fragment.newInstance(this), RouteV2Fragment.newInstance(this),
@@ -613,6 +617,33 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
} }
/**
* 检测一键定位状态
*/
fun checkNotifyRefreshLocation(textView: AppCompatTextView) {
textView.let {
if (isNotifyRefreshLocation) {
it.setText(R.string.txt_locating)
it.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
} else {
getPet(false)?.let { pet ->
it.text = pet.petName
it.setCompoundDrawablesWithIntrinsicBounds(
0, 0, R.drawable.icon_gray_down_arrow, 0
)
}
}
}
}
fun refreshLocationBtnState() {
when (mViewBinding.homeV2ViewPager2.currentItem) {
0 -> (mFragments[0] as ActivityV2Fragment).checkNotifyLocationState()
1 -> (mFragments[1] as RouteV2Fragment).checkNotifyLocationState()
3 -> (mFragments[3] as PetV2Fragment).checkNotifyLocationState()
}
}
override fun onCurrentClick() { override fun onCurrentClick() {
mChangePetDialog?.dismiss() mChangePetDialog?.dismiss()
} }

View File

@@ -183,6 +183,10 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() {
mHomeMapGoogleMapFragment?.greenRippleCircleAnim() mHomeMapGoogleMapFragment?.greenRippleCircleAnim()
} }
fun clearRippleCircleAnim() {
mHomeMapGoogleMapFragment?.clearRippleCircleAnim()
}
fun setMarkerInfoViewOffset() { fun setMarkerInfoViewOffset() {
if (null != mHomeMapBaiduMapFragment) { if (null != mHomeMapBaiduMapFragment) {
} else if (null != mHomeMapGoogleMapFragment) { } else if (null != mHomeMapGoogleMapFragment) {

View File

@@ -162,6 +162,13 @@ class ActivityV2Fragment :
//其他页面是否选择了宠物 //其他页面是否选择了宠物
showPetNameAndHead(it.mSelectPetPosition) showPetNameAndHead(it.mSelectPetPosition)
} }
checkNotifyLocationState()
}
}
fun checkNotifyLocationState() {
getHomeV2Activity()?.apply {
checkNotifyRefreshLocation(mViewBinding.ilHomeActivityTopPet.homeDataPetNameSmall)
} }
} }
@@ -319,7 +326,11 @@ class ActivityV2Fragment :
btnHomeMoreSleep -> goActivityNeedPet(MoreSleepActivity::class.java) btnHomeMoreSleep -> goActivityNeedPet(MoreSleepActivity::class.java)
ilHomeActivityTopPet.homeDataPetNameSmall, ilHomeActivityTopPet.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog() ilHomeActivityTopPet.homeDataPetNameSmall, ilHomeActivityTopPet.homeDataPetHeadSmall.root -> {
getHomeV2Activity()?.let {
if (!it.isNotifyRefreshLocation) it.selectPetDialog()
}
}
} }
} }

View File

@@ -154,6 +154,7 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
} }
} }
private fun initState() { private fun initState() {
mViewBinding.miHomeRouteAddressView.visibility = View.GONE mViewBinding.miHomeRouteAddressView.visibility = View.GONE
mHistoryDataMapCommon.clearAllMarker() mHistoryDataMapCommon.clearAllMarker()
@@ -228,6 +229,13 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
if (!isSelectCustomDate) get24HourTime() if (!isSelectCustomDate) get24HourTime()
showPetNameAndHead(mSelectPetPosition) showPetNameAndHead(mSelectPetPosition)
} }
checkNotifyLocationState()
}
}
fun checkNotifyLocationState() {
getHomeV2Activity()?.apply {
checkNotifyRefreshLocation(mViewBinding.ilHomeRoutePetHead.homeDataPetNameSmall)
} }
} }
@@ -419,9 +427,11 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
// mContext, NotificationV2Activity::class.java // mContext, NotificationV2Activity::class.java
// ) // )
// ) // )
ilHomeRoutePetHead.homeDataPetNameSmall, ilHomeRoutePetHead.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog( ilHomeRoutePetHead.homeDataPetNameSmall, ilHomeRoutePetHead.homeDataPetHeadSmall.root -> {
false getHomeV2Activity()?.let {
) if (!it.isNotifyRefreshLocation) it.selectPetDialog(false)
}
}
llHomeRouteCalendarFrom -> { llHomeRouteCalendarFrom -> {
getHomeV2Activity()?.getPet()?.let { getHomeV2Activity()?.getPet()?.let {

View File

@@ -1,5 +1,6 @@
package com.abbidot.tracker.ui.fragment.map package com.abbidot.tracker.ui.fragment.map
import android.animation.AnimatorSet
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.res.ColorStateList import android.content.res.ColorStateList
@@ -100,6 +101,10 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
//是否需要gps坐标转火星坐标 //是否需要gps坐标转火星坐标
private var needGpsToGCJ02 = true private var needGpsToGCJ02 = true
private var mAnimatorSet: AnimatorSet? = null
//一键定位开始的时间戳
private var notifyRefreshLocationTimestamp = 0L
companion object { companion object {
@JvmStatic @JvmStatic
@@ -150,6 +155,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
homeMapRefreshBtn, homeMapRefreshBtn,
homeMapBluetoothBtn, homeMapBluetoothBtn,
homeMapLiveBtn, homeMapLiveBtn,
ivHomeMapRefreshLocation,
llHomeMapTopPet.ivTopPetBtnSmall, llHomeMapTopPet.ivTopPetBtnSmall,
llHomeMapTopPet.homeDataPetNameSmall, llHomeMapTopPet.homeDataPetNameSmall,
llHomeMapTopPet.homeDataPetHeadSmall.root, llHomeMapTopPet.homeDataPetHeadSmall.root,
@@ -220,31 +226,31 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
override fun liveDataObserve() { override fun liveDataObserve() {
//获取当前宠物位置和围栏信息 //获取当前宠物位置和围栏信息
mMapViewModel.mMapDeviceLiveData.observe(this) { mMapViewModel.apply {
dealRequestResult(it, object : GetResultCallback { mMapDeviceLiveData.observe(this@MapV3Fragment) {
override fun onResult(any: Any) { dealRequestResult(it, object : GetResultCallback {
val data = it.getOrNull() override fun onResult(any: Any) {
data?.apply { it.getOrNull()?.let { data ->
mMapDeviceBean?.let { m -> dealMapData(data)
data.isCloseMsg = m.isCloseMsg
data.isCloseBattery = m.isCloseBattery
data.canShowBattery = m.canShowBattery
} }
mMapDeviceBean = data
setMapData(data)
mMapViewModel.setDeviceStateAndWarningData(
mContext!!,
getHomeV2Activity()?.getPet(),
data,
mViewBinding.ilHomeMapDeviceMsg.root,
mViewBinding.ilHomeMapDeviceMsg.tvDeviceMsgContent,
mViewBinding.ilHomeMapDeviceMsg.ivDeviceMsgCloseBtn,
mDeviceStateList,
mDeviceStateAdapter
)
} }
} }, showLoading = false, isRequestErrorTip = false)
}, showLoading = false, isRequestErrorTip = false) }
mRefreshLocationLiveData.observe(this@MapV3Fragment) {
dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) {
mMapViewModel.updateMillisInFuture(0.05f)
}
override fun onErrorCode() {
stopRefreshLocation()
}
override fun onRequestError(exceptionCode: String?) {
stopRefreshLocation()
}
})
}
} }
mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) { mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) {
@@ -317,6 +323,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
getHomeV2Activity()?.getPet(false)?.apply { getHomeV2Activity()?.getPet(false)?.apply {
if (trackBle.mac == macID) { if (trackBle.mac == macID) {
if (trackBle.conState == ConState.CONNECTED) { if (trackBle.conState == ConState.CONNECTED) {
mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_online)
mMapDeviceBean?.let { mMapDeviceBean?.let {
//连接上蓝牙,关机不显示 //连接上蓝牙,关机不显示
if (it.powerSwitch == ConstantInt.Type0) { if (it.powerSwitch == ConstantInt.Type0) {
@@ -345,9 +352,11 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
//隐藏蓝牙nearby //隐藏蓝牙nearby
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_offline)
//蓝牙断开就重新获取服务器数据,蓝牙数据上报断开 //蓝牙断开就重新获取服务器数据,蓝牙数据上报断开
updateMapDeviceStatus() updateMapDeviceStatus()
} }
setRefreshLocationBtnState()
} }
} }
} }
@@ -362,6 +371,66 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
// } // }
} }
private fun dealMapData(data: MapDeviceBean) {
mMapDeviceBean?.let { m ->
data.notifyLocationFail = m.notifyLocationFail
data.isCloseMsg = m.isCloseMsg
data.isCloseBattery = m.isCloseBattery
data.canShowBattery = m.canShowBattery
}
mMapDeviceBean = data
getHomeV2Activity()?.apply {
if (isNotifyRefreshLocation) {
if (data.liveFlag == 0) {
stopRefreshLocation()
setMapData(data)
mMapViewModel.setDeviceStateAndWarningData(
mContext,
getPet(),
data,
mViewBinding.ilHomeMapDeviceMsg.root,
mViewBinding.ilHomeMapDeviceMsg.tvDeviceMsgContent,
mViewBinding.ilHomeMapDeviceMsg.ivDeviceMsgCloseBtn,
mDeviceStateList,
mDeviceStateAdapter
)
} else {
//60秒超时
// val isRefreshTimeOut =
// (System.currentTimeMillis() - notifyRefreshLocationTimestamp) / 1000 >= 0
// if (isRefreshTimeOut) {
// stopRefreshLocation()
// mMapDeviceBean!!.notifyLocationFail = true
// mMapDeviceBean!!.isCloseBattery = false
// mMapDeviceBean!!.canShowBattery = true
// mViewBinding.ilHomeMapDeviceBatteryLayout.let {
// mMapViewModel.setMapDeviceBattery(
// mContext,
// mMapDeviceBean!!,
// it.root,
// it.tvDeviceBatteryInfo,
// it.ivDeviceCloseBtn
// )
// }
// }
}
} else {
setMapData(data)
mMapViewModel.setDeviceStateAndWarningData(
mContext,
getPet(),
data,
mViewBinding.ilHomeMapDeviceMsg.root,
mViewBinding.ilHomeMapDeviceMsg.tvDeviceMsgContent,
mViewBinding.ilHomeMapDeviceMsg.ivDeviceMsgCloseBtn,
mDeviceStateList,
mDeviceStateAdapter
)
}
}
}
/** /**
* 更新蓝牙上报的数据 * 更新蓝牙上报的数据
*/ */
@@ -517,8 +586,11 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
//隐藏蓝牙nearby //隐藏蓝牙nearby
mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE mViewBinding.ilHomeMapDeviceMsg.root.visibility = View.GONE
mViewBinding.homeMapLiveBtn.visibility = View.GONE mViewBinding.homeMapLiveBtn.visibility = View.GONE
mViewBinding.ivHomeMapBleConState.setImageResource(R.drawable.icon_map_offline)
mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE mViewBinding.llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE
mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE
isCanLive = false
setRefreshLocationBtnState()
ViewUtil.instance.selectPetDialogShow( ViewUtil.instance.selectPetDialogShow(
mContext, mContext,
@@ -586,6 +658,24 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
} }
private fun setRefreshLocationBtnState() {
getHomeV2Activity()?.apply {
getPet(false)?.let { pet ->
mViewBinding.ivHomeMapRefreshLocation.let {
val tintColor = if (SRBleUtil.instance.isMacConnect(pet.macID) || !isCanLive) {
it.setBackgroundResource(R.drawable.shape_light_yellow_circle_bg)
R.color.grey_color
} else {
it.setBackgroundResource(R.drawable.shape_yellow_circle_bg)
R.color.select_color3
}
it.imageTintList =
ColorStateList.valueOf(ContextCompat.getColor(mContext, tintColor))
}
}
}
}
private fun setLiveBtnState(canLive: Boolean) { private fun setLiveBtnState(canLive: Boolean) {
mViewBinding.apply { mViewBinding.apply {
ViewUtil.instance.viewShow(homeMapLiveBtn) ViewUtil.instance.viewShow(homeMapLiveBtn)
@@ -619,18 +709,21 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
private fun setMapDeviceBean(mapDeviceBean: MapDeviceBean) { private fun setMapDeviceBean(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply { mapDeviceBean.apply {
val share = MMKVUtil.getInt(MMKVKey.Shared) val share = MMKVUtil.getInt(MMKVKey.Shared)
mViewBinding.homeMapLiveBtn.visibility = if (share != ConstantInt.NoShare) { //分钟后无上报、没有lte信号或在wifi中隐藏直播按钮
View.GONE isCanLive =
} else { !(Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1)
if (liveFlag == ConstantInt.Type1) View.GONE mViewBinding.homeMapLiveBtn.visibility =
else { if (share != ConstantInt.NoShare || deviceType == ConstantInt.Type1) {
//分钟后无上报、没有lte信号或在wifi中隐藏直播按钮 View.GONE
isCanLive = } else {
!(Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || powerSwitch == ConstantInt.Type3 || inWifiZone == ConstantInt.Type1) if (liveFlag == ConstantInt.Type1) View.GONE
setLiveBtnState(isCanLive) else {
View.VISIBLE setLiveBtnState(isCanLive)
View.VISIBLE
}
} }
}
setRefreshLocationBtnState()
mViewBinding.ilHomeMapDeviceBatteryLayout.let { mViewBinding.ilHomeMapDeviceBatteryLayout.let {
mMapViewModel.setMapDeviceBattery( mMapViewModel.setMapDeviceBattery(
@@ -720,6 +813,69 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
} }
/**
* 开始通知一键定位
*/
private fun notifyRefreshLocation() {
getHomeV2Activity()?.apply {
getPet()?.let { pet ->
if (SRBleUtil.instance.isMacConnect(pet.macID)) {
showToast(R.string.txt_pet_close, gravity = Gravity.CENTER)
} else if (!isCanLive) {
showToast(R.string.txt_locate_works, gravity = Gravity.CENTER)
} else if (!isNotifyRefreshLocation) {
isNotifyRefreshLocation = true
isMoveCamera = true
mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.let {
it.setText(R.string.txt_locating)
it.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
}
notifyRefreshLocationTimestamp = System.currentTimeMillis()
mHomeMapCommon.greenRippleCircleAnim()
mViewBinding.ivHomeMapRefreshLocation.let {
it.isEnabled = false
it.imageTintList = ColorStateList.valueOf(
ContextCompat.getColor(
mContext, R.color.grey_color
)
)
mAnimatorSet = ViewUtil.instance.viewRotationAnimator(it, true)
}
mMapViewModel.stopGetData()
mMapViewModel.setupRefreshLocation(pet.deviceId)
}
}
}
}
private fun stopRefreshLocation() {
getHomeV2Activity()?.apply {
if (isNotifyRefreshLocation) {
isNotifyRefreshLocation = false
mHomeMapCommon.clearRippleCircleAnim()
mViewBinding.ivHomeMapRefreshLocation.let {
it.isEnabled = true
it.imageTintList = ColorStateList.valueOf(
ContextCompat.getColor(
mContext, R.color.select_color3
)
)
mAnimatorSet?.cancel()
}
getPet(false)?.let { pet ->
mMapViewModel.updateMillisInFuture(0.35f)
mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.let {
it.text = pet.petName
it.setCompoundDrawablesWithIntrinsicBounds(
0, 0, R.drawable.icon_gray_down_arrow, 0
)
}
}
refreshLocationBtnState()
}
}
}
override fun onClick(v: View?) { override fun onClick(v: View?) {
if (isLimitClick()) return if (isLimitClick()) return
mViewBinding.apply { mViewBinding.apply {
@@ -753,9 +909,17 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
goLive(true) goLive(true)
} }
ivHomeMapRefreshLocation -> notifyRefreshLocation()
llHomeMapTopPet.ivTopPetBtnSmall -> showMapTypeDialog() llHomeMapTopPet.ivTopPetBtnSmall -> showMapTypeDialog()
homeMapBluetoothBtn -> checkPermissions(1) homeMapBluetoothBtn -> checkPermissions(1)
llHomeMapTopPet.homeDataPetNameSmall, llHomeMapTopPet.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog() llHomeMapTopPet.homeDataPetNameSmall, llHomeMapTopPet.homeDataPetHeadSmall.root -> {
getHomeV2Activity()?.let {
if (!it.isNotifyRefreshLocation) {
getHomeV2Activity()?.selectPetDialog()
}
}
}
ilHomeMapDeviceBatteryLayout.ivDeviceCloseBtn -> { ilHomeMapDeviceBatteryLayout.ivDeviceCloseBtn -> {
mMapDeviceBean?.isCloseBattery = true mMapDeviceBean?.isCloseBattery = true
llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE llHomeMapDeviceBatteryLayout.visibility = View.INVISIBLE

View File

@@ -229,7 +229,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
mGoogleMap?.let { mGoogleMap?.let {
if (null == mRippleCircle) { if (null == mRippleCircle) {
mRippleCircle = it.addCircle( mRippleCircle = it.addCircle(
CircleOptions().center(this) CircleOptions().center(toGCJ02LatLon(this))
.radius(mRippleCircleRadius * mRippleCirclePercent) .radius(mRippleCircleRadius * mRippleCirclePercent)
.strokeWidth(AppUtils.dpToPx(2).toFloat()) .strokeWidth(AppUtils.dpToPx(2).toFloat())
.fillColor(ContextCompat.getColor(mContext!!, R.color.black10)) .fillColor(ContextCompat.getColor(mContext!!, R.color.black10))
@@ -253,7 +253,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
mRippleCirclePercent = it.animatedValue as Float / 100.0 mRippleCirclePercent = it.animatedValue as Float / 100.0
mRippleCircle?.apply { mRippleCircle?.apply {
mPetLatLng?.let { petLatLng -> mPetLatLng?.let { petLatLng ->
center = petLatLng center = toGCJ02LatLon(petLatLng)
radius = mRippleCircleRadius * mRippleCirclePercent radius = mRippleCircleRadius * mRippleCirclePercent
} }
} }
@@ -261,6 +261,10 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
repeatMode = ValueAnimator.RESTART repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE repeatCount = ValueAnimator.INFINITE
} }
} else {
mValueAnimator?.apply {
if (!isRunning) start()
}
} }
} }
@@ -291,7 +295,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
for (i in 0 until trackList.size) { for (i in 0 until trackList.size) {
trackList[i].apply { trackList[i].apply {
val latLng = LatLng(latitude, longitude) val latLng = LatLng(latitude, longitude)
latLngList.add(latLng) latLngList.add(toGCJ02LatLon(latLng))
if (i == trackList.size - 1) { if (i == trackList.size - 1) {
// addUserAndPetLine(latLng) // addUserAndPetLine(latLng)
refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera) refreshPetCurrentLocation(latLng, needMoveCamera = isMoveCamera)
@@ -319,6 +323,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
* 直播开始之后,改变绿色波纹动画 * 直播开始之后,改变绿色波纹动画
*/ */
fun greenRippleCircleAnim() { fun greenRippleCircleAnim() {
if (null == mRippleCircle) addRippleCircle()
mRippleCircle?.apply { mRippleCircle?.apply {
//一像素对应几米 //一像素对应几米
val pxDis = 2.0.pow(15.5 - getGoogleMapZoom()) val pxDis = 2.0.pow(15.5 - getGoogleMapZoom())
@@ -329,8 +334,14 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
} }
} }
fun clearRippleCircleAnim() {
mValueAnimator?.cancel()
mRippleCircle?.remove()
mRippleCircle = null
}
override fun onDetach() { override fun onDetach() {
super.onDetach() super.onDetach()
mValueAnimator?.cancel() clearRippleCircleAnim()
} }
} }

View File

@@ -143,6 +143,13 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
(mFragments[1] as HomeTrackFragment).getPetTrackerInfoData() (mFragments[1] as HomeTrackFragment).getPetTrackerInfoData()
} }
} }
checkNotifyLocationState()
}
fun checkNotifyLocationState() {
getHomeV2Activity()?.apply {
checkNotifyRefreshLocation(mViewBinding.ilHomePetTopBar.homeDataPetNameSmall)
}
} }
override fun onPause() { override fun onPause() {
@@ -207,7 +214,12 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
override fun onClick(v: View?) { override fun onClick(v: View?) {
mViewBinding.apply { mViewBinding.apply {
when (v!!) { when (v!!) {
ilHomePetTopBar.homeDataPetNameSmall, ilHomePetTopBar.homeDataPetHeadSmall.root -> getHomeV2Activity()?.selectPetDialog() ilHomePetTopBar.homeDataPetNameSmall, ilHomePetTopBar.homeDataPetHeadSmall.root -> {
getHomeV2Activity()?.let {
if (!it.isNotifyRefreshLocation) it.selectPetDialog()
}
}
ilHomePetTopBar.ivTopPetBtnSmall -> startActivity( ilHomePetTopBar.ivTopPetBtnSmall -> startActivity(
Intent(mContext, NotificationV2Activity::class.java) Intent(mContext, NotificationV2Activity::class.java)
) )

View File

@@ -29,6 +29,7 @@ import kotlinx.coroutines.launch
class MapViewModel : ViewModel() { class MapViewModel : ViewModel() {
val mMapDeviceLiveData = MutableLiveData<Result<MapDeviceBean>>() val mMapDeviceLiveData = MutableLiveData<Result<MapDeviceBean>>()
val mRefreshLocationLiveData = MutableLiveData<Result<String>>()
private var mCountDownTimer: CountDownTimer? = null private var mCountDownTimer: CountDownTimer? = null
//几分钟倒计时(min) //几分钟倒计时(min)
@@ -37,6 +38,13 @@ class MapViewModel : ViewModel() {
var mDeviceMsgType = ConstantInt.SpecialType var mDeviceMsgType = ConstantInt.SpecialType
fun setupRefreshLocation(deviceId: String) {
viewModelScope.launch {
val result = NetworkApi.setupRefreshLocation(deviceId)
mRefreshLocationLiveData.value = result
}
}
fun getMapDeviceStatus(deviceId: String, isNeedCountDown: Boolean = true) { fun getMapDeviceStatus(deviceId: String, isNeedCountDown: Boolean = true) {
viewModelScope.launch { viewModelScope.launch {
stopGetData() stopGetData()
@@ -51,7 +59,7 @@ class MapViewModel : ViewModel() {
* 更新刷新时间 * 更新刷新时间
*/ */
fun updateMillisInFuture(refreshMin: Float) { fun updateMillisInFuture(refreshMin: Float) {
if (refreshMin <= 0 || mRefreshDataMin == refreshMin) return if (refreshMin <= 0) return
mRefreshDataMin = refreshMin mRefreshDataMin = refreshMin
countDownGetData(mDeviceId) countDownGetData(mDeviceId)
} }
@@ -432,7 +440,7 @@ class MapViewModel : ViewModel() {
mapDeviceBean: MapDeviceBean, mapDeviceBean: MapDeviceBean,
rootView: ViewGroup, rootView: ViewGroup,
batteryText: TypefaceTextView, batteryText: TypefaceTextView,
closeBtn: AppCompatImageView closeBtn: AppCompatImageView //可关闭按钮
) { ) {
mapDeviceBean.apply { mapDeviceBean.apply {
if (isCloseBattery) return@apply if (isCloseBattery) return@apply

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape android:shape="oval">
<solid android:color="@color/light_yellow_color" />
<stroke android:width="@dimen/dp_1" android:color="@color/white" />
</shape>
</item>
</selector>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"> <item android:state_enabled="true" android:state_pressed="false">
<shape android:shape="oval"> <shape android:shape="oval">
<solid android:color="@color/yellow_color30" /> <solid android:color="@color/yellow_color30" />
<stroke android:width="@dimen/dp_1" android:color="@color/white" /> <stroke android:width="@dimen/dp_1" android:color="@color/white" />
@@ -12,4 +12,10 @@
<stroke android:width="@dimen/dp_1" android:color="@color/white" /> <stroke android:width="@dimen/dp_1" android:color="@color/white" />
</shape> </shape>
</item> </item>
<item android:state_enabled="false">
<shape android:shape="oval">
<solid android:color="@color/light_yellow_color" />
<stroke android:width="@dimen/dp_1" android:color="@color/white" />
</shape>
</item>
</selector> </selector>

View File

@@ -66,30 +66,46 @@
android:visibility="invisible" /> android:visibility="invisible" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/home_map_bluetooth_btn" android:id="@+id/iv_home_map_refresh_location"
style="@style/map_image_white_btn_style" style="@style/map_image_yellow_btn_style"
android:layout_above="@id/il_home_map_pet_location" android:layout_above="@id/il_home_map_pet_location"
android:layout_alignEnd="@id/rv_home_map_device_state" android:layout_alignEnd="@id/rv_home_map_device_state"
android:layout_marginBottom="@dimen/dp_8" android:layout_marginBottom="@dimen/dp_18"
android:padding="@dimen/dp_8" android:tint="@color/grey_color" />
android:src="@drawable/icon_map_bluetooth" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/home_map_refresh_btn" android:id="@+id/home_map_refresh_btn"
style="@style/map_image_yellow_btn_style" style="@style/map_image_yellow_btn_style"
android:layout_above="@id/home_map_bluetooth_btn" android:layout_above="@id/iv_home_map_refresh_location"
android:layout_alignEnd="@id/home_map_bluetooth_btn" android:layout_alignEnd="@id/iv_home_map_refresh_location"
android:layout_marginBottom="@dimen/dp_8" /> android:layout_marginBottom="@dimen/dp_8" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/home_map_bluetooth_btn"
style="@style/map_image_white_btn_style"
android:layout_alignBottom="@id/iv_home_map_refresh_location"
android:padding="@dimen/dp_8"
android:src="@drawable/icon_map_bluetooth" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_home_map_ble_con_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/home_map_bluetooth_btn"
android:layout_alignEnd="@id/home_map_bluetooth_btn"
android:src="@drawable/icon_map_offline" />
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/home_map_live_btn" android:id="@+id/home_map_live_btn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignTop="@id/home_map_refresh_btn" android:layout_above="@id/home_map_bluetooth_btn"
android:layout_marginBottom="@dimen/dp_8"
android:background="@drawable/shape38_gray_alpha_circle_bg" android:background="@drawable/shape38_gray_alpha_circle_bg"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="@dimen/dp_14" android:paddingHorizontal="@dimen/dp_14"
android:paddingVertical="@dimen/dp_16"> android:paddingVertical="@dimen/dp_16"
android:visibility="gone">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_home_map_live_image" android:id="@+id/iv_home_map_live_image"

View File

@@ -375,4 +375,5 @@
<color name="blue_color">#26A8FF</color> <color name="blue_color">#26A8FF</color>
<color name="line_stroke_color">#077B4A</color> <color name="line_stroke_color">#077B4A</color>
<color name="rote_line_color">#00C478</color> <color name="rote_line_color">#00C478</color>
<color name="light_yellow_color">#F9FFE8</color>
</resources> </resources>

View File

@@ -1058,7 +1058,6 @@
<string name="txt_tracker_offline">Tracker Offline. Unable to proceed.</string> <string name="txt_tracker_offline">Tracker Offline. Unable to proceed.</string>
<string name="txt_tracker_live">Live stream in progress. Settings unavailable.</string> <string name="txt_tracker_live">Live stream in progress. Settings unavailable.</string>
<string name="txt_abnormity">Operation failed. Please try again.</string> <string name="txt_abnormity">Operation failed. Please try again.</string>
<string name="txt_per_day">/day</string> <string name="txt_per_day">/day</string>
<string name="txt_renewal_day">Renewal: $%s/%s day on %s</string> <string name="txt_renewal_day">Renewal: $%s/%s day on %s</string>
<string name="txt_day_unit">/day x%s</string> <string name="txt_day_unit">/day x%s</string>
@@ -1069,5 +1068,8 @@
<string name="txt_auto_subscription_years">(Renew at $%s/%s years thereafter)</string> <string name="txt_auto_subscription_years">(Renew at $%s/%s years thereafter)</string>
<string name="txt_auto_subscription_months">(Renew at $%s/%s months thereafter)</string> <string name="txt_auto_subscription_months">(Renew at $%s/%s months thereafter)</string>
<string name="txt_tone">Tone</string> <string name="txt_tone">Tone</string>
<string name="txt_locate_works">Locate works on cellular only</string>
<string name="txt_pet_close">Pet is close, try Radar</string>
</resources> </resources>