修改套餐时间到期算法,删除以前map和直播v

2版本
This commit is contained in:
yezhiqiu
2026-02-04 17:42:07 +08:00
parent d55cb89936
commit 0409b50712
15 changed files with 31 additions and 1928 deletions

View File

@@ -1 +1 @@
#Fri Dec 26 18:05:45 CST 2025 #Wed Feb 04 14:33:32 CST 2026

View File

@@ -387,10 +387,6 @@
android:name=".ui.activity.device.wifi.EditWifiPowerZoneActivity" android:name=".ui.activity.device.wifi.EditWifiPowerZoneActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name=".ui.activity.map.LiveActivityV2"
android:exported="false"
android:screenOrientation="portrait" />
<activity <activity
android:name=".ui.activity.map.LiveActivityV3" android:name=".ui.activity.map.LiveActivityV3"
android:exported="false" android:exported="false"

View File

@@ -443,6 +443,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
} }
mChangePetListDialogAdapter.apply { mChangePetListDialogAdapter.apply {
setData(mPetList, true) setData(mPetList, true)
(mFragments[2] as MapV3Fragment).showPetNameAndHead(mSelectPetPosition)
if (isFirst) { if (isFirst) {
isFirst = false isFirst = false
setSelectPetPos(mSelectPetPosition) setSelectPetPos(mSelectPetPosition)
@@ -477,7 +478,6 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
} }
} }
} }
(mFragments[2] as MapV3Fragment).showPetNameAndHead(mSelectPetPosition)
} }
} }

View File

