新增蓝牙围栏数据同步下发;修改服务器端口8868

This commit is contained in:
yezhiqiu
2025-11-11 18:22:08 +08:00
parent 9e465cef8c
commit 30df6ed02e
37 changed files with 554 additions and 186 deletions

View File

@@ -30,7 +30,7 @@ android {
targetSdkVersion 35 targetSdkVersion 35
versionCode 2022 versionCode 2022
// versionName "2.0.22" // versionName "2.0.22"
versionName "2.0.22-Beta2" versionName "2.0.22-Beta4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -41,6 +41,7 @@ class HomeAccountMenuAdapter(
private lateinit var mHomeV2Activity: HomeV2Activity private lateinit var mHomeV2Activity: HomeV2Activity
private lateinit var mUnitSelectDialog: UnitSelectDialog private lateinit var mUnitSelectDialog: UnitSelectDialog
private val mAccountV2Fragment = accountV2Fragment private val mAccountV2Fragment = accountV2Fragment
private var isShowDialog = false
init { init {
addItemType(MultipleEntity.TEXT, R.layout.item_title_text_type) addItemType(MultipleEntity.TEXT, R.layout.item_title_text_type)
@@ -131,7 +132,6 @@ class HomeAccountMenuAdapter(
mHomeV2Activity.getString(R.string.txt_log_out_tips), mHomeV2Activity.getString(R.string.txt_log_out_tips),
position position
) )
} }
}, item.menuName }, item.menuName
) )
@@ -145,23 +145,36 @@ class HomeAccountMenuAdapter(
} }
private fun dialogShowType(type: Int, string: String, pos: Int) { private fun dialogShowType(type: Int, string: String, pos: Int) {
ViewUtil.instance.showDialog(context, string, object : BaseDialog.OnDialogOkListener { if (isShowDialog) return
override fun onOkClick(dialog: BaseDialog<*>) { isShowDialog = true
dialog.dismiss() ViewUtil.instance.showDialog(
when { context,
mLogOutTipsType == type -> { string,
Util.logOut(mHomeV2Activity, mHomeV2Activity.lifecycleScope) object : BaseDialog.OnDialogOkListener {
} override fun onOkClick(dialog: BaseDialog<*>) {
isShowDialog = false
dialog.dismiss()
when {
mLogOutTipsType == type -> {
Util.logOut(mHomeV2Activity, mHomeV2Activity.lifecycleScope)
}
mCloseAccountTipsType == type -> { mCloseAccountTipsType == type -> {
// closeAccount() // closeAccount()
} }
else -> { else -> {
// mHomeV2Activity.clearCache(this@HomeAccountMenuAdapter, pos) // mHomeV2Activity.clearCache(this@HomeAccountMenuAdapter, pos)
}
} }
} }
} },
}, okTextResId = R.string.txt_sure) okTextResId = R.string.txt_sure,
cancelListener = object : BaseDialog.OnDialogCancelListener {
override fun onCancelClick(dialog: BaseDialog<*>) {
isShowDialog = false
dialog.dismiss()
}
})
} }
} }

View File

@@ -131,10 +131,12 @@ class MySubscriptionAdapter(
View.VISIBLE View.VISIBLE
} else View.GONE } else View.GONE
} }
//充值
holder.setClickListener(R.id.btn_my_subscription_recharge) { holder.setClickListener(R.id.btn_my_subscription_recharge) {
if (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close) { if (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close) {
Intent(mContext, SubscriptionPlanActivity::class.java).let { Intent(mContext, SubscriptionPlanActivity::class.java).let {
it.putExtra(ConstantString.LkSetMeal, item) it.putExtra(ConstantString.LkSetMeal, item)
it.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
mMySubscriptionActivity.startActivity(it) mMySubscriptionActivity.startActivity(it)
} }
} else { } else {
@@ -174,6 +176,7 @@ class MySubscriptionAdapter(
val intent = Intent(mContext, ChoosePlanActivity::class.java) val intent = Intent(mContext, ChoosePlanActivity::class.java)
intent.putExtra(ConstantString.Title, "Premium") intent.putExtra(ConstantString.Title, "Premium")
intent.putExtra(ConstantString.Upgrade, true) intent.putExtra(ConstantString.Upgrade, true)
intent.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
intent.putExtra(ConstantString.LkSetMeal, item) intent.putExtra(ConstantString.LkSetMeal, item)
mMySubscriptionActivity.startActivity(intent) mMySubscriptionActivity.startActivity(intent)
} }

View File

@@ -219,7 +219,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
} }
/** /**
* 监听键盘弹出和隐藏,解决键盘弹出隐藏输入框的问题 * 监听键盘弹出和隐藏,解决键盘弹出挡住输入框的问题
*/ */
fun setListenKeyboardChange(windowTranslateY: Int = 500, view: View = window.decorView) { fun setListenKeyboardChange(windowTranslateY: Int = 500, view: View = window.decorView) {
window.decorView.viewTreeObserver.addOnGlobalLayoutListener { window.decorView.viewTreeObserver.addOnGlobalLayoutListener {
@@ -421,7 +421,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
// } // }
} }
fun showNoCancelableLoading(show: Boolean) { fun showNoCancelableLoading(show: Boolean, message: String = getString(R.string.txt_loading)) {
if (!isFrontRunning) { if (!isFrontRunning) {
return return
} }
@@ -432,7 +432,6 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
// var message = tip // var message = tip
// if (TextUtils.isEmpty(tip)) { // if (TextUtils.isEmpty(tip)) {
// } // }
val message = getString(R.string.txt_loading)
mLoadingDialog = mLoadingDialog =
QMUITipDialog.Builder(mContext).setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) QMUITipDialog.Builder(mContext).setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
.setTipWord(message).create(false).apply { .setTipWord(message).create(false).apply {
@@ -567,6 +566,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
getResultCallback.onResult(0) getResultCallback.onResult(0)
} }
} catch (e: Exception) { } catch (e: Exception) {
finish()
LogUtil.e("接口出错造成的异常:${e.message}") LogUtil.e("接口出错造成的异常:${e.message}")
} }
} }

View File

@@ -62,7 +62,6 @@ abstract class BaseFragment<T : ViewBinding>(
liveDataObserve() liveDataObserve()
} }
/** /**
* 注册监听livedata观察者 * 注册监听livedata观察者
*/ */

View File

@@ -44,6 +44,7 @@ data class FencesBean(
var ancillaryOtherLongitude: Double, var ancillaryOtherLongitude: Double,
var longDistance: Int, var longDistance: Int,
var shortDistance: Int, var shortDistance: Int,
var modeType: Int,//数据下发方式 1:纯ble2:纯wifi3:ble失败转wifi
var startDrag: Boolean//围栏形状是否开始拖动 var startDrag: Boolean//围栏形状是否开始拖动
) : Parcelable, BaseDiffBean() { ) : Parcelable, BaseDiffBean() {
constructor() : this( constructor() : this(
@@ -53,7 +54,7 @@ data class FencesBean(
"", "",
"", "",
"", "",
0, 1,
0, 0,
0.0, 0.0,
0.0, 0.0,
@@ -80,6 +81,7 @@ data class FencesBean(
0.0, 0.0,
0, 0,
0, 0,
0,
false false
) )

View File

@@ -382,7 +382,7 @@ class FencesAddActivity : BaseActivity<ActivityFencesAddBinding>(ActivityFencesA
override fun onOkClick(dialog: BaseDialog<*>) { override fun onOkClick(dialog: BaseDialog<*>) {
dialog.dismiss() dialog.dismiss()
mFencesManageViewModel.deleteFence( mFencesManageViewModel.deleteFence(
this@FencesAddActivity, mFenceId, mDeviceServiceId this@FencesAddActivity, mFenceId, mDeviceServiceId, 1
) )
} }
}, okTextResId = R.string.txt_sure }, okTextResId = R.string.txt_sure

View File

@@ -56,6 +56,7 @@ class PackageUpgradeDialog(activity: BaseActivity<*>, deviceId: String) :
) )
intent.putExtra(ConstantString.Upgrade, true) intent.putExtra(ConstantString.Upgrade, true)
intent.putExtra(ConstantString.LkSetMeal, d) intent.putExtra(ConstantString.LkSetMeal, d)
intent.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
mBaseActivity.startActivity(intent) mBaseActivity.startActivity(intent)
dismiss() dismiss()
break break

View File

