新增蓝牙围栏数据同步下发;修改服务器端口8868
This commit is contained in:
@@ -30,7 +30,7 @@ android {
|
||||
targetSdkVersion 35
|
||||
versionCode 2022
|
||||
// versionName "2.0.22"
|
||||
versionName "2.0.22-Beta2"
|
||||
versionName "2.0.22-Beta4"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class HomeAccountMenuAdapter(
|
||||
private lateinit var mHomeV2Activity: HomeV2Activity
|
||||
private lateinit var mUnitSelectDialog: UnitSelectDialog
|
||||
private val mAccountV2Fragment = accountV2Fragment
|
||||
private var isShowDialog = false
|
||||
|
||||
init {
|
||||
addItemType(MultipleEntity.TEXT, R.layout.item_title_text_type)
|
||||
@@ -131,7 +132,6 @@ class HomeAccountMenuAdapter(
|
||||
mHomeV2Activity.getString(R.string.txt_log_out_tips),
|
||||
position
|
||||
)
|
||||
|
||||
}
|
||||
}, item.menuName
|
||||
)
|
||||
@@ -145,23 +145,36 @@ class HomeAccountMenuAdapter(
|
||||
}
|
||||
|
||||
private fun dialogShowType(type: Int, string: String, pos: Int) {
|
||||
ViewUtil.instance.showDialog(context, string, object : BaseDialog.OnDialogOkListener {
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
dialog.dismiss()
|
||||
when {
|
||||
mLogOutTipsType == type -> {
|
||||
Util.logOut(mHomeV2Activity, mHomeV2Activity.lifecycleScope)
|
||||
}
|
||||
if (isShowDialog) return
|
||||
isShowDialog = true
|
||||
ViewUtil.instance.showDialog(
|
||||
context,
|
||||
string,
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
else -> {
|
||||
// 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()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -131,10 +131,12 @@ class MySubscriptionAdapter(
|
||||
View.VISIBLE
|
||||
} else View.GONE
|
||||
}
|
||||
//充值
|
||||
holder.setClickListener(R.id.btn_my_subscription_recharge) {
|
||||
if (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close) {
|
||||
Intent(mContext, SubscriptionPlanActivity::class.java).let {
|
||||
it.putExtra(ConstantString.LkSetMeal, item)
|
||||
it.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
|
||||
mMySubscriptionActivity.startActivity(it)
|
||||
}
|
||||
} else {
|
||||
@@ -174,6 +176,7 @@ class MySubscriptionAdapter(
|
||||
val intent = Intent(mContext, ChoosePlanActivity::class.java)
|
||||
intent.putExtra(ConstantString.Title, "Premium")
|
||||
intent.putExtra(ConstantString.Upgrade, true)
|
||||
intent.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
|
||||
intent.putExtra(ConstantString.LkSetMeal, item)
|
||||
mMySubscriptionActivity.startActivity(intent)
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听键盘弹出和隐藏,解决键盘弹出隐藏输入框的问题
|
||||
* 监听键盘弹出和隐藏,解决键盘弹出挡住输入框的问题
|
||||
*/
|
||||
fun setListenKeyboardChange(windowTranslateY: Int = 500, view: View = window.decorView) {
|
||||
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) {
|
||||
return
|
||||
}
|
||||
@@ -432,7 +432,6 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
||||
// var message = tip
|
||||
// if (TextUtils.isEmpty(tip)) {
|
||||
// }
|
||||
val message = getString(R.string.txt_loading)
|
||||
mLoadingDialog =
|
||||
QMUITipDialog.Builder(mContext).setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
|
||||
.setTipWord(message).create(false).apply {
|
||||
@@ -567,6 +566,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
||||
getResultCallback.onResult(0)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
finish()
|
||||
LogUtil.e("接口出错造成的异常:${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ abstract class BaseFragment<T : ViewBinding>(
|
||||
liveDataObserve()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 注册监听livedata观察者
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,7 @@ data class FencesBean(
|
||||
var ancillaryOtherLongitude: Double,
|
||||
var longDistance: Int,
|
||||
var shortDistance: Int,
|
||||
var modeType: Int,//数据下发方式 1:纯ble,2:纯wifi,3:ble失败转wifi
|
||||
var startDrag: Boolean//围栏形状是否开始拖动
|
||||
) : Parcelable, BaseDiffBean() {
|
||||
constructor() : this(
|
||||
@@ -53,7 +54,7 @@ data class FencesBean(
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0.0,
|
||||
0.0,
|
||||
@@ -80,6 +81,7 @@ data class FencesBean(
|
||||
0.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
false
|
||||
)
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ class FencesAddActivity : BaseActivity<ActivityFencesAddBinding>(ActivityFencesA
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
dialog.dismiss()
|
||||
mFencesManageViewModel.deleteFence(
|
||||
this@FencesAddActivity, mFenceId, mDeviceServiceId
|
||||
this@FencesAddActivity, mFenceId, mDeviceServiceId, 1
|
||||
)
|
||||
}
|
||||
}, okTextResId = R.string.txt_sure
|
||||
|
||||
@@ -56,6 +56,7 @@ class PackageUpgradeDialog(activity: BaseActivity<*>, deviceId: String) :
|
||||
)
|
||||
intent.putExtra(ConstantString.Upgrade, true)
|
||||
intent.putExtra(ConstantString.LkSetMeal, d)
|
||||
intent.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
|
||||
mBaseActivity.startActivity(intent)
|
||||
dismiss()
|
||||
break
|
||||
|
||||
@@ -359,8 +359,9 @@ interface INetworkService {
|
||||
@Field("ancillaryLatitude") ancillaryLatitude: Double,
|
||||
@Field("ancillaryLongitude") ancillaryLongitude: Double,
|
||||
@Field("ancillaryOtherLatitude") ancillaryOtherLatitude: Double,
|
||||
@Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double
|
||||
// @Field("fenceId") fenceId: String
|
||||
@Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double,
|
||||
@Field("fenceId") fenceId: String,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<FencesBean>
|
||||
|
||||
/**
|
||||
@@ -393,7 +394,9 @@ interface INetworkService {
|
||||
@Field("longitudeCenter") longitudeCenter: Double,
|
||||
@Field("latitudeCenter") latitudeCenter: Double,
|
||||
@Field("longDistance") longDistance: Int,
|
||||
@Field("shortDistance") shortDistance: Int
|
||||
@Field("shortDistance") shortDistance: Int,
|
||||
@Field("fenceId") fenceId: String,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<FencesBean>
|
||||
|
||||
/**
|
||||
@@ -427,6 +430,8 @@ interface INetworkService {
|
||||
@Field("latitudeCenter") latitudeCenter: Double,
|
||||
// @Field("longDistance") longDistance: Double,
|
||||
// @Field("shortDistance") shortDistance: Double
|
||||
@Field("fenceId") fenceId: String,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<FencesBean>
|
||||
|
||||
/**
|
||||
@@ -451,7 +456,8 @@ interface INetworkService {
|
||||
@Field("ancillaryLatitude") ancillaryLatitude: Double,
|
||||
@Field("ancillaryLongitude") ancillaryLongitude: Double,
|
||||
@Field("ancillaryOtherLatitude") ancillaryOtherLatitude: Double,
|
||||
@Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double
|
||||
@Field("ancillaryOtherLongitude") ancillaryOtherLongitude: Double,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
@@ -484,7 +490,8 @@ interface INetworkService {
|
||||
@Field("longitudeCenter") longitudeCenter: Double,
|
||||
@Field("latitudeCenter") latitudeCenter: Double,
|
||||
@Field("longDistance") longDistance: Int,
|
||||
@Field("shortDistance") shortDistance: Int
|
||||
@Field("shortDistance") shortDistance: Int,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
@@ -517,6 +524,7 @@ interface INetworkService {
|
||||
@Field("latitudeF") latitudeF: Double,
|
||||
@Field("longitudeCenter") longitudeCenter: Double,
|
||||
@Field("latitudeCenter") latitudeCenter: Double,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
@@ -524,9 +532,7 @@ interface INetworkService {
|
||||
*/
|
||||
@GET("device$VERSION_NUMBER/getFenceList")
|
||||
suspend fun getFenceList(
|
||||
@Query(
|
||||
"deviceId"
|
||||
) deviceId: String
|
||||
@Query("deviceId") deviceId: String
|
||||
): BaseResponse<GetFencesBean>
|
||||
|
||||
/**
|
||||
@@ -535,7 +541,9 @@ interface INetworkService {
|
||||
@FormUrlEncoded
|
||||
@POST("device/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>
|
||||
|
||||
/**
|
||||
|
||||
@@ -227,7 +227,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
*/
|
||||
suspend fun addCircleFence(fencesBean: FencesBean) = getResult {
|
||||
service.addCircleFence(
|
||||
fencesBean.deviceId, fencesBean.deviceServiceId,
|
||||
fencesBean.deviceId,
|
||||
fencesBean.deviceServiceId,
|
||||
fencesBean.name,
|
||||
fencesBean.address,
|
||||
"",
|
||||
@@ -242,6 +243,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
fencesBean.ancillaryLongitude,
|
||||
fencesBean.ancillaryOtherLatitude,
|
||||
fencesBean.ancillaryOtherLongitude,
|
||||
fencesBean.fenceId,
|
||||
fencesBean.modeType
|
||||
)
|
||||
}
|
||||
|
||||
@@ -270,7 +273,9 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
fencesBean.longitudeCenter,
|
||||
fencesBean.latitudeCenter,
|
||||
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 {
|
||||
service.addPolygonFence(
|
||||
fencesBean.deviceId, fencesBean.deviceServiceId,
|
||||
fencesBean.deviceId,
|
||||
fencesBean.deviceServiceId,
|
||||
fencesBean.name,
|
||||
fencesBean.address,
|
||||
"",
|
||||
@@ -301,6 +307,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
fencesBean.latitudeF,
|
||||
fencesBean.longitudeCenter,
|
||||
fencesBean.latitudeCenter,
|
||||
fencesBean.fenceId,
|
||||
fencesBean.modeType
|
||||
)
|
||||
}
|
||||
|
||||
@@ -323,7 +331,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
ancillaryLatitude: Double,
|
||||
ancillaryLongitude: Double,
|
||||
ancillaryOtherLatitude: Double,
|
||||
ancillaryOtherLongitude: Double
|
||||
ancillaryOtherLongitude: Double,
|
||||
modeType: Int
|
||||
) = getResult {
|
||||
service.updateCircleFence(
|
||||
deviceId,
|
||||
@@ -342,7 +351,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
ancillaryLatitude,
|
||||
ancillaryLongitude,
|
||||
ancillaryOtherLatitude,
|
||||
ancillaryOtherLongitude
|
||||
ancillaryOtherLongitude,
|
||||
modeType
|
||||
)
|
||||
}
|
||||
|
||||
@@ -370,7 +380,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
longitudeCenter: Double,
|
||||
latitudeCenter: Double,
|
||||
longDistance: Int,
|
||||
shortDistance: Int
|
||||
shortDistance: Int,
|
||||
modeType: Int
|
||||
) = getResult {
|
||||
service.updateRectFence(
|
||||
deviceId,
|
||||
@@ -394,7 +405,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
longitudeCenter,
|
||||
latitudeCenter,
|
||||
longDistance,
|
||||
shortDistance
|
||||
shortDistance,
|
||||
modeType
|
||||
)
|
||||
}
|
||||
|
||||
@@ -403,7 +415,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
*/
|
||||
suspend fun updatePolygonFence(fencesBean: FencesBean) = getResult {
|
||||
service.updatePolygonFence(
|
||||
fencesBean.deviceId, fencesBean.deviceServiceId,
|
||||
fencesBean.deviceId,
|
||||
fencesBean.deviceServiceId,
|
||||
fencesBean.fenceId,
|
||||
fencesBean.name,
|
||||
fencesBean.address,
|
||||
@@ -426,6 +439,7 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
fencesBean.latitudeF,
|
||||
fencesBean.longitudeCenter,
|
||||
fencesBean.latitudeCenter,
|
||||
fencesBean.modeType
|
||||
)
|
||||
}
|
||||
|
||||
@@ -439,8 +453,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
/**
|
||||
* 移除围栏
|
||||
*/
|
||||
suspend fun removeFence(fenceId: String, deviceServiceId: String) = getResult {
|
||||
service.removeFence(fenceId, deviceServiceId)
|
||||
suspend fun removeFence(fenceId: String, deviceServiceId: String,modeType:Int) = getResult {
|
||||
service.removeFence(fenceId, deviceServiceId,modeType)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -321,6 +321,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
mContext, SubscriptionPlanActivity::class.java
|
||||
).let { i ->
|
||||
i.putExtra(ConstantString.LkSetMeal, l)
|
||||
i.putExtra(ConstantString.RechargeType, ConstantInt.Type2)
|
||||
startActivity(i)
|
||||
}
|
||||
break
|
||||
|
||||
@@ -24,6 +24,9 @@ class AddNewTracker2Activity :
|
||||
private var isFirstBind = false
|
||||
private lateinit var mScanDeviceList: ArrayList<DataBean>
|
||||
|
||||
//第一次没扫地设备,继续第二次
|
||||
private var againScan = true
|
||||
|
||||
override fun getTopBar() = mViewBinding.ilAddNewTracker2TopBar.titleTopBar
|
||||
|
||||
override fun initData() {
|
||||
@@ -56,7 +59,7 @@ class AddNewTracker2Activity :
|
||||
|
||||
mScanDeviceList.clear()
|
||||
// 扫描超时时间,可选
|
||||
val scanRuleConfig = BleScanRuleConfig.Builder().setScanTimeOut(15000).build()
|
||||
val scanRuleConfig = BleScanRuleConfig.Builder().setScanTimeOut(3000).build()
|
||||
BleManager.getInstance().initScanRule(scanRuleConfig)
|
||||
BleManager.getInstance().scan(object : BleScanCallback() {
|
||||
override fun onScanStarted(success: Boolean) {
|
||||
@@ -66,7 +69,7 @@ class AddNewTracker2Activity :
|
||||
override fun onScanning(bleDevice: BleDevice?) {
|
||||
LogUtil.d("onScanning....$bleDevice")
|
||||
bleDevice?.apply {
|
||||
if (null != name && name.contains("Pet_Tracker")) {
|
||||
if (null != name && name.contains(SRBleUtil.instance.trackDeviceBleStartName)) {
|
||||
val start = 45
|
||||
val end = start + 6
|
||||
val subArray = scanRecord.sliceArray(start until end)
|
||||
@@ -88,6 +91,12 @@ class AddNewTracker2Activity :
|
||||
}
|
||||
|
||||
private fun scanFinished() {
|
||||
if (againScan && mScanDeviceList.size == 0) {
|
||||
againScan = false
|
||||
LogUtil.e("没有扫描到设备,再次重试")
|
||||
startScanBle()
|
||||
return
|
||||
}
|
||||
if (mScanDeviceList.size > 0) {
|
||||
val intent = Intent(mContext, AddNewTracker3Activity::class.java)
|
||||
intent.putParcelableArrayListExtra(ConstantString.DeviceInfo, mScanDeviceList)
|
||||
@@ -95,11 +104,13 @@ class AddNewTracker2Activity :
|
||||
startActivityFinish(intent)
|
||||
} else {
|
||||
mViewBinding.lavAddNewTracker2Lottie.visibility = View.GONE
|
||||
ViewUtil.instance.showDialog(mContext,
|
||||
ViewUtil.instance.showDialog(
|
||||
mContext,
|
||||
R.string.txt_no_search_device,
|
||||
object : BaseDialog.OnDialogOkListener {
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
dialog.dismiss()
|
||||
againScan = true
|
||||
mViewBinding.lavAddNewTracker2Lottie.visibility = View.VISIBLE
|
||||
startScanBle()
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@ import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.adapter.SelectFencesTypeCardShadeAdapter
|
||||
import com.abbidot.tracker.adapter.VirtualFencesZoneShadeAdapter
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.base.BaseDialog
|
||||
import com.abbidot.tracker.bean.DataBean
|
||||
import com.abbidot.tracker.bean.FencesBean
|
||||
import com.abbidot.tracker.bean.GetFencesBean
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
import com.abbidot.tracker.bean.ReceiveDeviceData
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
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.util.Util
|
||||
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.FencesMapViewModel
|
||||
@@ -37,6 +40,7 @@ import com.abbidot.tracker.vm.GeoCoderViewModel
|
||||
import com.abbidot.tracker.widget.OnCircleViewScaleClickListener
|
||||
import com.abbidot.tracker.widget.OnPolygonViewPointPullClickListener
|
||||
import com.abbidot.tracker.widget.OnRectViewRotateScaleClickListener
|
||||
import com.clj.fastble.BleManager
|
||||
import com.daimajia.androidanimations.library.Techniques
|
||||
import com.daimajia.androidanimations.library.YoYo
|
||||
|
||||
@@ -77,6 +81,9 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
|
||||
private lateinit var mDistanceUnit: String
|
||||
|
||||
//操作类型,0增加,1编辑,2删除
|
||||
private var mActionType = ConstantInt.Type0
|
||||
|
||||
override fun getTopBar() = mViewBinding.addEditFencesZoneTopBar.titleTopBar
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@@ -270,6 +277,44 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
// 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 {
|
||||
override fun onResult(any: Any) {
|
||||
it.getOrNull()?.apply {
|
||||
// sendNotifyData()
|
||||
mFencesBean.fenceId = fenceId
|
||||
sendFenceData()
|
||||
successTips(R.string.txt_fence_saved)
|
||||
//ble失败
|
||||
if (mFencesBean.modeType == ConstantInt.Type3) {
|
||||
successTips()
|
||||
} 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() {
|
||||
mFencesManageViewModel.mDeleteFenceLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
XEventBus.post(EventName.DeleteFences)
|
||||
// sendNotifyData()
|
||||
//删除蓝牙标志
|
||||
mFencesBean.isOn = ConstantInt.Type2
|
||||
sendFenceData()
|
||||
showToast(
|
||||
R.string.txt_delete_success, isFinish = true, gravity = Gravity.CENTER
|
||||
)
|
||||
@@ -334,33 +385,32 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
mFencesManageViewModel.mUpdateFenceLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
// sendNotifyData()
|
||||
sendFenceData()
|
||||
successTips(R.string.txt_fence_saved)
|
||||
//失败
|
||||
if (mFencesBean.modeType == ConstantInt.Type3) {
|
||||
successTips()
|
||||
} else {
|
||||
successTips(R.string.txt_save_successful)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendNotifyData() {
|
||||
mPetBean?.apply {
|
||||
SRBleUtil.instance.isConnectBleSendNotifyData(macID)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送围栏数据
|
||||
*/
|
||||
private fun sendFenceData() {
|
||||
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)
|
||||
showToast(resStringId, isFinish = true, gravity = Gravity.CENTER)
|
||||
}
|
||||
@@ -598,6 +648,12 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
return
|
||||
}
|
||||
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)
|
||||
name = fenceName
|
||||
when (fenceShapeType) {
|
||||
@@ -626,6 +682,26 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
* 更新围栏
|
||||
*/
|
||||
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()
|
||||
if (TextUtils.isEmpty(fenceName)) {
|
||||
showToast(R.string.txt_not_null, gravity = Gravity.CENTER)
|
||||
@@ -633,6 +709,11 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
}
|
||||
fencesBean.apply {
|
||||
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) {
|
||||
ConstantInt.CircleShapeType -> {
|
||||
mFencesManageViewModel.updateCircleFence(
|
||||
@@ -659,9 +740,33 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
* 删除围栏
|
||||
*/
|
||||
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 {
|
||||
mFencesManageViewModel.deleteFence(
|
||||
this@AddAndEditFencesZoneBaseActivity, fenceId, deviceServiceId
|
||||
this@AddAndEditFencesZoneBaseActivity, fenceId, deviceServiceId, modeType
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ import com.abbidot.baselibrary.eventbus.XEventBus
|
||||
import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.base.BaseDialog
|
||||
import com.abbidot.tracker.bean.FencesBean
|
||||
import com.abbidot.tracker.bean.GetFencesBean
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
import com.abbidot.tracker.bean.ReceiveDeviceData
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
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.util.Util
|
||||
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.FencesMapViewModel
|
||||
import com.clj.fastble.BleManager
|
||||
import com.daimajia.androidanimations.library.Techniques
|
||||
import com.daimajia.androidanimations.library.YoYo
|
||||
|
||||
@@ -46,13 +50,13 @@ class PreviewFencesZoneActivity :
|
||||
private lateinit var mPreviewFencesMapCommon: PreviewFencesZoneCommon
|
||||
private var mShowCenterLocationType = ConstantInt.OtherLocationType
|
||||
|
||||
//是否是当前页面删除,放在重复收到本页面删除通知
|
||||
private var isCurrentActivityDelete = false
|
||||
|
||||
//是否是卫星地图
|
||||
private var isSatelliteMap = false
|
||||
private lateinit var mFencesList: MutableList<FencesBean>
|
||||
|
||||
//操作类型,0增加,1编辑,2删除
|
||||
private var mActionType = ConstantInt.Type1
|
||||
|
||||
override fun getTopBar() = mViewBinding.previewFencesZoneTopBar.titleTopBar
|
||||
|
||||
override fun initData() {
|
||||
@@ -149,14 +153,14 @@ class PreviewFencesZoneActivity :
|
||||
mViewBinding.cbPreviewFencesSwitch.isChecked =
|
||||
!mViewBinding.cbPreviewFencesSwitch.isChecked
|
||||
showToast(R.string.txt_change_successful, gravity = Gravity.CENTER)
|
||||
mCurrentFences?.apply {
|
||||
isOn =
|
||||
if (mViewBinding.cbPreviewFencesSwitch.isChecked) ConstantInt.Open else ConstantInt.Close
|
||||
mFencesManageViewModel.getFenceList(
|
||||
this@PreviewFencesZoneActivity, mCurrentDeviceId
|
||||
)
|
||||
sendFenceData()
|
||||
}
|
||||
// mCurrentFences?.apply {
|
||||
// isOn =
|
||||
// if (mViewBinding.cbPreviewFencesSwitch.isChecked) ConstantInt.Open else ConstantInt.Close
|
||||
//
|
||||
// }
|
||||
mFencesManageViewModel.getFenceList(
|
||||
this@PreviewFencesZoneActivity, mCurrentDeviceId
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -164,10 +168,6 @@ class PreviewFencesZoneActivity :
|
||||
mFencesManageViewModel.mDeleteFenceLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
isCurrentActivityDelete = true
|
||||
//删除蓝牙标志
|
||||
mCurrentFences?.isOn = ConstantInt.Type2
|
||||
sendFenceData()
|
||||
XEventBus.post(EventName.DeleteFences)
|
||||
showToast(R.string.txt_delete_success, true, gravity = Gravity.CENTER)
|
||||
}
|
||||
@@ -183,7 +183,47 @@ class PreviewFencesZoneActivity :
|
||||
|
||||
//接收删除围栏返回通知
|
||||
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() {
|
||||
mPetBean?.apply {
|
||||
mCurrentFences?.apply {
|
||||
SRBleUtil.instance.isConnectBleSendFenceData(macID, this)
|
||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||
macID, SRBleCmdUtil.instance.setFences(this)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,6 +316,24 @@ class PreviewFencesZoneActivity :
|
||||
} else {
|
||||
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) {
|
||||
ConstantInt.CircleShapeType -> {
|
||||
mFencesManageViewModel.updateCircleFence(
|
||||
@@ -302,9 +362,36 @@ class PreviewFencesZoneActivity :
|
||||
* 删除围栏
|
||||
*/
|
||||
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 {
|
||||
mFencesManageViewModel.deleteFence(
|
||||
this@PreviewFencesZoneActivity, fenceId, deviceServiceId
|
||||
this@PreviewFencesZoneActivity, fenceId, deviceServiceId, modeType
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ 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.LogUtil
|
||||
import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.tracker.R
|
||||
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.GetFencesBean
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
import com.abbidot.tracker.bean.ReceiveDeviceData
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.ActivityVirtualFencesBinding
|
||||
import com.abbidot.tracker.util.Util
|
||||
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.clj.fastble.BleManager
|
||||
import com.qmuiteam.qmui.util.QMUIDisplayHelper
|
||||
|
||||
/**
|
||||
@@ -39,6 +44,9 @@ class VirtualFencesActivity :
|
||||
private var mPetBean: PetBean? = null
|
||||
private var mGetFencesBean: GetFencesBean? = null
|
||||
|
||||
//需要同步设备的围栏数据
|
||||
private lateinit var mNeedSyncFencesList: MutableList<FencesBean>
|
||||
|
||||
override fun getTopBar() = mViewBinding.virtualFencesTopBar.titleTopBar
|
||||
|
||||
override fun initData() {
|
||||
@@ -49,6 +57,7 @@ class VirtualFencesActivity :
|
||||
|
||||
mFencesList = mutableListOf()
|
||||
mFencesNoGoList = mutableListOf()
|
||||
mNeedSyncFencesList = mutableListOf()
|
||||
|
||||
mViewBinding.apply {
|
||||
|
||||
@@ -135,6 +144,17 @@ class VirtualFencesActivity :
|
||||
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) {
|
||||
@@ -193,6 +213,118 @@ class VirtualFencesActivity :
|
||||
val countString = String.format(getString(R.string.txt_fences_set), "$fencesCount/5")
|
||||
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) {
|
||||
|
||||
@@ -202,7 +202,9 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
// XEventBus.post(EventName.UpdateData + "TrackerManageSetActivity")
|
||||
// XEventBus.post(EventName.UpdateData + "TrackerManageFragment")
|
||||
mPetBean?.apply {
|
||||
SRBleUtil.instance.isConnectBleSendNotifyData(macID)
|
||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||
macID, SRBleCmdUtil.instance.setNotifySyncData()
|
||||
)
|
||||
}
|
||||
showToast(R.string.txt_change_successful, isFinish = true)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.ActivityTrackingDurationSetBinding
|
||||
import com.abbidot.tracker.util.Util
|
||||
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.TrackerSetViewModel
|
||||
|
||||
@@ -61,7 +62,9 @@ class TrackingDurationSetActivity :
|
||||
mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex
|
||||
)
|
||||
mMapDeviceBean?.apply {
|
||||
SRBleUtil.instance.isConnectBleSendNotifyData(deviceMacId)
|
||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||
deviceMacId, SRBleCmdUtil.instance.setNotifySyncData()
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -73,4 +73,5 @@ class PaymentMethodActivity :
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class PaymentSuccessActivity :
|
||||
mViewBinding.apply {
|
||||
ivPaymentSuccessAnim.load(R.drawable.pwd_reset_successful_done)
|
||||
mPayResult?.let {
|
||||
|
||||
LogUtil.e("充值类型rechargeType=${it.rechargeType}")
|
||||
// if (it.rechargeType == ConstantInt.Type0) {
|
||||
// btnPaymentSuccessContinue.setText(R.string.txt_continue)
|
||||
// }
|
||||
@@ -89,6 +89,8 @@ class PaymentSuccessActivity :
|
||||
|
||||
mMac = MMKVUtil.getString(MMKVKey.FirstDeviceMac)
|
||||
if (TextUtils.isEmpty(mMac)) {
|
||||
btnPaymentSuccessContinue.setText(R.string.txt_continue)
|
||||
tvPaymentSuccessActivateTip.visibility = View.INVISIBLE
|
||||
ilPaymentSuccessBluetoothTips.root.visibility = View.GONE
|
||||
} else {
|
||||
connectBle(mMac)
|
||||
@@ -177,7 +179,7 @@ class PaymentSuccessActivity :
|
||||
pet.deviceId = mPayResult!!.deviceId
|
||||
pet.petType = ConstantInt.DogPetType
|
||||
pet.gender = ConstantInt.WoMan
|
||||
pet.macID=mMac
|
||||
pet.macID = mMac
|
||||
pet.birthdayDate = "2024-01-01"
|
||||
pet.height = Utils.formatDecimal(Util.inToCm(20.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 data2 = SRBleCmdUtil.instance.byteToInt(data[2])
|
||||
if (data0 == 0x1A && data1 == 1 && data2 == 0) {
|
||||
MMKVUtil.putString(MMKVKey.FirstDeviceMac, "")
|
||||
XEventBus.post(EventName.PayBack)
|
||||
mPayResult?.let {
|
||||
if (it.rechargeType == ConstantInt.Type0) {
|
||||
@@ -288,7 +291,10 @@ class PaymentSuccessActivity :
|
||||
)
|
||||
|
||||
btnPaymentSuccessContinue -> {
|
||||
SRBleUtil.instance.getConnectMacDevice(mMac)?.let {
|
||||
if (TextUtils.isEmpty(mMac)) {
|
||||
XEventBus.post(EventName.PayBack)
|
||||
finish()
|
||||
} else SRBleUtil.instance.getConnectMacDevice(mMac)?.let {
|
||||
setButtonEnabled(
|
||||
mViewBinding.btnPaymentSuccessContinue, ConstantInt.Type0
|
||||
)
|
||||
|
||||
@@ -50,7 +50,7 @@ class SubscriptionDetailActivity :
|
||||
it.name
|
||||
}
|
||||
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 =
|
||||
Utils.formatTime(it.createdDate.toLong(), Utils.DATE_FORMAT_PATTERN_EN6)
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class SubscriptionPlanActivity :
|
||||
intent, ConstantString.LkSetMeal, SubscriptionsOrderBean::class.java
|
||||
)
|
||||
val isFirstBind = getBoolean(ConstantString.isFirstBind, false)
|
||||
mRechargeType = getInt(ConstantString.RechargeType, ConstantInt.Type1)
|
||||
if (isFirstBind) mRechargeType = ConstantInt.Type0
|
||||
}
|
||||
|
||||
|
||||
@@ -75,19 +75,19 @@ class HistoryDataMapCommon : BaseMapCommon() {
|
||||
}
|
||||
}
|
||||
|
||||
fun addSetLine() {
|
||||
fun addSetLine(isMoveCamera: Boolean = true) {
|
||||
if (null != mHistoryDataBaiduMapFragment) {
|
||||
mHistoryDataBaiduMapFragment!!.addSetLine()
|
||||
} else if (null != mHistoryDataGoogleMapFragment) {
|
||||
mHistoryDataGoogleMapFragment!!.addSetLine()
|
||||
mHistoryDataGoogleMapFragment!!.addSetLine(isMoveCamera)
|
||||
}
|
||||
}
|
||||
|
||||
fun addSetNumber() {
|
||||
fun addSetNumber(isMoveCamera: Boolean = true) {
|
||||
if (null != mHistoryDataBaiduMapFragment) {
|
||||
mHistoryDataBaiduMapFragment!!.addSetNumber()
|
||||
} else if (null != mHistoryDataGoogleMapFragment) {
|
||||
mHistoryDataGoogleMapFragment!!.addSetNumber()
|
||||
mHistoryDataGoogleMapFragment!!.addSetNumber(isMoveCamera)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,9 @@ class HomeMapCommon @Inject constructor() : BaseMapCommon() {
|
||||
MMKVUtil.putDouble(MMKVKey.MapShowDefaultLon, longitude)
|
||||
mHomeMapGoogleMapFragment?.apply {
|
||||
refreshPetCurrentLocation(
|
||||
LatLng(latitude, longitude), isAnimMoveCamera = isAnimMoveCamera
|
||||
LatLng(latitude, longitude),
|
||||
isAnimMoveCamera = isAnimMoveCamera,
|
||||
needMoveCamera = isAnimMoveCamera
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,9 @@ class AccountV2Fragment :
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
mNotificationsViewModel.getMessageList(mHomeV2Activity)
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,9 @@ class ActivityV2Fragment :
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
if (mCurrentShowPetPos == mHomeV2Activity.mSelectPetPosition) {
|
||||
mHomeV2Activity.getPet()?.apply {
|
||||
mDataViewModel.getHomeDeviceData(deviceId, mToday, petId)
|
||||
|
||||
@@ -179,13 +179,13 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
})
|
||||
|
||||
mViewBinding.rgHistoryRouteMapTrackType.setOnCheckedChangeListener { _, checkedId ->
|
||||
mViewBinding.vsbMapRouteLine.progress = mViewBinding.vsbMapRouteLine.max
|
||||
// mViewBinding.vsbMapRouteLine.progress = mViewBinding.vsbMapRouteLine.max
|
||||
when (checkedId) {
|
||||
mViewBinding.rbHistoryRouteMapLine.id -> {
|
||||
MMKVUtil.putInt(MMKVKey.LineSelectPosition, ConstantInt.Line)
|
||||
mHistoryDataMapCommon.addSetLine()
|
||||
mHistoryDataMapCommon.addSetLine(false)
|
||||
if (mHistoryDataList.size > 0) {
|
||||
mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1)
|
||||
// mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1)
|
||||
} else {
|
||||
showToast(R.string.no_data, gravity = Gravity.CENTER)
|
||||
}
|
||||
@@ -193,9 +193,9 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
|
||||
mViewBinding.rbHistoryRouteMapNumber.id -> {
|
||||
MMKVUtil.putInt(MMKVKey.LineSelectPosition, ConstantInt.Point)
|
||||
mHistoryDataMapCommon.addSetNumber()
|
||||
mHistoryDataMapCommon.addSetNumber(false)
|
||||
if (mHistoryDataList.size > 0) {
|
||||
mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1)
|
||||
// mHistoryDataMapCommon.slideStopChanged(mHistoryDataList.size - 1)
|
||||
} else {
|
||||
showToast(R.string.no_data, gravity = Gravity.CENTER)
|
||||
}
|
||||
@@ -206,6 +206,9 @@ class RouteV2Fragment : BaseFragment<FragmentRouteV2Binding>(FragmentRouteV2Bind
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
if (mCurrentShowPetPos == mHomeV2Activity.mSelectPetPosition) {
|
||||
if (!isSelectCustomDate) {
|
||||
if (mHistoryDataMapCommon.isMapLoadOk()) {
|
||||
|
||||
@@ -891,6 +891,9 @@ class HomeTrackFragment :
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
//变量初始化
|
||||
if (!::mHomeV2Activity.isInitialized) {
|
||||
return
|
||||
|
||||
@@ -169,6 +169,9 @@ class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::i
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
//其他页面是否选择了宠物
|
||||
if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) {
|
||||
showPetNameAndHead(mHomeV2Activity.mSelectPetPosition)
|
||||
@@ -275,15 +278,11 @@ class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::i
|
||||
}
|
||||
}
|
||||
//接收蓝牙连接状态
|
||||
XEventBus.observe(
|
||||
this, EventName.ConnectDeviceState
|
||||
) { trackBleDevice: BleTrackDeviceBean ->
|
||||
XEventBus.observe(this, EventName.ConnectDeviceState) { trackBle: BleTrackDeviceBean ->
|
||||
mHomeV2Activity.getPet(false)?.apply {
|
||||
if (trackBleDevice.mac == macID) {
|
||||
//蓝牙断开就重新获取服务器数据,蓝牙数据上报断开
|
||||
if (trackBleDevice.conState == ConState.DISCONNECTED) {
|
||||
updateMapDeviceStatus()
|
||||
}
|
||||
//蓝牙断开就重新获取服务器数据,蓝牙数据上报断开
|
||||
if (trackBle.mac == macID && trackBle.conState != ConState.CONNECTED) {
|
||||
updateMapDeviceStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -609,6 +608,7 @@ class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::i
|
||||
homeMapRefreshBtn, mShowCenterLocationType
|
||||
)
|
||||
} else {
|
||||
isAnimMoveCamera = true
|
||||
updateMapDeviceStatus(useBleLocation = true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ abstract class BaseGoogleMapFragment :
|
||||
private var mMapviewBundleKey = this.javaClass.simpleName
|
||||
|
||||
//地图放大
|
||||
private var mGoogleMapZoom = 18f
|
||||
private var mGoogleMapZoom = 17f
|
||||
|
||||
//地图摄像机移动动画时间 毫秒
|
||||
private val mAnimMoveDurationMs = 1000
|
||||
|
||||
@@ -163,6 +163,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
||||
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)
|
||||
if (type == ConstantInt.Line) {
|
||||
addSetLine()
|
||||
@@ -170,12 +173,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
||||
addSetNumber()
|
||||
}
|
||||
|
||||
val maxIndex = data.size - 1
|
||||
mGeoCoderViewModel.getLatLonAddress(
|
||||
mLatLngList[maxIndex].latitude, mLatLngList[maxIndex].longitude, false
|
||||
)
|
||||
|
||||
mCurLatLng = mLatLngList[maxIndex]
|
||||
setMarkerInfoViewOffset(mMarkerInfoView, mLatLngList[maxIndex])
|
||||
}
|
||||
|
||||
@@ -191,9 +191,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
||||
*/
|
||||
fun slideStopChanged(progress: Int) {
|
||||
if (mLatLngList.size > 0) {
|
||||
moveCameraLocation(
|
||||
mLatLngList[progress].latitude, mLatLngList[progress].longitude, false
|
||||
)
|
||||
// moveCameraLocation(
|
||||
// mLatLngList[progress].latitude, mLatLngList[progress].longitude, false
|
||||
// )
|
||||
mGeoCoderViewModel.getLatLonAddress(
|
||||
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
|
||||
LogUtil.e("画线点有 $size 个")
|
||||
if (size == 0) return
|
||||
mGoogleMap?.let {
|
||||
it.clear()
|
||||
|
||||
moveCameraUpdate(mLatLngList[size - 1])
|
||||
if (isMoveCamera) moveCameraUpdate(mLatLngList[size - 1])
|
||||
|
||||
addSinglePolyline(it, mLatLngList)
|
||||
|
||||
@@ -226,21 +226,23 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
||||
// 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
|
||||
LogUtil.e("轨迹谷歌地图设置显示数字$size,经纬度点")
|
||||
if (size == 0) return
|
||||
mGoogleMap?.let {
|
||||
it.clear()
|
||||
|
||||
moveCameraUpdate(mLatLngList[size - 1])
|
||||
if (isMoveCamera) moveCameraUpdate(mLatLngList[size - 1])
|
||||
|
||||
// refreshPetCurrentLocation(
|
||||
// mLatLngList[size - 1], needMoveCamera = false, isAnimMoveCamera = false
|
||||
@@ -260,7 +262,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,9 @@ class HomePetFragment : BaseFragment<FragmentHomePetBinding>(FragmentHomePetBind
|
||||
}
|
||||
|
||||
fun getPetAllInfoData() {
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
//变量初始化
|
||||
if (!::mHomeV2Activity.isInitialized) {
|
||||
return
|
||||
|
||||
@@ -84,6 +84,9 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
//其他页面是否选择了宠物
|
||||
if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) {
|
||||
showPetNameAndHead(mHomeV2Activity.mSelectPetPosition)
|
||||
|
||||
@@ -23,7 +23,7 @@ class SocketUtilManage {
|
||||
// private val iP = "192.168.0.69"
|
||||
|
||||
//默认国外服务器端口
|
||||
private var port = 6868
|
||||
private var port = 8868
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
private val crcTable = ushortArrayOf(
|
||||
|
||||
@@ -342,5 +342,13 @@ class SRBleCmdUtil private constructor() {
|
||||
}
|
||||
return getCrc8Cmd(byteArray)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询围栏
|
||||
*/
|
||||
fun getFences(): ByteArray {
|
||||
val byteArray = byteArrayOf(0x13, CMD_READ.toByte(), 0)
|
||||
return getCrc8Cmd(byteArray)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -404,36 +404,16 @@ class SRBleUtil private constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送参数同步提醒消息 0x17
|
||||
* 发生数据给指定的Mac设备
|
||||
*/
|
||||
fun isConnectBleSendNotifyData(mac: String) {
|
||||
fun isConnectBleSendCmdData(mac: String, byteArray: ByteArray) {
|
||||
if (TextUtils.isEmpty(mac)) {
|
||||
return
|
||||
}
|
||||
if (BleManager.getInstance().isConnected(mac)) {
|
||||
val trackDeviceBean = getConnectMacDevice(mac)
|
||||
trackDeviceBean?.let {
|
||||
writeData(
|
||||
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)
|
||||
)
|
||||
writeData(it.bleDevice, byteArray)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,10 @@ package com.abbidot.tracker.vm
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.base.BaseDialog
|
||||
import com.abbidot.tracker.bean.FencesBean
|
||||
import com.abbidot.tracker.bean.GetFencesBean
|
||||
import com.abbidot.tracker.retrofit2.NetworkApi
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -81,7 +78,8 @@ class FencesManageViewModel : ViewModel() {
|
||||
ancillaryLatitude,
|
||||
ancillaryLongitude,
|
||||
ancillaryOtherLatitude,
|
||||
ancillaryOtherLongitude
|
||||
ancillaryOtherLongitude,
|
||||
modeType
|
||||
)
|
||||
mUpdateFenceLiveData.value = result
|
||||
}
|
||||
@@ -115,7 +113,8 @@ class FencesManageViewModel : ViewModel() {
|
||||
longitudeCenter,
|
||||
latitudeCenter,
|
||||
longDistance,
|
||||
shortDistance
|
||||
shortDistance,
|
||||
modeType
|
||||
)
|
||||
mUpdateFenceLiveData.value = result
|
||||
}
|
||||
@@ -133,18 +132,11 @@ class FencesManageViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteFence(activity: BaseActivity<*>, fenceId: String, deviceServiceId: String) {
|
||||
ViewUtil.instance.showDialog(
|
||||
activity, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener {
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
dialog.dismiss()
|
||||
activity.showLoading(true)
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.removeFence(fenceId, deviceServiceId)
|
||||
mDeleteFenceLiveData.value = result
|
||||
}
|
||||
}
|
||||
}, okTextResId = R.string.txt_sure
|
||||
)
|
||||
fun deleteFence(activity: BaseActivity<*>, fenceId: String, deviceServiceId: String,modeType:Int) {
|
||||
activity.showLoading(true)
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.removeFence(fenceId, deviceServiceId,modeType)
|
||||
mDeleteFenceLiveData.value = result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1027,7 +1027,6 @@
|
||||
<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_update_time">Updated: %s</string>
|
||||
|
||||
<string name="txt_as_low_as">As low as</string>
|
||||
<string name="txt_payment_manager">Payment Manager</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_family_sharing">Family Members Sharing</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_months">Renewal: $%s/%s months on %s</string>
|
||||
<string name="txt_replacement_year">1 replacement/year, any reason</string>
|
||||
<string name="txt_expiry_time">Expiry Time:</string>
|
||||
<string name="txt_year_care">%s Year Care</string>
|
||||
<string name="txt_fence_saved">Saved. Active when online.</string>
|
||||
<string name="txt_synchronized_data">同步数据中…</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user