@@ -186,8 +186,9 @@ class SureSubscriptionPlanActivity :
getString(R.string.txt_month_unit), "${p.planTimeMonthsCount}" getString(R.string.txt_month_unit), "${p.planTimeMonthsCount}"
) )
val renewalString = if (p.mealUnit == ConstantString.PackageUnitYear) { val renewalString = if (p.mealUnit == ConstantString.PackageUnitYear) {
val renewalTimestamp = val renewalTimestamp = Utils.timestampAddHowTimestamp(
Utils.getAfterHowTimestamp(nowTimestamp, p.period * 365L) nowTimestamp, p.period, ConstantString.PackageUnitYear
)
val renewalDate = val renewalDate =
Utils.formatTime(renewalTimestamp, Utils.DATE_FORMAT_PATTERN_EN7) Utils.formatTime(renewalTimestamp, Utils.DATE_FORMAT_PATTERN_EN7)
if (p.planTimeMonthsCount > 12) { if (p.planTimeMonthsCount > 12) {
@@ -214,8 +215,9 @@ class SureSubscriptionPlanActivity :
renewalDate renewalDate
) )
} else { } else {
val renewalTimestamp = val renewalTimestamp = Utils.timestampAddHowTimestamp(
Utils.getAfterHowTimestamp(nowTimestamp, 30L * p.planTimeMonthsCount) nowTimestamp, p.planTimeMonthsCount, ConstantString.PackageUnitMonth
)
val renewalDate = val renewalDate =
Utils.formatTime(renewalTimestamp, Utils.DATE_FORMAT_PATTERN_EN7) Utils.formatTime(renewalTimestamp, Utils.DATE_FORMAT_PATTERN_EN7)
if (p.planTimeMonthsCount > 1) { if (p.planTimeMonthsCount > 1) {

View File

@@ -492,7 +492,7 @@ class HomeTrackFragment :
ViewUtil.instance.addMenuBean(mTrackMenuList, getString(R.string.txt_live_duration)) ViewUtil.instance.addMenuBean(mTrackMenuList, getString(R.string.txt_live_duration))
ViewUtil.instance.addMenuBean( ViewUtil.instance.addMenuBean(
mTrackMenuList, mTrackMenuList,
getString(R.string.txt_firmware_upgrade), getString(R.string.txt_firmware_version),
menuType = MultipleEntity.IMG_TEXT_IMG menuType = MultipleEntity.IMG_TEXT_IMG
) )
ViewUtil.instance.addMenuBean( ViewUtil.instance.addMenuBean(

View File

@@ -1,647 +0,0 @@
package com.abbidot.tracker.ui.fragment.map
import android.content.Context
import android.content.Intent
import android.location.LocationManager
import android.provider.Settings
import android.view.View
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import com.abbidot.baselibrary.constant.ConState
import com.abbidot.baselibrary.constant.EventName
import com.abbidot.baselibrary.constant.MMKVKey
import com.abbidot.baselibrary.eventbus.XEventBus
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.util.AppUtils
import com.abbidot.baselibrary.util.LogUtil
import com.abbidot.baselibrary.util.MMKVUtil
import com.abbidot.tracker.R
import com.abbidot.tracker.adapter.HomeMapDeviceMsgAdapter
import com.abbidot.tracker.adapter.HomeMapDeviceStateAdapter
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.base.BaseFragment
import com.abbidot.tracker.bean.BleReportDataBean
import com.abbidot.tracker.bean.BleTrackDeviceBean
import com.abbidot.tracker.bean.DataBean
import com.abbidot.tracker.bean.FamilyBean
import com.abbidot.tracker.bean.MapDeviceBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.database.MyDatabase
import com.abbidot.tracker.databinding.FragmentMapV2Binding
import com.abbidot.tracker.dialog.CommonDialog1
import com.abbidot.tracker.dialog.SelectMapTypeDialog
import com.abbidot.tracker.ui.activity.HomeV2Activity
import com.abbidot.tracker.ui.activity.device.MyTrackerV2Activity
import com.abbidot.tracker.ui.activity.map.LiveActivityV2
import com.abbidot.tracker.ui.common.map.HomeMapCommon
import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.vm.FamilyViewModel
import com.abbidot.tracker.vm.FencesMapViewModel
import com.abbidot.tracker.vm.MapViewModel
import com.abbidot.tracker.widget.MapDeviceNetView
import com.clj.fastble.BleManager
import com.hjq.permissions.XXPermissions
import com.hjq.permissions.permission.PermissionLists
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject
/**
* 首页map
* create an instance of this fragment.
*/
@AndroidEntryPoint
class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::inflate) {
private val mFencesMapViewModel: FencesMapViewModel by viewModels()
private val mMapViewModel: MapViewModel by viewModels()
private val mFamilyViewModel: FamilyViewModel by viewModels()
private lateinit var mLocationManager: LocationManager
private lateinit var mHomeV2Activity: HomeV2Activity
private var mSelectMapTypeDialog: SelectMapTypeDialog? = null
//当前这个页面显示的宠物下标
private var mCurrentShowPetPos = -1
@Inject
lateinit var mHomeMapCommon: HomeMapCommon
private lateinit var mFragment: Fragment
private var mMapDeviceBean: MapDeviceBean? = null
private lateinit var mDeviceStateList: MutableList<DataBean>
private lateinit var mDeviceStateAdapter: HomeMapDeviceStateAdapter
private lateinit var mDeviceMsgList: MutableList<DataBean>
private lateinit var mDeviceMsgAdapter: HomeMapDeviceMsgAdapter
//启动移动地图摄像机
private var isMoveCamera = true
private var mShowCenterLocationType = ConstantInt.PetLocationType
//是否显示围栏
private var isShowFence = true
//地图类型,标准和卫星地图
private var mMapType = ConstantInt.Type0
companion object {
@JvmStatic
fun newInstance(context: Context) = MapV2Fragment().apply {
mContext = context
}
}
override fun initData() {
mLocationManager = mContext!!.getSystemService(Context.LOCATION_SERVICE) as LocationManager
mHomeV2Activity = activity as HomeV2Activity
mCurrentShowPetPos = mHomeV2Activity.mSelectPetPosition
isShowFence = Util.getShowFenceSp()
mViewBinding.apply {
mHomeV2Activity.edgeToEdgeAdapterBars(
rlHomeMapTopLayout, WindowInsetsCompat.Type.statusBars()
)
mFragment = mHomeMapCommon.getMapFragment(
mContext!!, miHomeMapAddressView, dnHomeMapNetView
) { mapLoadOk() }
dnHomeMapNetView.setShowNetType(MapDeviceNetView.NO_NET_TYPE)
llHomeMapTopPet.ivTopPetBtnSmall.setImageResource(R.drawable.icon_map_type)
ViewUtil.instance.setMapSwitchLocationButtonImage(
homeMapRefreshBtn, mShowCenterLocationType
)
mDeviceStateList = mutableListOf()
mDeviceMsgList = mutableListOf()
mMapViewModel.addDeviceDefaultStateData(mContext!!, mDeviceStateList)
mDeviceStateAdapter = HomeMapDeviceStateAdapter(mContext!!, mDeviceStateList)
ViewUtil.instance.setRecyclerViewVerticalLinearLayout(
mContext!!, rvHomeMapDeviceState, mDeviceStateAdapter, bottom = 10
)
mDeviceMsgAdapter = HomeMapDeviceMsgAdapter(mContext!!, mDeviceMsgList)
ViewUtil.instance.setRecyclerViewVerticalLinearLayout(
mContext!!, rvHomeMapDeviceMsg, mDeviceMsgAdapter, bottom = 10
)
setOnClickListenerViews(
homeMapRefreshBtn,
homeMapBluetoothBtn,
homeMapLiveBtn,
llHomeMapTopPet.ivTopPetBtnSmall,
llHomeMapTopPet.homeDataPetNameSmall,
llHomeMapTopPet.homeDataPetHeadSmall.root
)
if (AppUtils.isDebug()) {
llHomeMapTopPet.homeDataPetHeadSmall.appHeadImage.setOnLongClickListener {
mHomeV2Activity.goToDebugActivity()
true
}
}
}
//解决报错java.lang.IllegalArgumentException
//No view found for id 0x7f090254 (com.abbidot.tracker:id/fc_home_map_fragment) for fragment HomeMapGoogleMapFragment
//https://www.jianshu.com/p/9235092f407a
childFragmentManager.commit {
add(R.id.fc_home_map_fragment, mFragment)
}
// (mActivity as FragmentActivity).supportFragmentManager.commit {
// add(R.id.fc_home_map_fragment, mFragment)
// }
locationPermissionsTip(1)
}
override fun onResume() {
super.onResume()
//其他页面是否选择了宠物
if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) {
showPetNameAndHead(mHomeV2Activity.mSelectPetPosition)
}
mViewBinding.apply {
homeMapLiveBtn.isEnabled = true
homeMapBluetoothBtn.isEnabled = true
}
val showFence = Util.getShowFenceSp()
//检测直播页面有没有修改围栏显示
if (isShowFence != showFence) {
if (null == mSelectMapTypeDialog) {
setFencesShow(showFence)
} else {
mSelectMapTypeDialog?.setFencesSwitch(showFence)
}
}
}
private fun getHomeV2Activity(): HomeV2Activity? {
return if (null == activity) {
LogUtil.e("getHomeV2Activity,null == activity")
null
} else {
activity as HomeV2Activity
}
}
/**
* 地图加载好了
*/
private fun mapLoadOk() {
LogUtil.e("MapV2Fragment 地图加载好了${mHomeV2Activity.mPetList}")
// mHomeV2Activity.mDataViewModel.getHomeBindPetList(mHomeV2Activity)
mHomeV2Activity.apply {
if (mPetList.size > 0) showPetNameAndHead(mSelectPetPosition)
mFamilyViewModel.getDeviceInviteInfo(this)
}
}
override fun liveDataObserve() {
//获取设备邀请信息
mFamilyViewModel.mInviteInfoLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) {
it.getOrNull()?.apply {
if (deleteArray.isNotEmpty()) showDeleteInviteDialog(deleteArray)
if (inviteArray.isNotEmpty()) showInviteDialog(inviteArray)
}
}
})
}
//获取当前宠物位置和围栏信息
mMapViewModel.mMapDeviceLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) {
val data = it.getOrNull()
data?.apply {
mMapDeviceBean = data
setMapData(data)
mMapViewModel.setDeviceStateAndWarningData(
mContext!!,
mHomeV2Activity.getPet(),
data,
mDeviceStateList,
mDeviceStateAdapter,
mDeviceMsgList,
mDeviceMsgAdapter,
mViewBinding.rvHomeMapDeviceMsg
)
}
}
}, showLoading = false, isRequestErrorTip = false)
}
//删除围栏通知
XEventBus.observe(this, EventName.DeleteFences) {
updateMapDeviceStatus()
}
//添加编辑围栏通知
XEventBus.observe(this, EventName.RefreshFences) {
updateMapDeviceStatus()
}
//直播自动结束提示
XEventBus.observe(this, EventName.LiveAutoEnd) {
ViewUtil.instance.showDialog(
mContext!!, R.string.txt_live_ended, object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
dialog.dismiss()
}
}, okTextResId = R.string.txt_sure, cancelTextResId = R.string.txt_cancel
)
}
//直播超时
XEventBus.observe(this, EventName.LiveOpenTimeOut) {
ViewUtil.instance.showDialog(
mContext!!,
R.string.txt_time_out_try_again,
object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
dialog.dismiss()
locationPermissionsTip()
}
},
okTextResId = R.string.txt_sure
)
}
//蓝牙上报的数据
XEventBus.observe(this, EventName.BleReportData) { reportData: BleReportDataBean ->
mHomeV2Activity.getPet(false)?.apply {
if (macID == reportData.mac) updateBleReportData(reportData)
}
}
//接收蓝牙连接状态
XEventBus.observe(this, EventName.ConnectDeviceState) { trackBle: BleTrackDeviceBean ->
mHomeV2Activity.getPet(false)?.apply {
//蓝牙断开就重新获取服务器数据,蓝牙数据上报断开
if (trackBle.mac == macID && trackBle.conState != ConState.CONNECTED) {
//隐藏蓝牙nearby
mViewBinding.rvHomeMapDeviceMsg.visibility = View.GONE
updateMapDeviceStatus()
}
}
}
}
/**
* 更新蓝牙上报的数据
*/
private fun updateBleReportData(bleReportDataBean: BleReportDataBean) {
bleReportDataBean.apply {
if (haveDeviceStateData) {
mMapViewModel.stopGetData()
if (null == mMapDeviceBean) mMapDeviceBean = MapDeviceBean()
mMapDeviceBean?.let {
Util.bleReportDataToMapDevice(it, bleReportDataBean)
if (haveLocationData) {
locationList?.let { list ->
val location = list[list.size - 1]
it.longitude = location.longitude
it.latitude = location.latitude
}
mHomeMapCommon.setMapDeviceBean(mMapDeviceBean)
mHomeMapCommon.refreshPetCurrentLocation(
it.latitude, it.longitude, isMoveCamera
)
mHomeMapCommon.startRefreshUserLocation()
}
}
mViewBinding.homeMapLiveBtn.visibility = View.VISIBLE
mMapViewModel.setDeviceStateAndWarningData(
mContext!!,
mHomeV2Activity.getPet(),
mMapDeviceBean!!,
mDeviceStateList,
mDeviceStateAdapter,
mDeviceMsgList,
mDeviceMsgAdapter,
mViewBinding.rvHomeMapDeviceMsg
)
}
}
}
/**
* 显示被删除邀请的弹窗
*/
private fun showDeleteInviteDialog(deleteArray: MutableList<FamilyBean>) {
lifecycleScope.launch(Dispatchers.IO) {
val myDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
myDeviceDb?.apply {
for (deviceDb in myDeviceDb) {
for (item in deleteArray) {
if (deviceDb.deviceId == item.deviceId) {
MyDatabase.deviceDao().delete(deviceDb)
LogUtil.e("删除了邀请的设备")
}
}
}
}
val newDeviceDb = MyDatabase.deviceDao().findAll(MyDatabase.DeviceTableName)
newDeviceDb?.apply {
LogUtil.e("删去了邀请,还剩${newDeviceDb.size}下个设备")
}
}
CommonDialog1(
mContext!!,
getString(R.string.txt_setting_notification),
getString(R.string.txt_view_access),
false,
okClickListener = object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
if (mHomeV2Activity.mPetList.size == 0) {
mHomeV2Activity.noSharePet()
} else {
mHomeV2Activity.onChangeClick(0)
}
}
}).show()
}
/**
* 显示被邀请通知弹窗
*/
private fun showInviteDialog(inviteArray: MutableList<FamilyBean>) {
for (item in inviteArray) {
val content = String.format(
getString(R.string.txt_invites_you_check), item.userName, item.petName
)
CommonDialog1(
mContext!!,
getString(R.string.txt_setting_notification),
content,
false,
okClickListener = object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
startActivity(
mHomeV2Activity, Intent(
mHomeV2Activity, MyTrackerV2Activity::class.java
)
)
}
}).show()
}
}
private val mPermissionsTips =
"ABBIDOT APP collects location data,The route and distance between the current location and the device can be calculated."
/**
* 弹窗说明需要位置权限做什么,上架市场需要
*/
private fun locationPermissionsTip(type: Int = 0) {
if (XXPermissions.isGrantedPermissions(
mContext!!, mutableListOf(
PermissionLists.getAccessFineLocationPermission(),
PermissionLists.getAccessCoarseLocationPermission()
)
)
) {
if (type == 0) checkPermissions(type)
} else {
ViewUtil.instance.showDialog(
mContext!!, mPermissionsTips, object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
dialog.dismiss()
if (type == 0) checkPermissions(type)
else Util.checkLocationPermissionsGpsEnabled(mContext!!, {})
}
}, okTextResId = R.string.txt_accept, cancelTextResId = R.string.txt_deny
)
}
}
/**
* 更新首页设备状态数据
*/
private fun updateMapDeviceStatus(
isNeedCountDown: Boolean = true, useBleLocation: Boolean = false
) {
// mShowCenterLocationType = ConstantInt.PetLocationType
// ViewUtil.instance.setMapSwitchLocationButtonImage(
// mViewBinding.homeMapRefreshBtn, mShowCenterLocationType
// )
if (mHomeV2Activity.mPetList.size <= mCurrentShowPetPos) return
mHomeV2Activity.getPet()?.apply {
//蓝牙连接上,就直接用蓝牙上报的位置刷新
if (useBleLocation && BleManager.getInstance().isConnected(macID)) {
mMapDeviceBean?.let {
mHomeMapCommon.refreshPetCurrentLocation(
it.latitude, it.longitude, isMoveCamera
)
mHomeMapCommon.startRefreshUserLocation()
}
} else {
mMapViewModel.getMapDeviceStatus(deviceId, isNeedCountDown)
}
}
}
/**
* 显示地图类型选择弹窗
*/
private fun showMapTypeDialog() {
if (null == mSelectMapTypeDialog) mSelectMapTypeDialog = ViewUtil.instance.getMapTypeDialog(
mContext!!, object : BaseRecyclerAdapter.OnItemClickListener {
override fun onItemClick(itemView: View?, pos: Int) {
mMapType = Util.getMapTypeSp()
if (pos == mMapType) {
return
}
mHomeMapCommon.switchSatelliteAndNormalMapType()
}
}) { v, isChecked ->
if (v.id == R.id.cb_dialog_map_fences_switch) {
setFencesShow(isChecked)
}
}
else {
mSelectMapTypeDialog!!.mapTypeSpToUpdate()
}
mSelectMapTypeDialog?.show()
}
/**
* 设置围栏显示
*/
private fun setFencesShow(isShow: Boolean) {
isShowFence = isShow
MMKVUtil.putBoolean(MMKVKey.ShowFence, isShow)
if (isShow) {
mMapDeviceBean?.fences?.let { fences ->
mFencesMapViewModel.setFencesData(mContext!!, fences, mFragment)
}
} else {
mFencesMapViewModel.setFencesData(mContext!!, null, mFragment)
}
}
/**
* 设置需要更新的标识
*/
fun setNeedUpdateTag() {
mCurrentShowPetPos = -1
}
/**
* 显示选择宠物
*/
fun showPetNameAndHead(position: Int) {
//变量初始化
if (!::mHomeV2Activity.isInitialized) {
return
}
if (mHomeV2Activity.mPetList.size == 0) {
return
}
mCurrentShowPetPos = position
ViewUtil.instance.selectPetDialogShow(
mContext!!,
mHomeV2Activity.mPetList,
position,
mViewBinding.llHomeMapTopPet.homeDataPetNameSmall,
mViewBinding.llHomeMapTopPet.homeDataPetHeadSmall.appHeadImage
)
if (mHomeMapCommon.isMapLoadOk()) {
isMoveCamera=true
mHomeMapCommon.clearMarker()
mViewBinding.miHomeMapAddressView.visibility = View.GONE
mViewBinding.rvHomeMapDeviceMsg.visibility = View.GONE
showLoading(true)
val pet = mHomeV2Activity.mPetList[position]
//重新设置地图宠物头像
mHomeMapCommon.setPetHeadIcon(pet.imgurl, pet.petType)
//获取首页设备信息状态
updateMapDeviceStatus()
}
}
/**
* 设置地图相关数据
*/
private fun setMapData(mapDeviceBean: MapDeviceBean) {
mapDeviceBean.apply {
//分钟后无上报、没有lte信号或在wifi中隐藏直播按钮
mViewBinding.homeMapLiveBtn.visibility =
if (Util.isTimeoutReport(updateTime) || powerSwitch == ConstantInt.Type0 || powerSwitch == ConstantInt.Type2 || inWifiZone == ConstantInt.Type1) View.GONE
else View.VISIBLE
mHomeMapCommon.setMapDeviceBean(this)
//设置循环查询时间间隔 30秒
mMapViewModel.updateMillisInFuture(0.5f)
if (isShowFence) {
fences?.let { fences ->
mFencesMapViewModel.setFencesData(mContext!!, fences, mFragment)
}
}
// mShowCenterLocationType = ConstantInt.PetLocationType
// ViewUtil.instance.setMapSwitchLocationButtonImage(
// mViewBinding.homeMapRefreshBtn, mShowCenterLocationType
// )
mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera)
mHomeMapCommon.startRefreshUserLocation()
isMoveCamera = false
}
}
/**
* 检查获取定位,蓝牙权限
*/
private fun checkPermissions(type: Int) {
Util.checkBluetoothPermissionsEnabled(mContext!!, {
if (type == 0) {
if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
startActivity(intent)
} else if (mHomeV2Activity.isRequestPetData && mHomeV2Activity.mPetList.size == 0) {
showToast(R.string.no_bind_pet)
} else {
mHomeV2Activity.getPet()?.apply {
mViewBinding.homeMapLiveBtn.isEnabled = false
val intent = Intent(mContext, LiveActivityV2::class.java)
intent.putExtra(ConstantString.JumpActivity, true)
intent.putExtra(ConstantString.Pet, this)
startActivity(intent)
}
}
} else if (type == 1) {
if (!SRBleUtil.instance.isBleEnable(mContext!!)) {
SRBleUtil.instance.openBluetooth(mContext!!)
} else if (mHomeV2Activity.isRequestPetData && mHomeV2Activity.mPetList.size == 0) {
showToast(R.string.no_bind_pet)
} else {
mHomeV2Activity.getPet()?.apply {
mViewBinding.homeMapBluetoothBtn.isEnabled = false
val intent = Intent(mContext, LiveActivityV2::class.java)
intent.putExtra(ConstantString.JumpActivity, false)
intent.putExtra(ConstantString.Pet, this)
startActivity(intent)
}
}
}
})
}
override fun onClick(v: View?) {
mViewBinding.apply {
when (v!!) {
homeMapRefreshBtn -> {
if (mHomeV2Activity.isRequestPetData && mHomeV2Activity.mPetList.size == 0) {
showToast(R.string.no_bind_pet)
return
}
if (mShowCenterLocationType == ConstantInt.PetLocationType) {
mShowCenterLocationType = ConstantInt.UserLocationType
mHomeMapCommon.switchShowLocation(mShowCenterLocationType)
} else {
mShowCenterLocationType = ConstantInt.PetLocationType
isMoveCamera = true
updateMapDeviceStatus(useBleLocation = true)
}
ViewUtil.instance.setMapSwitchLocationButtonImage(
homeMapRefreshBtn, mShowCenterLocationType
)
}
homeMapLiveBtn -> {
// locationPermissionsTip()
mHomeV2Activity.getPet()?.apply {
mViewBinding.homeMapLiveBtn.isEnabled = false
val intent = Intent(mContext, LiveActivityV2::class.java)
intent.putExtra(ConstantString.JumpActivity, true)
intent.putExtra(ConstantString.Pet, this)
startActivity(intent)
}
}
llHomeMapTopPet.ivTopPetBtnSmall -> showMapTypeDialog()
homeMapBluetoothBtn -> checkPermissions(1)
llHomeMapTopPet.homeDataPetNameSmall, llHomeMapTopPet.homeDataPetHeadSmall.root -> mHomeV2Activity.selectPetDialog()
}
}
}
}