@@ -359,8 +359,9 @@ interface INetworkService {
@Field("ancillaryLatitude") ancillaryLatitude: Double, @Field("ancillaryLatitude") ancillaryLatitude: Double,
@Field("ancillaryLongitude") ancillaryLongitude: Double, @Field("ancillaryLongitude") ancillaryLongitude: Double,
@Field("ancillaryOtherLatitude") ancillaryOtherLatitude: Double, @Field("ancillaryOtherLatitude") ancillaryOtherLatitude: Double,
@Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double @Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double,
// @Field("fenceId") fenceId: String @Field("fenceId") fenceId: String,
@Field("modeType") modeType: Int
): BaseResponse<FencesBean> ): BaseResponse<FencesBean>
/** /**
@@ -393,7 +394,9 @@ interface INetworkService {
@Field("longitudeCenter") longitudeCenter: Double, @Field("longitudeCenter") longitudeCenter: Double,
@Field("latitudeCenter") latitudeCenter: Double, @Field("latitudeCenter") latitudeCenter: Double,
@Field("longDistance") longDistance: Int, @Field("longDistance") longDistance: Int,
@Field("shortDistance") shortDistance: Int @Field("shortDistance") shortDistance: Int,
@Field("fenceId") fenceId: String,
@Field("modeType") modeType: Int
): BaseResponse<FencesBean> ): BaseResponse<FencesBean>
/** /**
@@ -427,6 +430,8 @@ interface INetworkService {
@Field("latitudeCenter") latitudeCenter: Double, @Field("latitudeCenter") latitudeCenter: Double,
// @Field("longDistance") longDistance: Double, // @Field("longDistance") longDistance: Double,
// @Field("shortDistance") shortDistance: Double // @Field("shortDistance") shortDistance: Double
@Field("fenceId") fenceId: String,
@Field("modeType") modeType: Int
): BaseResponse<FencesBean> ): BaseResponse<FencesBean>
/** /**
@@ -451,7 +456,8 @@ interface INetworkService {
@Field("ancillaryLatitude") ancillaryLatitude: Double, @Field("ancillaryLatitude") ancillaryLatitude: Double,
@Field("ancillaryLongitude") ancillaryLongitude: Double, @Field("ancillaryLongitude") ancillaryLongitude: Double,
@Field("ancillaryOtherLatitude") ancillaryOtherLatitude: Double, @Field("ancillaryOtherLatitude") ancillaryOtherLatitude: Double,
@Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double @Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double,
@Field("modeType") modeType: Int
): BaseResponse<String> ): BaseResponse<String>
/** /**
@@ -484,7 +490,8 @@ interface INetworkService {
@Field("longitudeCenter") longitudeCenter: Double, @Field("longitudeCenter") longitudeCenter: Double,
@Field("latitudeCenter") latitudeCenter: Double, @Field("latitudeCenter") latitudeCenter: Double,
@Field("longDistance") longDistance: Int, @Field("longDistance") longDistance: Int,
@Field("shortDistance") shortDistance: Int @Field("shortDistance") shortDistance: Int,
@Field("modeType") modeType: Int
): BaseResponse<String> ): BaseResponse<String>
/** /**
@@ -517,6 +524,7 @@ interface INetworkService {
@Field("latitudeF") latitudeF: Double, @Field("latitudeF") latitudeF: Double,
@Field("longitudeCenter") longitudeCenter: Double, @Field("longitudeCenter") longitudeCenter: Double,
@Field("latitudeCenter") latitudeCenter: Double, @Field("latitudeCenter") latitudeCenter: Double,
@Field("modeType") modeType: Int
): BaseResponse<String> ): BaseResponse<String>
/** /**
@@ -524,9 +532,7 @@ interface INetworkService {
*/ */
@GET("device$VERSION_NUMBER/getFenceList") @GET("device$VERSION_NUMBER/getFenceList")
suspend fun getFenceList( suspend fun getFenceList(
@Query( @Query("deviceId") deviceId: String
"deviceId"
) deviceId: String
): BaseResponse<GetFencesBean> ): BaseResponse<GetFencesBean>
/** /**
@@ -535,7 +541,9 @@ interface INetworkService {
@FormUrlEncoded @FormUrlEncoded
@POST("device/removeFence") @POST("device/removeFence")
suspend fun removeFence( suspend fun removeFence(
@Field("fenceId") fenceId: String, @Field("deviceServiceId") deviceServiceId: String @Field("fenceId") fenceId: String,
@Field("deviceServiceId") deviceServiceId: String,
@Field("modeType") modeType: Int
): BaseResponse<String> ): BaseResponse<String>
/** /**

View File

@@ -227,7 +227,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
*/ */
suspend fun addCircleFence(fencesBean: FencesBean) = getResult { suspend fun addCircleFence(fencesBean: FencesBean) = getResult {
service.addCircleFence( service.addCircleFence(
fencesBean.deviceId, fencesBean.deviceServiceId, fencesBean.deviceId,
fencesBean.deviceServiceId,
fencesBean.name, fencesBean.name,
fencesBean.address, fencesBean.address,
"", "",
@@ -242,6 +243,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
fencesBean.ancillaryLongitude, fencesBean.ancillaryLongitude,
fencesBean.ancillaryOtherLatitude, fencesBean.ancillaryOtherLatitude,
fencesBean.ancillaryOtherLongitude, fencesBean.ancillaryOtherLongitude,
fencesBean.fenceId,
fencesBean.modeType
) )
} }
@@ -270,7 +273,9 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
fencesBean.longitudeCenter, fencesBean.longitudeCenter,
fencesBean.latitudeCenter, fencesBean.latitudeCenter,
fencesBean.longDistance, fencesBean.longDistance,
fencesBean.shortDistance fencesBean.shortDistance,
fencesBean.fenceId,
fencesBean.modeType
) )
} }
@@ -279,7 +284,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
*/ */
suspend fun addPolygonFence(fencesBean: FencesBean) = getResult { suspend fun addPolygonFence(fencesBean: FencesBean) = getResult {
service.addPolygonFence( service.addPolygonFence(
fencesBean.deviceId, fencesBean.deviceServiceId, fencesBean.deviceId,
fencesBean.deviceServiceId,
fencesBean.name, fencesBean.name,
fencesBean.address, fencesBean.address,
"", "",
@@ -301,6 +307,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
fencesBean.latitudeF, fencesBean.latitudeF,
fencesBean.longitudeCenter, fencesBean.longitudeCenter,
fencesBean.latitudeCenter, fencesBean.latitudeCenter,
fencesBean.fenceId,
fencesBean.modeType
) )
} }
@@ -323,7 +331,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
ancillaryLatitude: Double, ancillaryLatitude: Double,
ancillaryLongitude: Double, ancillaryLongitude: Double,
ancillaryOtherLatitude: Double, ancillaryOtherLatitude: Double,
ancillaryOtherLongitude: Double ancillaryOtherLongitude: Double,
modeType: Int
) = getResult { ) = getResult {
service.updateCircleFence( service.updateCircleFence(
deviceId, deviceId,
@@ -342,7 +351,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
ancillaryLatitude, ancillaryLatitude,
ancillaryLongitude, ancillaryLongitude,
ancillaryOtherLatitude, ancillaryOtherLatitude,
ancillaryOtherLongitude ancillaryOtherLongitude,
modeType
) )
} }
@@ -370,7 +380,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
longitudeCenter: Double, longitudeCenter: Double,
latitudeCenter: Double, latitudeCenter: Double,
longDistance: Int, longDistance: Int,
shortDistance: Int shortDistance: Int,
modeType: Int
) = getResult { ) = getResult {
service.updateRectFence( service.updateRectFence(
deviceId, deviceId,
@@ -394,7 +405,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
longitudeCenter, longitudeCenter,
latitudeCenter, latitudeCenter,
longDistance, longDistance,
shortDistance shortDistance,
modeType
) )
} }
@@ -403,7 +415,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
*/ */
suspend fun updatePolygonFence(fencesBean: FencesBean) = getResult { suspend fun updatePolygonFence(fencesBean: FencesBean) = getResult {
service.updatePolygonFence( service.updatePolygonFence(
fencesBean.deviceId, fencesBean.deviceServiceId, fencesBean.deviceId,
fencesBean.deviceServiceId,
fencesBean.fenceId, fencesBean.fenceId,
fencesBean.name, fencesBean.name,
fencesBean.address, fencesBean.address,
@@ -426,6 +439,7 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
fencesBean.latitudeF, fencesBean.latitudeF,
fencesBean.longitudeCenter, fencesBean.longitudeCenter,
fencesBean.latitudeCenter, fencesBean.latitudeCenter,
fencesBean.modeType
) )
} }
@@ -439,8 +453,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
/** /**
* 移除围栏 * 移除围栏
*/ */
suspend fun removeFence(fenceId: String, deviceServiceId: String) = getResult { suspend fun removeFence(fenceId: String, deviceServiceId: String,modeType:Int) = getResult {
service.removeFence(fenceId, deviceServiceId) service.removeFence(fenceId, deviceServiceId,modeType)
} }
/** /**

View File

@@ -321,6 +321,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
mContext, SubscriptionPlanActivity::class.java mContext, SubscriptionPlanActivity::class.java
).let { i -> ).let { i ->
i.putExtra(ConstantString.LkSetMeal, l) i.putExtra(ConstantString.LkSetMeal, l)
i.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
startActivity(i) startActivity(i)
} }
break break

View File

@@ -24,6 +24,9 @@ class AddNewTracker2Activity :
private var isFirstBind = false private var isFirstBind = false
private lateinit var mScanDeviceList: ArrayList<DataBean> private lateinit var mScanDeviceList: ArrayList<DataBean>
//第一次没扫地设备,继续第二次
private var againScan = true
override fun getTopBar() = mViewBinding.ilAddNewTracker2TopBar.titleTopBar override fun getTopBar() = mViewBinding.ilAddNewTracker2TopBar.titleTopBar
override fun initData() { override fun initData() {
@@ -56,7 +59,7 @@ class AddNewTracker2Activity :
mScanDeviceList.clear() mScanDeviceList.clear()
// 扫描超时时间,可选 // 扫描超时时间,可选
val scanRuleConfig = BleScanRuleConfig.Builder().setScanTimeOut(15000).build() val scanRuleConfig = BleScanRuleConfig.Builder().setScanTimeOut(3000).build()
BleManager.getInstance().initScanRule(scanRuleConfig) BleManager.getInstance().initScanRule(scanRuleConfig)
BleManager.getInstance().scan(object : BleScanCallback() { BleManager.getInstance().scan(object : BleScanCallback() {
override fun onScanStarted(success: Boolean) { override fun onScanStarted(success: Boolean) {
@@ -66,7 +69,7 @@ class AddNewTracker2Activity :
override fun onScanning(bleDevice: BleDevice?) { override fun onScanning(bleDevice: BleDevice?) {
LogUtil.d("onScanning....$bleDevice") LogUtil.d("onScanning....$bleDevice")
bleDevice?.apply { bleDevice?.apply {
if (null != name && name.contains("Pet_Tracker")) { if (null != name && name.contains(SRBleUtil.instance.trackDeviceBleStartName)) {
val start = 45 val start = 45
val end = start + 6 val end = start + 6
val subArray = scanRecord.sliceArray(start until end) val subArray = scanRecord.sliceArray(start until end)
@@ -88,6 +91,12 @@ class AddNewTracker2Activity :
} }
private fun scanFinished() { private fun scanFinished() {
if (againScan && mScanDeviceList.size == 0) {
againScan = false
LogUtil.e("没有扫描到设备,再次重试")
startScanBle()
return
}
if (mScanDeviceList.size > 0) { if (mScanDeviceList.size > 0) {
val intent = Intent(mContext, AddNewTracker3Activity::class.java) val intent = Intent(mContext, AddNewTracker3Activity::class.java)
intent.putParcelableArrayListExtra(ConstantString.DeviceInfo, mScanDeviceList) intent.putParcelableArrayListExtra(ConstantString.DeviceInfo, mScanDeviceList)
@@ -95,11 +104,13 @@ class AddNewTracker2Activity :
startActivityFinish(intent) startActivityFinish(intent)
} else { } else {
mViewBinding.lavAddNewTracker2Lottie.visibility = View.GONE mViewBinding.lavAddNewTracker2Lottie.visibility = View.GONE
ViewUtil.instance.showDialog(mContext, ViewUtil.instance.showDialog(
mContext,
R.string.txt_no_search_device, R.string.txt_no_search_device,
object : BaseDialog.OnDialogOkListener { object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) { override fun onOkClick(dialog: BaseDialog<*>) {
dialog.dismiss() dialog.dismiss()
againScan = true
mViewBinding.lavAddNewTracker2Lottie.visibility = View.VISIBLE mViewBinding.lavAddNewTracker2Lottie.visibility = View.VISIBLE
startScanBle() startScanBle()
} }

View File

@@ -19,10 +19,12 @@ import com.abbidot.tracker.R
import com.abbidot.tracker.adapter.SelectFencesTypeCardShadeAdapter import com.abbidot.tracker.adapter.SelectFencesTypeCardShadeAdapter
import com.abbidot.tracker.adapter.VirtualFencesZoneShadeAdapter import com.abbidot.tracker.adapter.VirtualFencesZoneShadeAdapter
import com.abbidot.tracker.base.BaseActivity import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.bean.DataBean import com.abbidot.tracker.bean.DataBean
import com.abbidot.tracker.bean.FencesBean import com.abbidot.tracker.bean.FencesBean
import com.abbidot.tracker.bean.GetFencesBean import com.abbidot.tracker.bean.GetFencesBean
import com.abbidot.tracker.bean.PetBean import com.abbidot.tracker.bean.PetBean
import com.abbidot.tracker.bean.ReceiveDeviceData
import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.constant.GetResultCallback import com.abbidot.tracker.constant.GetResultCallback
@@ -30,6 +32,7 @@ import com.abbidot.tracker.databinding.ActivityAddEditFencesZoneBinding
import com.abbidot.tracker.ui.common.map.FencesAddEditMapCommon import com.abbidot.tracker.ui.common.map.FencesAddEditMapCommon
import com.abbidot.tracker.util.Util import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
import com.abbidot.tracker.util.bluetooth.SRBleUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.vm.FencesManageViewModel import com.abbidot.tracker.vm.FencesManageViewModel
import com.abbidot.tracker.vm.FencesMapViewModel import com.abbidot.tracker.vm.FencesMapViewModel
@@ -37,6 +40,7 @@ import com.abbidot.tracker.vm.GeoCoderViewModel
import com.abbidot.tracker.widget.OnCircleViewScaleClickListener import com.abbidot.tracker.widget.OnCircleViewScaleClickListener
import com.abbidot.tracker.widget.OnPolygonViewPointPullClickListener import com.abbidot.tracker.widget.OnPolygonViewPointPullClickListener
import com.abbidot.tracker.widget.OnRectViewRotateScaleClickListener import com.abbidot.tracker.widget.OnRectViewRotateScaleClickListener
import com.clj.fastble.BleManager
import com.daimajia.androidanimations.library.Techniques import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo import com.daimajia.androidanimations.library.YoYo
@@ -77,6 +81,9 @@ open class AddAndEditFencesZoneBaseActivity :
private lateinit var mDistanceUnit: String private lateinit var mDistanceUnit: String
//操作类型0增加1编辑2删除
private var mActionType = ConstantInt.Type0
override fun getTopBar() = mViewBinding.addEditFencesZoneTopBar.titleTopBar override fun getTopBar() = mViewBinding.addEditFencesZoneTopBar.titleTopBar
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@@ -270,6 +277,44 @@ open class AddAndEditFencesZoneBaseActivity :
// text = it // text = it
} }
} }
//接收发送指令后设备返回的数据
XEventBus.observe(this, EventName.DeviceReceiveData) { receive: ReceiveDeviceData ->
mPetBean?.let {
if (it.macID == receive.mac) {
val data = receive.data
parseData(data)
}
}
}
}
private fun parseData(data: ByteArray?) {
data?.apply {
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
//围栏设置
if (data0 == 0x13 && data1 == 1) {
//成功
if (data2 == 0) {
mFencesBean.modeType = ConstantInt.Type1
when (mActionType) {
ConstantInt.Type0 -> successTips(R.string.txt_save_successful)
ConstantInt.Type1 -> updateNetFences(mFencesBean)
ConstantInt.Type2 -> deleteNetFences(mFencesBean)
}
} else {
//失败
mFencesBean.modeType = ConstantInt.Type3
when (mActionType) {
ConstantInt.Type0 -> saveFences(mFencesBean)
ConstantInt.Type1 -> updateNetFences(mFencesBean)
ConstantInt.Type2 -> deleteNetFences(mFencesBean)
}
}
}
}
} }
/** /**
@@ -298,10 +343,20 @@ open class AddAndEditFencesZoneBaseActivity :
dealRequestResult(it, object : GetResultCallback { dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) { override fun onResult(any: Any) {
it.getOrNull()?.apply { it.getOrNull()?.apply {
// sendNotifyData() //ble失败
mFencesBean.fenceId = fenceId if (mFencesBean.modeType == ConstantInt.Type3) {
sendFenceData() successTips()
successTips(R.string.txt_fence_saved) } else {
mFencesBean.fenceId = fenceId
mPetBean?.let { p ->
//有连接蓝牙
if (BleManager.getInstance().isConnected(p.macID)) {
sendFenceData()
} else {
successTips()
}
}
}
} }
} }
@@ -314,17 +369,13 @@ open class AddAndEditFencesZoneBaseActivity :
} }
/** /**
* 编辑更新围栏通知 * 删除、编辑更新围栏通知
*/ */
fun editLiveDataObserve() { fun editLiveDataObserve() {
mFencesManageViewModel.mDeleteFenceLiveData.observe(this) { mFencesManageViewModel.mDeleteFenceLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback { dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) { override fun onResult(any: Any) {
XEventBus.post(EventName.DeleteFences) XEventBus.post(EventName.DeleteFences)
// sendNotifyData()
//删除蓝牙标志
mFencesBean.isOn = ConstantInt.Type2
sendFenceData()
showToast( showToast(
R.string.txt_delete_success, isFinish = true, gravity = Gravity.CENTER R.string.txt_delete_success, isFinish = true, gravity = Gravity.CENTER
) )
@@ -334,33 +385,32 @@ open class AddAndEditFencesZoneBaseActivity :
mFencesManageViewModel.mUpdateFenceLiveData.observe(this) { mFencesManageViewModel.mUpdateFenceLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback { dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) { override fun onResult(any: Any) {
// sendNotifyData() //失败
sendFenceData() if (mFencesBean.modeType == ConstantInt.Type3) {
successTips(R.string.txt_fence_saved) successTips()
} else {
successTips(R.string.txt_save_successful)
}
} }
}) })
} }
} }
private fun sendNotifyData() {
mPetBean?.apply {
SRBleUtil.instance.isConnectBleSendNotifyData(macID)
}
}
/** /**
* 发送围栏数据 * 发送围栏数据
*/ */
private fun sendFenceData() { private fun sendFenceData() {
mPetBean?.apply { mPetBean?.apply {
SRBleUtil.instance.isConnectBleSendFenceData(macID, mFencesBean) SRBleUtil.instance.isConnectBleSendCmdData(
macID, SRBleCmdUtil.instance.setFences(mFencesBean)
)
} }
} }
/** /**
* 修改成功提示 * 修改成功提示
*/ */
private fun successTips(resStringId: Int) { private fun successTips(resStringId: Int = R.string.txt_fence_saved) {
XEventBus.post(EventName.RefreshFences) XEventBus.post(EventName.RefreshFences)
showToast(resStringId, isFinish = true, gravity = Gravity.CENTER) showToast(resStringId, isFinish = true, gravity = Gravity.CENTER)
} }
@@ -598,6 +648,12 @@ open class AddAndEditFencesZoneBaseActivity :
return return
} }
fencesBean.apply { fencesBean.apply {
mPetBean?.let {
modeType = if (modeType == ConstantInt.Type3) ConstantInt.Type3
else if (BleManager.getInstance().isConnected(it.macID)) ConstantInt.Type1
else ConstantInt.Type2
}
mActionType = ConstantInt.Type0
setButtonEnabled(mViewBinding.btnSaveFencesZone, ConstantInt.Type0) setButtonEnabled(mViewBinding.btnSaveFencesZone, ConstantInt.Type0)
name = fenceName name = fenceName
when (fenceShapeType) { when (fenceShapeType) {
@@ -626,6 +682,26 @@ open class AddAndEditFencesZoneBaseActivity :
* 更新围栏 * 更新围栏
*/ */
fun updateFences(fencesBean: FencesBean) { fun updateFences(fencesBean: FencesBean) {
val fenceName = mViewBinding.ilFencesZoneNameInput.etInputContent.text.toString()
if (TextUtils.isEmpty(fenceName)) {
showToast(R.string.txt_not_null, gravity = Gravity.CENTER)
return
}
mActionType = ConstantInt.Type1
mPetBean?.let {
if (BleManager.getInstance().isConnected(it.macID)) {
sendFenceData()
} else {
fencesBean.modeType = ConstantInt.Type2
updateNetFences(fencesBean)
}
}
}
/**
* 更新接口围栏
*/
private fun updateNetFences(fencesBean: FencesBean) {
val fenceName = mViewBinding.ilFencesZoneNameInput.etInputContent.text.toString() val fenceName = mViewBinding.ilFencesZoneNameInput.etInputContent.text.toString()
if (TextUtils.isEmpty(fenceName)) { if (TextUtils.isEmpty(fenceName)) {
showToast(R.string.txt_not_null, gravity = Gravity.CENTER) showToast(R.string.txt_not_null, gravity = Gravity.CENTER)
@@ -633,6 +709,11 @@ open class AddAndEditFencesZoneBaseActivity :
} }
fencesBean.apply { fencesBean.apply {
name = fenceName name = fenceName
mPetBean?.let {
modeType = if (modeType == ConstantInt.Type3) ConstantInt.Type3
else if (BleManager.getInstance().isConnected(it.macID)) ConstantInt.Type1
else ConstantInt.Type2
}
when (fenceShapeType) { when (fenceShapeType) {
ConstantInt.CircleShapeType -> { ConstantInt.CircleShapeType -> {
mFencesManageViewModel.updateCircleFence( mFencesManageViewModel.updateCircleFence(
@@ -659,9 +740,33 @@ open class AddAndEditFencesZoneBaseActivity :
* 删除围栏 * 删除围栏
*/ */
fun deleteFences(fencesBean: FencesBean) { fun deleteFences(fencesBean: FencesBean) {
ViewUtil.instance.showDialog(
this, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
dialog.dismiss()
mPetBean?.let {
mActionType = ConstantInt.Type2
if (BleManager.getInstance().isConnected(it.macID)) {
//删除蓝牙标志
fencesBean.isOn = ConstantInt.Type2
sendFenceData()
} else {
fencesBean.modeType = ConstantInt.Type2
deleteNetFences(fencesBean)
}
}
}
}, okTextResId = R.string.txt_sure
)
}
/**
* 删除围栏
*/
private fun deleteNetFences(fencesBean: FencesBean) {
fencesBean.apply { fencesBean.apply {
mFencesManageViewModel.deleteFence( mFencesManageViewModel.deleteFence(
this@AddAndEditFencesZoneBaseActivity, fenceId, deviceServiceId this@AddAndEditFencesZoneBaseActivity, fenceId, deviceServiceId, modeType
) )
} }
} }

View File

@@ -12,9 +12,11 @@ import com.abbidot.baselibrary.eventbus.XEventBus
import com.abbidot.baselibrary.util.MMKVUtil import com.abbidot.baselibrary.util.MMKVUtil
import com.abbidot.tracker.R import com.abbidot.tracker.R
import com.abbidot.tracker.base.BaseActivity import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.bean.FencesBean import com.abbidot.tracker.bean.FencesBean
import com.abbidot.tracker.bean.GetFencesBean import com.abbidot.tracker.bean.GetFencesBean
import com.abbidot.tracker.bean.PetBean import com.abbidot.tracker.bean.PetBean
import com.abbidot.tracker.bean.ReceiveDeviceData
import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.constant.GetResultCallback import com.abbidot.tracker.constant.GetResultCallback
@@ -22,9 +24,11 @@ import com.abbidot.tracker.databinding.ActivityPreviewFencesZoneBinding
import com.abbidot.tracker.ui.common.map.PreviewFencesZoneCommon import com.abbidot.tracker.ui.common.map.PreviewFencesZoneCommon
import com.abbidot.tracker.util.Util import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
import com.abbidot.tracker.util.bluetooth.SRBleUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.vm.FencesManageViewModel import com.abbidot.tracker.vm.FencesManageViewModel
import com.abbidot.tracker.vm.FencesMapViewModel import com.abbidot.tracker.vm.FencesMapViewModel
import com.clj.fastble.BleManager
import com.daimajia.androidanimations.library.Techniques import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo import com.daimajia.androidanimations.library.YoYo
@@ -46,13 +50,13 @@ class PreviewFencesZoneActivity :
private lateinit var mPreviewFencesMapCommon: PreviewFencesZoneCommon private lateinit var mPreviewFencesMapCommon: PreviewFencesZoneCommon
private var mShowCenterLocationType = ConstantInt.OtherLocationType private var mShowCenterLocationType = ConstantInt.OtherLocationType
//是否是当前页面删除,放在重复收到本页面删除通知
private var isCurrentActivityDelete = false
//是否是卫星地图 //是否是卫星地图
private var isSatelliteMap = false private var isSatelliteMap = false
private lateinit var mFencesList: MutableList<FencesBean> private lateinit var mFencesList: MutableList<FencesBean>
//操作类型0增加1编辑2删除
private var mActionType = ConstantInt.Type1
override fun getTopBar() = mViewBinding.previewFencesZoneTopBar.titleTopBar override fun getTopBar() = mViewBinding.previewFencesZoneTopBar.titleTopBar
override fun initData() { override fun initData() {
@@ -149,14 +153,14 @@ class PreviewFencesZoneActivity :
mViewBinding.cbPreviewFencesSwitch.isChecked = mViewBinding.cbPreviewFencesSwitch.isChecked =
!mViewBinding.cbPreviewFencesSwitch.isChecked !mViewBinding.cbPreviewFencesSwitch.isChecked
showToast(R.string.txt_change_successful, gravity = Gravity.CENTER) showToast(R.string.txt_change_successful, gravity = Gravity.CENTER)
mCurrentFences?.apply { // mCurrentFences?.apply {
isOn = // isOn =
if (mViewBinding.cbPreviewFencesSwitch.isChecked) ConstantInt.Open else ConstantInt.Close // if (mViewBinding.cbPreviewFencesSwitch.isChecked) ConstantInt.Open else ConstantInt.Close
mFencesManageViewModel.getFenceList( //
this@PreviewFencesZoneActivity, mCurrentDeviceId // }
) mFencesManageViewModel.getFenceList(
sendFenceData() this@PreviewFencesZoneActivity, mCurrentDeviceId
} )
} }
}) })
} }
@@ -164,10 +168,6 @@ class PreviewFencesZoneActivity :
mFencesManageViewModel.mDeleteFenceLiveData.observe(this) { mFencesManageViewModel.mDeleteFenceLiveData.observe(this) {
dealRequestResult(it, object : GetResultCallback { dealRequestResult(it, object : GetResultCallback {
override fun onResult(any: Any) { override fun onResult(any: Any) {
isCurrentActivityDelete = true
//删除蓝牙标志
mCurrentFences?.isOn = ConstantInt.Type2
sendFenceData()
XEventBus.post(EventName.DeleteFences) XEventBus.post(EventName.DeleteFences)
showToast(R.string.txt_delete_success, true, gravity = Gravity.CENTER) showToast(R.string.txt_delete_success, true, gravity = Gravity.CENTER)
} }
@@ -183,7 +183,47 @@ class PreviewFencesZoneActivity :
//接收删除围栏返回通知 //接收删除围栏返回通知
XEventBus.observe(this, EventName.DeleteFences) { XEventBus.observe(this, EventName.DeleteFences) {
if (!isCurrentActivityDelete) finish() //是否是当前页面删除,放在重复收到本页面删除通知
if (!isFrontRunning) finish()
}
//接收发送指令后设备返回的数据
XEventBus.observe(this, EventName.DeviceReceiveData) { receive: ReceiveDeviceData ->
mPetBean?.let {
//防止编辑围栏页面,重复执行
if (it.macID == receive.mac && isFrontRunning) {
val data = receive.data
parseData(data)
}
}
}
}
private fun parseData(data: ByteArray?) {
data?.apply {
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
//围栏设置
if (data0 == 0x13 && data1 == 1) {
mCurrentFences?.let {
if (data2 == 0) {
//成功
it.modeType = ConstantInt.Type1
when (mActionType) {
ConstantInt.Type1 -> changeOnNetAndOff(it)
ConstantInt.Type2 -> deleteNetFences()
}
} else {
//失败
it.modeType = ConstantInt.Type3
when (mActionType) {
ConstantInt.Type1 -> changeOnNetAndOff(it)
ConstantInt.Type2 -> deleteNetFences()
}
}
}
}
} }
} }
@@ -193,7 +233,9 @@ class PreviewFencesZoneActivity :
private fun sendFenceData() { private fun sendFenceData() {
mPetBean?.apply { mPetBean?.apply {
mCurrentFences?.apply { mCurrentFences?.apply {
SRBleUtil.instance.isConnectBleSendFenceData(macID, this) SRBleUtil.instance.isConnectBleSendCmdData(
macID, SRBleCmdUtil.instance.setFences(this)
)
} }
} }
} }
@@ -274,6 +316,24 @@ class PreviewFencesZoneActivity :
} else { } else {
ConstantInt.Open ConstantInt.Open
} }
mPetBean?.let {
mActionType = ConstantInt.Type1
if (modeType == ConstantInt.Type3) fencesBean.modeType = ConstantInt.Type3
else if (BleManager.getInstance().isConnected(it.macID)) {
sendFenceData()
} else {
fencesBean.modeType = ConstantInt.Type2
changeOnNetAndOff(fencesBean)
}
}
}
}
/**
* 修改开关状态
*/
private fun changeOnNetAndOff(fencesBean: FencesBean) {
fencesBean.apply {
when (fenceShapeType) { when (fenceShapeType) {
ConstantInt.CircleShapeType -> { ConstantInt.CircleShapeType -> {
mFencesManageViewModel.updateCircleFence( mFencesManageViewModel.updateCircleFence(
@@ -302,9 +362,36 @@ class PreviewFencesZoneActivity :
* 删除围栏 * 删除围栏
*/ */
private fun deleteFences() { private fun deleteFences() {
ViewUtil.instance.showDialog(
this, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener {
override fun onOkClick(dialog: BaseDialog<*>) {
dialog.dismiss()
mPetBean?.let {
mCurrentFences?.apply {
mActionType = ConstantInt.Type2
if (modeType == ConstantInt.Type3) modeType = ConstantInt.Type3
else if (BleManager.getInstance().isConnected(it.macID)) {
//删除蓝牙标志
isOn = ConstantInt.Type2
sendFenceData()
} else {
modeType = ConstantInt.Type2
deleteNetFences()
}
}
}
}
}, okTextResId = R.string.txt_sure
)
}
/**
* 删除围栏
*/
private fun deleteNetFences() {
mCurrentFences?.apply { mCurrentFences?.apply {
mFencesManageViewModel.deleteFence( mFencesManageViewModel.deleteFence(
this@PreviewFencesZoneActivity, fenceId, deviceServiceId this@PreviewFencesZoneActivity, fenceId, deviceServiceId, modeType
) )
} }
} }

View File

@@ -7,6 +7,7 @@ import com.abbidot.baselibrary.constant.EventName
import com.abbidot.baselibrary.constant.MMKVKey import com.abbidot.baselibrary.constant.MMKVKey
import com.abbidot.baselibrary.eventbus.XEventBus import com.abbidot.baselibrary.eventbus.XEventBus
import com.abbidot.baselibrary.list.BaseRecyclerAdapter import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.util.LogUtil
import com.abbidot.baselibrary.util.MMKVUtil import com.abbidot.baselibrary.util.MMKVUtil
import com.abbidot.tracker.R import com.abbidot.tracker.R
import com.abbidot.tracker.adapter.FencesZoneAdapter import com.abbidot.tracker.adapter.FencesZoneAdapter
@@ -14,13 +15,17 @@ import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.bean.FencesBean import com.abbidot.tracker.bean.FencesBean
import com.abbidot.tracker.bean.GetFencesBean import com.abbidot.tracker.bean.GetFencesBean
import com.abbidot.tracker.bean.PetBean import com.abbidot.tracker.bean.PetBean
import com.abbidot.tracker.bean.ReceiveDeviceData
import com.abbidot.tracker.constant.ConstantInt import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.constant.GetResultCallback import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.databinding.ActivityVirtualFencesBinding import com.abbidot.tracker.databinding.ActivityVirtualFencesBinding
import com.abbidot.tracker.util.Util import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.vm.FencesManageViewModel import com.abbidot.tracker.vm.FencesManageViewModel
import com.clj.fastble.BleManager
import com.qmuiteam.qmui.util.QMUIDisplayHelper import com.qmuiteam.qmui.util.QMUIDisplayHelper
/** /**
@@ -39,6 +44,9 @@ class VirtualFencesActivity :
private var mPetBean: PetBean? = null private var mPetBean: PetBean? = null
private var mGetFencesBean: GetFencesBean? = null private var mGetFencesBean: GetFencesBean? = null
//需要同步设备的围栏数据
private lateinit var mNeedSyncFencesList: MutableList<FencesBean>
override fun getTopBar() = mViewBinding.virtualFencesTopBar.titleTopBar override fun getTopBar() = mViewBinding.virtualFencesTopBar.titleTopBar
override fun initData() { override fun initData() {
@@ -49,6 +57,7 @@ class VirtualFencesActivity :
mFencesList = mutableListOf() mFencesList = mutableListOf()
mFencesNoGoList = mutableListOf() mFencesNoGoList = mutableListOf()
mNeedSyncFencesList = mutableListOf()
mViewBinding.apply { mViewBinding.apply {
@@ -135,6 +144,17 @@ class VirtualFencesActivity :
mFencesNoGoAdapter.showNoDataAddButton(false) mFencesNoGoAdapter.showNoDataAddButton(false)
} }
} }
//接收发送指令后设备返回的数据
XEventBus.observe(this, EventName.DeviceReceiveData) { receive: ReceiveDeviceData ->
mPetBean?.let {
//防止编辑围栏,重复执行
if (it.macID == receive.mac && isFrontRunning) {
val data = receive.data
parseData(data)
}
}
}
} }
private fun setFencesData(getFencesBean: GetFencesBean) { private fun setFencesData(getFencesBean: GetFencesBean) {
@@ -193,6 +213,118 @@ class VirtualFencesActivity :
val countString = String.format(getString(R.string.txt_fences_set), "$fencesCount/5") val countString = String.format(getString(R.string.txt_fences_set), "$fencesCount/5")
tvVirtualFencesCount.text = countString tvVirtualFencesCount.text = countString
} }
mPetBean?.apply {
if (BleManager.getInstance().isConnected(macID)) {
showNoCancelableLoading(true, getString(R.string.txt_synchronized_data))
SRBleUtil.instance.isConnectBleSendCmdData(macID, SRBleCmdUtil.instance.getFences())
}
}
}
private fun parseData(data: ByteArray?) {
data?.apply {
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
if (data0 == 0x13) {
if (data1 == 0) {
//围栏查询
verifyBleFences(data2, sliceArray(3..size - 2))
} else if (data1 == 1 && data2 == 0) {
//围栏设置
mNeedSyncFencesList.removeAt(0)
if (mNeedSyncFencesList.size > 0) {
mPetBean?.apply {
SRBleUtil.instance.isConnectBleSendCmdData(
macID, SRBleCmdUtil.instance.setFences(mNeedSyncFencesList[0])
)
}
} else {
showNoCancelableLoading(false)
}
} else {
showNoCancelableLoading(false)
}
}
}
}
/**
* 检验设备里的围栏
*/
private fun verifyBleFences(bleFencesCount: Int, data: ByteArray) {
val bleFencesIdList = mutableListOf<String>()
mNeedSyncFencesList.clear()
//先把设备里存在的,服务器不存在的删除
for (i in 0 until bleFencesCount) {
//是否存在设备里的围栏id
var bleFencesIdExist = false
val step = i * 4
val fenceId = data.sliceArray(step..step + 3).toHexString()
bleFencesIdList.add(fenceId)
for (fence in mFencesList) {
if (fence.fenceId.takeLast(8) == fenceId) {
bleFencesIdExist = true
break
}
}
if (!bleFencesIdExist) {
for (fence in mFencesNoGoList) {
if (fence.fenceId.takeLast(8) == fenceId) {
bleFencesIdExist = true
break
}
}
}
if (!bleFencesIdExist) {
FencesBean().apply {
this.fenceId = fenceId
//删除
isOn = ConstantInt.Type2
mNeedSyncFencesList.add(this)
}
}
}
for (fence in mFencesList) {
//是否存在服务器里的围栏id
var serverFencesIdExist = false
for (bleFenceId in bleFencesIdList) {
if (fence.fenceId.takeLast(8) == bleFenceId) {
serverFencesIdExist = true
break
}
}
if (!serverFencesIdExist) {
mNeedSyncFencesList.add(fence)
}
}
for (fence in mFencesNoGoList) {
//是否存在服务器里的围栏id
var serverFencesIdExist = false
for (bleFenceId in bleFencesIdList) {
if (fence.fenceId.takeLast(8) == bleFenceId) {
serverFencesIdExist = true
break
}
}
if (!serverFencesIdExist) {
mNeedSyncFencesList.add(fence)
}
}
LogUtil.e("需要同步的围栏个数:${mNeedSyncFencesList.size}")
for (a in mNeedSyncFencesList) LogUtil.e(a.toString())
if (mNeedSyncFencesList.size > 0) {
mPetBean?.apply {
SRBleUtil.instance.isConnectBleSendCmdData(
macID, SRBleCmdUtil.instance.setFences(mNeedSyncFencesList[0])
)
}
} else {
showNoCancelableLoading(false)
}
} }
private fun goPreviewFencesZone(fencesBean: FencesBean) { private fun goPreviewFencesZone(fencesBean: FencesBean) {

View File

@@ -202,7 +202,9 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
// XEventBus.post(EventName.UpdateData + "TrackerManageSetActivity") // XEventBus.post(EventName.UpdateData + "TrackerManageSetActivity")
// XEventBus.post(EventName.UpdateData + "TrackerManageFragment") // XEventBus.post(EventName.UpdateData + "TrackerManageFragment")
mPetBean?.apply { mPetBean?.apply {
SRBleUtil.instance.isConnectBleSendNotifyData(macID) SRBleUtil.instance.isConnectBleSendCmdData(
macID, SRBleCmdUtil.instance.setNotifySyncData()
)
} }
showToast(R.string.txt_change_successful, isFinish = true) showToast(R.string.txt_change_successful, isFinish = true)
} }

View File

@@ -15,6 +15,7 @@ import com.abbidot.tracker.constant.GetResultCallback
import com.abbidot.tracker.databinding.ActivityTrackingDurationSetBinding import com.abbidot.tracker.databinding.ActivityTrackingDurationSetBinding
import com.abbidot.tracker.util.Util import com.abbidot.tracker.util.Util
import com.abbidot.tracker.util.ViewUtil import com.abbidot.tracker.util.ViewUtil
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
import com.abbidot.tracker.util.bluetooth.SRBleUtil import com.abbidot.tracker.util.bluetooth.SRBleUtil
import com.abbidot.tracker.vm.TrackerSetViewModel import com.abbidot.tracker.vm.TrackerSetViewModel
@@ -61,7 +62,9 @@ class TrackingDurationSetActivity :
mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex
) )
mMapDeviceBean?.apply { mMapDeviceBean?.apply {
SRBleUtil.instance.isConnectBleSendNotifyData(deviceMacId) SRBleUtil.instance.isConnectBleSendCmdData(
deviceMacId, SRBleCmdUtil.instance.setNotifySyncData()
)
} }
} }
}) })

View File

@@ -73,4 +73,5 @@ class PaymentMethodActivity :
finish() finish()
} }
} }
} }