View File

@@ -242,6 +242,8 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
} }
mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) { mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) {
mCountDownTimerViewModel.isStartCountDown = true
LogUtil.e("22222222222")
mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.text = mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.text =
getHomeV2Activity()?.getPet()?.petName getHomeV2Activity()?.getPet()?.petName
} }
@@ -487,6 +489,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
if (mPetList.size == 0) { if (mPetList.size == 0) {
return return
} }
mCountDownTimerViewModel.isStartCountDown = false
mCurrentShowPetPos = position mCurrentShowPetPos = position
//隐藏蓝牙nearby //隐藏蓝牙nearby
@@ -530,23 +533,18 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
mapDeviceBean.apply { mapDeviceBean.apply {
setMapDeviceBean(this) setMapDeviceBean(this)
//设置循环查询时间间隔 30秒 //设置循环查询时间间隔 30秒
mMapViewModel.updateMillisInFuture(0.5f) // mMapViewModel.updateMillisInFuture(0.5f)
if (latitude == 0.0 && longitude == 0.0) { if (latitude == 0.0 && longitude == 0.0) {
mHomeMapCommon.clearMarker() if (!mCountDownTimerViewModel.isStartCountDown) {
isMoveCamera = true mHomeMapCommon.clearMarker()
mHomeMapCommon.getUserGoogleLatLng()?.let { isMoveCamera = true
mHomeMapCommon.refreshPetCurrentLocation( mCountDownTimerViewModel.startCountDown(30)
it.latitude, it.longitude, isMoveCamera mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.setText(R.string.txt_locating)
) mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE
} }
mCountDownTimerViewModel.startCountDown(30) mHomeMapCommon.switchShowLocation(ConstantInt.UserLocationType)
mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.setText(R.string.txt_locating)
mViewBinding.ilHomeMapPetLocation.root.visibility = View.INVISIBLE
} else { } else {
// mViewBinding.llHomeMapTopPet.homeDataPetNameSmall.text =
// getHomeV2Activity()?.getPet()?.petName
// mCountDownTimerViewModel.stopCountDown()
mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera) mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera)
isMoveCamera = false isMoveCamera = false
} }

View File

@@ -14,6 +14,9 @@ class CountDownTimerViewModel : ViewModel() {
val mCountDownEndLiveData = MutableLiveData<Long>() val mCountDownEndLiveData = MutableLiveData<Long>()
private var mCountDownTimer: CountDownTimer? = null private var mCountDownTimer: CountDownTimer? = null
//是否开始倒计时
var isStartCountDown = false
/** /**
* @param second 秒 * @param second 秒
* 倒计时 * 倒计时
@@ -23,16 +26,19 @@ class CountDownTimerViewModel : ViewModel() {
mCountDownTimer = object : CountDownTimer(second * 1000, countDownInterval * 1000L) { mCountDownTimer = object : CountDownTimer(second * 1000, countDownInterval * 1000L) {
override fun onTick(millisUntilFinished: Long) { override fun onTick(millisUntilFinished: Long) {
val time = millisUntilFinished / 1000 val time = millisUntilFinished / 1000
isStartCountDown = true
mCountDowningLiveData.value = time mCountDowningLiveData.value = time
} }
override fun onFinish() { override fun onFinish() {
isStartCountDown = false
mCountDownEndLiveData.value = 0L mCountDownEndLiveData.value = 0L
} }
}.start() }.start()
} }
fun stopCountDown() { fun stopCountDown() {
isStartCountDown = false
mCountDownTimer?.cancel() mCountDownTimer?.cancel()
} }

View File

@@ -238,7 +238,7 @@ class FencesPolygonView : View {
it.drawBitmap(this, mCPoint.x - width / 2, mCPoint.y - height / 2, null) it.drawBitmap(this, mCPoint.x - width / 2, mCPoint.y - height / 2, null)
it.drawBitmap(this, mBPoint.x - width / 2, mBPoint.y - height / 2, null) it.drawBitmap(this, mBPoint.x - width / 2, mBPoint.y - height / 2, null)
} }
it.drawRect(mPathRectF, mFillPaint)
} }
} }

View File

@@ -1,136 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat 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"
android:orientation="vertical"
tools:context=".ui.activity.map.LiveActivityV2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fc_live_v2_map_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.abbidot.tracker.widget.MapMarkerInfoView
android:id="@+id/mi_live_v2_map_address_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@id/fc_live_v2_map_fragment"
android:layout_alignBottom="@id/fc_live_v2_map_fragment" />
<com.abbidot.tracker.widget.MapDeviceNetView
android:id="@+id/dn_live_v2_map_net_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@id/fc_live_v2_map_fragment"
android:layout_alignBottom="@id/fc_live_v2_map_fragment"
android:visibility="gone" />
<include
android:id="@+id/ll_live_v2_map_top_pet"
layout="@layout/layout_top_pet_data_small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/dp_8"
android:layout_marginTop="@dimen/dp_40" />
<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
android:id="@+id/ll_live_v2_state_layout"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_34"
android:layout_below="@id/ll_live_v2_map_top_pet"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_8"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingHorizontal="@dimen/dp_12"
android:visibility="gone"
app:qmui_backgroundColor="@color/select_color2"
app:qmui_radius="@dimen/dp_28">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lav_live_v2_state_anim"
android:layout_width="@dimen/dp_40"
android:layout_height="wrap_content"
android:visibility="gone"
app:lottie_loop="true" />
<com.abbidot.tracker.widget.TypefaceTextView
android:id="@+id/tv_live_v2_state_content"
style="@style/my_TextView_style_v2"
android:text="@string/txt_starting_live"
android:textColor="@color/select_color"
android:textSize="@dimen/textSize12"
app:typeface="@string/roboto_regular_font" />
</com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_live_v2_map_device_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ll_live_v2_state_layout"
android:layout_centerInParent="true"
android:layout_marginTop="@dimen/dp_8" />
<com.abbidot.tracker.widget.NonSwipeRecyclerView
android:id="@+id/rv_map_live_v2_device_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ll_live_v2_map_top_pet"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/dp_18"
android:layout_marginEnd="@dimen/dp_12"
android:layoutDirection="rtl" />
<include
android:id="@+id/il_live_v2_bluetooth_find_device"
layout="@layout/layout_bluetooth_find_device"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_map_live_v2_refresh_btn"
style="@style/map_image_yellow_btn_style"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="@dimen/dp_12"
android:layout_marginBottom="@dimen/dp_16" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_map_live_v2_bluetooth_btn"
style="@style/map_image_white_btn_style"
android:layout_alignTop="@id/iv_map_live_v2_refresh_btn"
android:layout_alignBottom="@id/iv_map_live_v2_refresh_btn"
android:layout_marginStart="@dimen/dp_12"
android:padding="@dimen/dp_8"
android:src="@drawable/icon_map_bluetooth" />
<include
android:id="@+id/il_map_live_v2_issue_layout"
layout="@layout/layout_live_issue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone" />
</RelativeLayout>
<include
android:id="@+id/il_live_v2_operate_layout"
layout="@layout/layout_live_v2_data_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white" />
</androidx.appcompat.widget.LinearLayoutCompat>

View File

@@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.activity.map.LiveActivityV2"> tools:context=".ui.activity.map.LiveActivityV3">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -1,100 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.fragment.map.MapV2Fragment">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fc_home_map_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.abbidot.tracker.widget.MapMarkerInfoView
android:id="@+id/mi_home_map_address_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.abbidot.tracker.widget.MapDeviceNetView
android:id="@+id/dn_home_map_net_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/rl_home_map_top_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="@dimen/dp_8">
<include
android:id="@+id/ll_home_map_top_pet"
layout="@layout/layout_top_pet_data_small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_8" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_home_map_device_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ll_home_map_top_pet"
android:layout_centerInParent="true"
android:layout_marginTop="@dimen/dp_8" />
<com.abbidot.tracker.widget.NonSwipeRecyclerView
android:id="@+id/rv_home_map_device_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ll_home_map_top_pet"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/dp_60"
android:layout_marginEnd="@dimen/dp_2"
android:layoutDirection="rtl" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/home_map_bluetooth_btn"
style="@style/map_image_white_btn_style"
android:layout_alignEnd="@id/rv_home_map_device_state"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dp_60"
android:padding="@dimen/dp_8"
android:src="@drawable/icon_map_bluetooth" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/home_map_refresh_btn"
style="@style/map_image_yellow_btn_style"
android:layout_above="@id/home_map_bluetooth_btn"
android:layout_alignEnd="@id/home_map_bluetooth_btn"
android:layout_marginBottom="@dimen/dp_8" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/home_map_live_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/dp_58"
android:background="@drawable/shape38_green_alpha_circle_bg"
android:orientation="vertical"
android:paddingHorizontal="@dimen/dp_36"
android:paddingVertical="@dimen/dp_6"
android:visibility="gone">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon_black_cir_ring"
android:padding="@dimen/dp_6"
android:src="@drawable/icon_red_dot" />
<com.abbidot.tracker.widget.TypefaceTextView
style="@style/my_TextView_style_v2"
android:layout_marginTop="@dimen/dp_2"
android:text="@string/txt_live"
android:textSize="@dimen/textSize12"
android:textStyle="bold" />
</androidx.appcompat.widget.LinearLayoutCompat>
</RelativeLayout>
</FrameLayout>

View File

@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.fragment.map.MapV2Fragment"> tools:context=".ui.fragment.map.MapV3Fragment">
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
android:id="@+id/fc_home_map_fragment" android:id="@+id/fc_home_map_fragment"

View File

@@ -483,7 +483,7 @@
<string name="txt_please_wait">Please wait…</string> <string name="txt_please_wait">Please wait…</string>
<string name="txt_release_notes">Version Description</string> <string name="txt_release_notes">Version Description</string>
<string name="txt_firmware_name">Firmware Name</string> <string name="txt_firmware_name">Firmware Name</string>
<string name="txt_firmware_version">Firmware version</string> <string name="txt_firmware_version">Firmware Version</string>
<string name="txt_firmware_size">Firmware file size</string> <string name="txt_firmware_size">Firmware file size</string>
<string name="txt_upgrade">upgrade</string> <string name="txt_upgrade">upgrade</string>
<string name="txt_upgrade_success">Upgrade successful</string> <string name="txt_upgrade_success">Upgrade successful</string>
@@ -499,7 +499,7 @@
<string name="txt_upgrading">Upgrading</string> <string name="txt_upgrading">Upgrading</string>
<string name="txt_upgrade_start">Preparing for Upgrade</string> <string name="txt_upgrade_start">Preparing for Upgrade</string>
<string name="txt_device_connect_success">Device successfully connected</string> <string name="txt_device_connect_success">Device successfully connected</string>
<string name="txt_latest_version">Currently the latest version</string> <string name="txt_latest_version">Already latest version</string>
<string name="txt_device_has_bind">The tracker is paired with another account</string> <string name="txt_device_has_bind">The tracker is paired with another account</string>
<string name="txt_activity">Activity</string> <string name="txt_activity">Activity</string>
<string name="txt_route">Route</string> <string name="txt_route">Route</string>