View File

@@ -62,7 +62,7 @@ class PaymentSuccessActivity :
mViewBinding.apply { mViewBinding.apply {
ivPaymentSuccessAnim.load(R.drawable.pwd_reset_successful_done) ivPaymentSuccessAnim.load(R.drawable.pwd_reset_successful_done)
mPayResult?.let { mPayResult?.let {
LogUtil.e("充值类型rechargeType=${it.rechargeType}")
// if (it.rechargeType == ConstantInt.Type0) { // if (it.rechargeType == ConstantInt.Type0) {
// btnPaymentSuccessContinue.setText(R.string.txt_continue) // btnPaymentSuccessContinue.setText(R.string.txt_continue)
// } // }
@@ -89,6 +89,8 @@ class PaymentSuccessActivity :
mMac = MMKVUtil.getString(MMKVKey.FirstDeviceMac) mMac = MMKVUtil.getString(MMKVKey.FirstDeviceMac)
if (TextUtils.isEmpty(mMac)) { if (TextUtils.isEmpty(mMac)) {
btnPaymentSuccessContinue.setText(R.string.txt_continue)
tvPaymentSuccessActivateTip.visibility = View.INVISIBLE
ilPaymentSuccessBluetoothTips.root.visibility = View.GONE ilPaymentSuccessBluetoothTips.root.visibility = View.GONE
} else { } else {
connectBle(mMac) connectBle(mMac)
@@ -177,7 +179,7 @@ class PaymentSuccessActivity :
pet.deviceId = mPayResult!!.deviceId pet.deviceId = mPayResult!!.deviceId
pet.petType = ConstantInt.DogPetType pet.petType = ConstantInt.DogPetType
pet.gender = ConstantInt.WoMan pet.gender = ConstantInt.WoMan
pet.macID=mMac pet.macID = mMac
pet.birthdayDate = "2024-01-01" pet.birthdayDate = "2024-01-01"
pet.height = Utils.formatDecimal(Util.inToCm(20.0), 1).toFloat() pet.height = Utils.formatDecimal(Util.inToCm(20.0), 1).toFloat()
pet.weight = Utils.formatDecimal(Util.lbsToKg(25.0), 1).toFloat() pet.weight = Utils.formatDecimal(Util.lbsToKg(25.0), 1).toFloat()
@@ -232,6 +234,7 @@ class PaymentSuccessActivity :
val data1 = SRBleCmdUtil.instance.byteToInt(data[1]) val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
val data2 = SRBleCmdUtil.instance.byteToInt(data[2]) val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
if (data0 == 0x1A && data1 == 1 && data2 == 0) { if (data0 == 0x1A && data1 == 1 && data2 == 0) {
MMKVUtil.putString(MMKVKey.FirstDeviceMac, "")
XEventBus.post(EventName.PayBack) XEventBus.post(EventName.PayBack)
mPayResult?.let { mPayResult?.let {
if (it.rechargeType == ConstantInt.Type0) { if (it.rechargeType == ConstantInt.Type0) {
@@ -288,7 +291,10 @@ class PaymentSuccessActivity :
) )
btnPaymentSuccessContinue -> { btnPaymentSuccessContinue -> {
SRBleUtil.instance.getConnectMacDevice(mMac)?.let { if (TextUtils.isEmpty(mMac)) {
XEventBus.post(EventName.PayBack)
finish()
} else SRBleUtil.instance.getConnectMacDevice(mMac)?.let {
setButtonEnabled( setButtonEnabled(
mViewBinding.btnPaymentSuccessContinue, ConstantInt.Type0 mViewBinding.btnPaymentSuccessContinue, ConstantInt.Type0
) )

View File

@@ -50,7 +50,7 @@ class SubscriptionDetailActivity :
it.name it.name
} }
tvSubscribeDetailRenewYear.text = tvSubscribeDetailRenewYear.text =
String.format(mContext.getString(R.string.txt_renew_year), it.accountFee) String.format(mContext.getString(R.string.txt_renew_year), "${it.accountFee}")
tvSubscribeDetailRenewsOn.text = tvSubscribeDetailRenewsOn.text =
Utils.formatTime(it.createdDate.toLong(), Utils.DATE_FORMAT_PATTERN_EN6) Utils.formatTime(it.createdDate.toLong(), Utils.DATE_FORMAT_PATTERN_EN6)
} }

View File

@@ -50,6 +50,7 @@ class SubscriptionPlanActivity :
intent, ConstantString.LkSetMeal, SubscriptionsOrderBean::class.java intent, ConstantString.LkSetMeal, SubscriptionsOrderBean::class.java
) )
val isFirstBind = getBoolean(ConstantString.isFirstBind, false) val isFirstBind = getBoolean(ConstantString.isFirstBind, false)
mRechargeType = getInt(ConstantString.RechargeType, ConstantInt.Type1)
if (isFirstBind) mRechargeType = ConstantInt.Type0 if (isFirstBind) mRechargeType = ConstantInt.Type0
} }

View File

@@ -75,19 +75,19 @@ class HistoryDataMapCommon : BaseMapCommon() {
} }
} }
fun addSetLine() { fun addSetLine(isMoveCamera: Boolean = true) {
if (null != mHistoryDataBaiduMapFragment) { if (null != mHistoryDataBaiduMapFragment) {
mHistoryDataBaiduMapFragment!!.addSetLine() mHistoryDataBaiduMapFragment!!.addSetLine()
} else if (null != mHistoryDataGoogleMapFragment) { } else if (null != mHistoryDataGoogleMapFragment) {
mHistoryDataGoogleMapFragment!!.addSetLine() mHistoryDataGoogleMapFragment!!.addSetLine(isMoveCamera)
} }
} }
fun addSetNumber() { fun addSetNumber(isMoveCamera: Boolean = true) {
if (null != mHistoryDataBaiduMapFragment) { if (null != mHistoryDataBaiduMapFragment) {
mHistoryDataBaiduMapFragment!!.addSetNumber() mHistoryDataBaiduMapFragment!!.addSetNumber()
} else if (null != mHistoryDataGoogleMapFragment) { } else if (null != mHistoryDataGoogleMapFragment) {
mHistoryDataGoogleMapFragment!!.addSetNumber() mHistoryDataGoogleMapFragment!!.addSetNumber(isMoveCamera)
} }
} }

View File

@@ -84,7 +84,9 @@ class HomeMapCommon @Inject constructor() : BaseMapCommon() {
MMKVUtil.putDouble(MMKVKey.MapShowDefaultLon, longitude) MMKVUtil.putDouble(MMKVKey.MapShowDefaultLon, longitude)
mHomeMapGoogleMapFragment?.apply { mHomeMapGoogleMapFragment?.apply {
refreshPetCurrentLocation( refreshPetCurrentLocation(
LatLng(latitude, longitude), isAnimMoveCamera = isAnimMoveCamera LatLng(latitude, longitude),
isAnimMoveCamera = isAnimMoveCamera,
needMoveCamera = isAnimMoveCamera
) )
} }
} }

View File

@@ -97,6 +97,9 @@ class AccountV2Fragment :
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activity?.apply {
mHomeV2Activity = this as HomeV2Activity
}
mNotificationsViewModel.getMessageList(mHomeV2Activity) mNotificationsViewModel.getMessageList(mHomeV2Activity)
} }

View File

@@ -138,7 +138,9 @@ class ActivityV2Fragment :
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activity?.apply {
mHomeV2Activity = this as HomeV2Activity
}
if (mCurrentShowPetPos == mHomeV2Activity.mSelectPetPosition) { if (mCurrentShowPetPos == mHomeV2Activity.mSelectPetPosition) {
mHomeV2Activity.getPet()?.apply { mHomeV2Activity.getPet()?.apply {
mDataViewModel.getHomeDeviceData(deviceId, mToday, petId) mDataViewModel.getHomeDeviceData(deviceId, mToday, petId)

View File

@@ -179,13 +179,13 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
}) })
mViewBinding.rgHistoryRouteMapTrackType.setOnCheckedChangeListener { _, checkedId -> mViewBinding.rgHistoryRouteMapTrackType.setOnCheckedChangeListener { _, checkedId ->
mViewBinding.vsbMapRouteLine.progress = mViewBinding.vsbMapRouteLine.max // mViewBinding.vsbMapRouteLine.progress = mViewBinding.vsbMapRouteLine.max
when (checkedId) { when (checkedId) {
mViewBinding.rbHistoryRouteMapLine.id -> { mViewBinding.rbHistoryRouteMapLine.id -> {
MMKVUtil.putInt(MMKVKey.LineSelectPosition, ConstantInt.Line) MMKVUtil.putInt(MMKVKey.LineSelectPosition, ConstantInt.Line)
mHistoryDataMapCommon.addSetLine() mHistoryDataMapCommon.addSetLine(false)
if (mHistoryDataList.size > 0) { if (mHistoryDataList.size > 0) {
mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1) // mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1)
} else { } else {
showToast(R.string.no_data, gravity = Gravity.CENTER) showToast(R.string.no_data, gravity = Gravity.CENTER)
} }
@@ -193,9 +193,9 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
mViewBinding.rbHistoryRouteMapNumber.id -> { mViewBinding.rbHistoryRouteMapNumber.id -> {
MMKVUtil.putInt(MMKVKey.LineSelectPosition, ConstantInt.Point) MMKVUtil.putInt(MMKVKey.LineSelectPosition, ConstantInt.Point)
mHistoryDataMapCommon.addSetNumber() mHistoryDataMapCommon.addSetNumber(false)
if (mHistoryDataList.size > 0) { if (mHistoryDataList.size > 0) {
mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1) // mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1)
} else { } else {
showToast(R.string.no_data, gravity = Gravity.CENTER) showToast(R.string.no_data, gravity = Gravity.CENTER)
} }
@@ -206,6 +206,9 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activity?.apply {
mHomeV2Activity = this as HomeV2Activity
}
if (mCurrentShowPetPos == mHomeV2Activity.mSelectPetPosition) { if (mCurrentShowPetPos == mHomeV2Activity.mSelectPetPosition) {
if (!isSelectCustomDate) { if (!isSelectCustomDate) {
if (mHistoryDataMapCommon.isMapLoadOk()) { if (mHistoryDataMapCommon.isMapLoadOk()) {

View File

@@ -891,6 +891,9 @@ class HomeTrackFragment :
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activity?.apply {
mHomeV2Activity = this as HomeV2Activity
}
//变量初始化 //变量初始化
if (!::mHomeV2Activity.isInitialized) { if (!::mHomeV2Activity.isInitialized) {
return return

View File

@@ -169,6 +169,9 @@ class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::i
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activity?.apply {
mHomeV2Activity = this as HomeV2Activity
}
//其他页面是否选择了宠物 //其他页面是否选择了宠物
if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) { if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) {
showPetNameAndHead(mHomeV2Activity.mSelectPetPosition) showPetNameAndHead(mHomeV2Activity.mSelectPetPosition)
@@ -275,15 +278,11 @@ class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::i
} }
} }
//接收蓝牙连接状态 //接收蓝牙连接状态
XEventBus.observe( XEventBus.observe(this, EventName.ConnectDeviceState) { trackBle: BleTrackDeviceBean ->
this, EventName.ConnectDeviceState
) { trackBleDevice: BleTrackDeviceBean ->
mHomeV2Activity.getPet(false)?.apply { mHomeV2Activity.getPet(false)?.apply {
if (trackBleDevice.mac == macID) { //蓝牙断开就重新获取服务器数据,蓝牙数据上报断开
//蓝牙断开就重新获取服务器数据,蓝牙数据上报断开 if (trackBle.mac == macID && trackBle.conState != ConState.CONNECTED) {
if (trackBleDevice.conState == ConState.DISCONNECTED) { updateMapDeviceStatus()
updateMapDeviceStatus()
}
} }
} }
} }
@@ -609,6 +608,7 @@ class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::i
homeMapRefreshBtn, mShowCenterLocationType homeMapRefreshBtn, mShowCenterLocationType
) )
} else { } else {
isAnimMoveCamera = true
updateMapDeviceStatus(useBleLocation = true) updateMapDeviceStatus(useBleLocation = true)
} }
} }

View File

@@ -82,7 +82,7 @@ abstract class BaseGoogleMapFragment :
private var mMapviewBundleKey = this.javaClass.simpleName private var mMapviewBundleKey = this.javaClass.simpleName
//地图放大 //地图放大
private var mGoogleMapZoom = 18f private var mGoogleMapZoom = 17f
//地图摄像机移动动画时间 毫秒 //地图摄像机移动动画时间 毫秒
private val mAnimMoveDurationMs = 1000 private val mAnimMoveDurationMs = 1000

View File

@@ -163,6 +163,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
mContext!!, AppUtils.dpToPx(50), LatLng(minLat, minLon), LatLng(maxLat, maxLon) mContext!!, AppUtils.dpToPx(50), LatLng(minLat, minLon), LatLng(maxLat, maxLon)
) )
val maxIndex = data.size - 1
mCurLatLng = mLatLngList[maxIndex]
val type = MMKVUtil.getInt(MMKVKey.LineSelectPosition, ConstantInt.Line) val type = MMKVUtil.getInt(MMKVKey.LineSelectPosition, ConstantInt.Line)
if (type == ConstantInt.Line) { if (type == ConstantInt.Line) {
addSetLine() addSetLine()
@@ -170,12 +173,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
addSetNumber() addSetNumber()
} }
val maxIndex = data.size - 1
mGeoCoderViewModel.getLatLonAddress( mGeoCoderViewModel.getLatLonAddress(
mLatLngList[maxIndex].latitude, mLatLngList[maxIndex].longitude, false mLatLngList[maxIndex].latitude, mLatLngList[maxIndex].longitude, false
) )
mCurLatLng = mLatLngList[maxIndex]
setMarkerInfoViewOffset(mMarkerInfoView, mLatLngList[maxIndex]) setMarkerInfoViewOffset(mMarkerInfoView, mLatLngList[maxIndex])
} }
@@ -191,9 +191,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
*/ */
fun slideStopChanged(progress: Int) { fun slideStopChanged(progress: Int) {
if (mLatLngList.size > 0) { if (mLatLngList.size > 0) {
moveCameraLocation( // moveCameraLocation(
mLatLngList[progress].latitude, mLatLngList[progress].longitude, false // mLatLngList[progress].latitude, mLatLngList[progress].longitude, false
) // )
mGeoCoderViewModel.getLatLonAddress( mGeoCoderViewModel.getLatLonAddress(
mLatLngList[progress].latitude, mLatLngList[progress].longitude, false mLatLngList[progress].latitude, mLatLngList[progress].longitude, false
) )
@@ -211,14 +211,14 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
/** /**
* 画线 * 画线
*/ */
fun addSetLine() { fun addSetLine(isMoveCamera: Boolean = true) {
val size = mLatLngList.size val size = mLatLngList.size
LogUtil.e("画线点有 $size") LogUtil.e("画线点有 $size")
if (size == 0) return if (size == 0) return
mGoogleMap?.let { mGoogleMap?.let {
it.clear() it.clear()
moveCameraUpdate(mLatLngList[size - 1]) if (isMoveCamera) moveCameraUpdate(mLatLngList[size - 1])
addSinglePolyline(it, mLatLngList) addSinglePolyline(it, mLatLngList)
@@ -226,21 +226,23 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
// mLatLngList[size - 1], needMoveCamera = false, isAnimMoveCamera = false // mLatLngList[size - 1], needMoveCamera = false, isAnimMoveCamera = false
// ) // )
setPetMarkerLatLng(mLatLngList[size - 1]) //设置宠物头像和经纬度
if (null == mCurLatLng) setPetMarkerLatLng(mLatLngList[size - 1])
else setPetMarkerLatLng(mCurLatLng!!)
} }
} }
/** /**
* 设置显示数字 * 设置显示数字
*/ */
fun addSetNumber() { fun addSetNumber(isMoveCamera: Boolean = true) {
val size = mLatLngList.size val size = mLatLngList.size
LogUtil.e("轨迹谷歌地图设置显示数字$size,经纬度点") LogUtil.e("轨迹谷歌地图设置显示数字$size,经纬度点")
if (size == 0) return if (size == 0) return
mGoogleMap?.let { mGoogleMap?.let {
it.clear() it.clear()
moveCameraUpdate(mLatLngList[size - 1]) if (isMoveCamera) moveCameraUpdate(mLatLngList[size - 1])
// refreshPetCurrentLocation( // refreshPetCurrentLocation(
// mLatLngList[size - 1], needMoveCamera = false, isAnimMoveCamera = false // mLatLngList[size - 1], needMoveCamera = false, isAnimMoveCamera = false
@@ -260,7 +262,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
it.addMarker(numberMarker) it.addMarker(numberMarker)
} }
setPetMarkerLatLng(mLatLngList[size - 1]) //设置宠物头像和经纬度
if (null == mCurLatLng) setPetMarkerLatLng(mLatLngList[size - 1])
else setPetMarkerLatLng(mCurLatLng!!)
} }
} }
@@ -278,27 +282,4 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
} }
} }
} }
private fun moveCamera(latLng: LatLng) {
// moveAnimateCameraLocation(latLng, object : GoogleMap.CancelableCallback {
// override fun onCancel() {
// LogUtil.e("moveCamera onCancel")
// }
//
// override fun onFinish() {
// LogUtil.e("moveCamera onFinish")
// if (isMapSnapshot) {
// isMapSnapshot = false
// mHistoryDataActivity.mTopBar?.postDelayed({
// if (mHistoryDataActivity.isFrontRunning) {
// mScreenshotsViewModel.getHistoryDataGoogleMapSnapshotImage(
// mContext!!, mGoogleMap!!, mHistoryDataActivity.mPet.deviceId
// )
// }
// }, 1200)
// }
// }
// })
moveAnimateCameraLocation(latLng, null)
}
} }

View File

@@ -117,6 +117,9 @@ class HomePetFragment : BaseFragment<FragmentHomePetBinding>(FragmentHomePetBind
} }
fun getPetAllInfoData() { fun getPetAllInfoData() {
activity?.apply {
mHomeV2Activity = this as HomeV2Activity
}
//变量初始化 //变量初始化
if (!::mHomeV2Activity.isInitialized) { if (!::mHomeV2Activity.isInitialized) {
return return

View File

@@ -84,6 +84,9 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activity?.apply {
mHomeV2Activity = this as HomeV2Activity
}
//其他页面是否选择了宠物 //其他页面是否选择了宠物
if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) { if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) {
showPetNameAndHead(mHomeV2Activity.mSelectPetPosition) showPetNameAndHead(mHomeV2Activity.mSelectPetPosition)

View File

@@ -23,7 +23,7 @@ class SocketUtilManage {
// private val iP = "192.168.0.69" // private val iP = "192.168.0.69"
//默认国外服务器端口 //默认国外服务器端口
private var port = 6868 private var port = 8868
@OptIn(ExperimentalUnsignedTypes::class) @OptIn(ExperimentalUnsignedTypes::class)
private val crcTable = ushortArrayOf( private val crcTable = ushortArrayOf(

View File

@@ -342,5 +342,13 @@ class SRBleCmdUtil private constructor() {
} }
return getCrc8Cmd(byteArray) return getCrc8Cmd(byteArray)
} }
/**
* 查询围栏
*/
fun getFences(): ByteArray {
val byteArray = byteArrayOf(0x13, CMD_READ.toByte(), 0)
return getCrc8Cmd(byteArray)
}
} }

View File

@@ -404,36 +404,16 @@ class SRBleUtil private constructor() {
} }
/** /**
* 发送参数同步提醒消息 0x17 * 发生数据给指定的Mac设备
*/ */
fun isConnectBleSendNotifyData(mac: String) { fun isConnectBleSendCmdData(mac: String, byteArray: ByteArray) {
if (TextUtils.isEmpty(mac)) { if (TextUtils.isEmpty(mac)) {
return return
} }
if (BleManager.getInstance().isConnected(mac)) { if (BleManager.getInstance().isConnected(mac)) {
val trackDeviceBean = getConnectMacDevice(mac) val trackDeviceBean = getConnectMacDevice(mac)
trackDeviceBean?.let { trackDeviceBean?.let {
writeData( writeData(it.bleDevice, byteArray)
it.bleDevice, SRBleCmdUtil.instance.setNotifySyncData()
)
}
}
}
/**
* 发送围栏设置 0x13
*/
fun isConnectBleSendFenceData(mac: String, fencesBean: FencesBean) {
if (TextUtils.isEmpty(mac)) {
return
}
if (BleManager.getInstance().isConnected(mac)) {
val trackDeviceBean = getConnectMacDevice(mac)
trackDeviceBean?.let {
writeData(
it.bleDevice, SRBleCmdUtil.instance.setFences(fencesBean)
)
} }
} }
} }

View File

@@ -3,13 +3,10 @@ package com.abbidot.tracker.vm
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.abbidot.tracker.R
import com.abbidot.tracker.base.BaseActivity import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.base.BaseDialog
import com.abbidot.tracker.bean.FencesBean import com.abbidot.tracker.bean.FencesBean
import com.abbidot.tracker.bean.GetFencesBean import com.abbidot.tracker.bean.GetFencesBean
import com.abbidot.tracker.retrofit2.NetworkApi import com.abbidot.tracker.retrofit2.NetworkApi
import com.abbidot.tracker.util.ViewUtil
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
/** /**
@@ -81,7 +78,8 @@ class FencesManageViewModel : ViewModel() {
ancillaryLatitude, ancillaryLatitude,
ancillaryLongitude, ancillaryLongitude,
ancillaryOtherLatitude, ancillaryOtherLatitude,
ancillaryOtherLongitude ancillaryOtherLongitude,
modeType
) )
mUpdateFenceLiveData.value = result mUpdateFenceLiveData.value = result
} }
@@ -115,7 +113,8 @@ class FencesManageViewModel : ViewModel() {
longitudeCenter, longitudeCenter,
latitudeCenter, latitudeCenter,
longDistance, longDistance,
shortDistance shortDistance,
modeType
) )
mUpdateFenceLiveData.value = result mUpdateFenceLiveData.value = result
} }
@@ -133,18 +132,11 @@ class FencesManageViewModel : ViewModel() {
} }
} }
fun deleteFence(activity: BaseActivity<*>, fenceId: String, deviceServiceId: String) { fun deleteFence(activity: BaseActivity<*>, fenceId: String, deviceServiceId: String,modeType:Int) {
ViewUtil.instance.showDialog( activity.showLoading(true)
activity, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener { viewModelScope.launch {
override fun onOkClick(dialog: BaseDialog<*>) { val result = NetworkApi.removeFence(fenceId, deviceServiceId,modeType)
dialog.dismiss() mDeleteFenceLiveData.value = result
activity.showLoading(true) }
viewModelScope.launch {
val result = NetworkApi.removeFence(fenceId, deviceServiceId)
mDeleteFenceLiveData.value = result
}
}
}, okTextResId = R.string.txt_sure
)
} }
} }

View File

@@ -1027,7 +1027,6 @@
<string name="txt_please_enter_email">Please enter email address.</string> <string name="txt_please_enter_email">Please enter email address.</string>
<string name="txt_wifi_password_dec">Wi-Fi ensures your tracker stays connected when LTE signals are weak.</string> <string name="txt_wifi_password_dec">Wi-Fi ensures your tracker stays connected when LTE signals are weak.</string>
<string name="txt_update_time">Updated: %s</string> <string name="txt_update_time">Updated: %s</string>
<string name="txt_as_low_as">As low as</string> <string name="txt_as_low_as">As low as</string>
<string name="txt_payment_manager">Payment Manager</string> <string name="txt_payment_manager">Payment Manager</string>
<string name="txt_billed_annually">Billed annually</string> <string name="txt_billed_annually">Billed annually</string>
@@ -1042,12 +1041,12 @@
<string name="txt_route_records">Route History Records</string> <string name="txt_route_records">Route History Records</string>
<string name="txt_family_sharing">Family Members Sharing</string> <string name="txt_family_sharing">Family Members Sharing</string>
<string name="txt_customer_support">Premium Customer Support</string> <string name="txt_customer_support">Premium Customer Support</string>
<string name="txt_renewal_years">Renewal: $%s/%s years on %s</string> <string name="txt_renewal_years">Renewal: $%s/%s years on %s</string>
<string name="txt_renewal_months">Renewal: $%s/%s months on %s</string> <string name="txt_renewal_months">Renewal: $%s/%s months on %s</string>
<string name="txt_replacement_year">1 replacement/year, any reason</string> <string name="txt_replacement_year">1 replacement/year, any reason</string>
<string name="txt_expiry_time">Expiry Time:</string> <string name="txt_expiry_time">Expiry Time:</string>
<string name="txt_year_care">%s Year Care</string> <string name="txt_year_care">%s Year Care</string>
<string name="txt_fence_saved">Saved. Active when online.</string> <string name="txt_fence_saved">Saved. Active when online.</string>
<string name="txt_synchronized_data">同步数据中&#8230;</string>
</resources> </resources>