1.优化区分信号弱/无信号(4种状态:1. wifi zone 中/关机/休眠/充电/超时无上报-关,2. 信号大于50-强,信号大于0小于50 -弱,3. 信号等于0-无)
2.修复围栏编辑和添加保存时/删除时,还可以输入内容和点‘取消’按钮 3.修复删除围栏时,还可以点击编辑按钮 4.修复轨迹页面围栏名字太长,列表对不齐 5.修复轨迹只有3个点时,滑块滑不动的bug 6.修复直播页面第三个导航无法点击bug 7.校对多语言字符
This commit is contained in:
@@ -46,6 +46,9 @@ class SubscriptionHistoryAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保险订单
|
||||
*/
|
||||
private fun bindAnnualCareData(holder: BaseViewHolder, item: SubscriptionsOrderBean) {
|
||||
holder.setText(
|
||||
R.id.tv_subscription_annual_care_order_id,
|
||||
@@ -111,26 +114,28 @@ class SubscriptionHistoryAdapter(
|
||||
visibility = View.VISIBLE
|
||||
when (item.orderStatus) {
|
||||
1 -> {
|
||||
val updateTimestamp = Utils.stringToTimestamp(item.updateTime, isUtc = true)
|
||||
val nowTimestamp = System.currentTimeMillis()
|
||||
// val updateTimestamp = Utils.stringToTimestamp(item.updateTime, isUtc = true)
|
||||
// val nowTimestamp = System.currentTimeMillis()
|
||||
if (item.enabled == ConstantInt.Type0 || (item.surplusDays == 0L && item.subscriptionStatus == ConstantInt.Close)) {
|
||||
visibility = View.GONE
|
||||
} else if (item.mealUnit == ConstantString.PackageUnitDay) {
|
||||
visibility = View.VISIBLE
|
||||
setText(R.string.txt_refund)
|
||||
} else if (item.mealUnit == ConstantString.PackageUnitMonth) {
|
||||
val day7Timestamp = 7 * 24 * 60 * 60 * 1000L
|
||||
// val day7Timestamp = 7 * 24 * 60 * 60 * 1000L
|
||||
//套餐超出7天不能退款
|
||||
if (nowTimestamp - updateTimestamp <= day7Timestamp) {
|
||||
// if (nowTimestamp - updateTimestamp <= day7Timestamp) {
|
||||
if (item.isRefundable == ConstantInt.Type1) {
|
||||
visibility = View.VISIBLE
|
||||
setText(R.string.txt_refund)
|
||||
} else {
|
||||
visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
val day30Timestamp = 30 * 24 * 60 * 60 * 1000L
|
||||
// val day30Timestamp = 30 * 24 * 60 * 60 * 1000L
|
||||
//套餐超出30天不能退款
|
||||
if (nowTimestamp - updateTimestamp <= day30Timestamp) {
|
||||
// if (nowTimestamp - updateTimestamp <= day30Timestamp) {
|
||||
if (item.isRefundable == ConstantInt.Type1) {
|
||||
visibility = View.VISIBLE
|
||||
setText(R.string.txt_refund)
|
||||
} else {
|
||||
|
||||
@@ -55,6 +55,7 @@ data class SubscriptionsOrderBean(
|
||||
var endTime: Long,
|
||||
var refundTime: Long,
|
||||
var planTimeMonthsCount: Int,
|
||||
var isRefundable: Int,//是否显示退款按钮 1:是 0:否
|
||||
@MultipleEntity var menuType: Int,
|
||||
var isUpdateOrder: Int = 0//是否是升级订单 1:是 0:否
|
||||
) : Parcelable, MultiItemEntity {
|
||||
@@ -101,6 +102,7 @@ data class SubscriptionsOrderBean(
|
||||
0L,
|
||||
0L,
|
||||
0,
|
||||
0,
|
||||
menuType,
|
||||
0
|
||||
)
|
||||
|
||||
@@ -65,7 +65,6 @@ import com.hjq.permissions.XXPermissions
|
||||
import com.hjq.permissions.permission.PermissionLists
|
||||
import com.huantansheng.easyphotos.EasyPhotos
|
||||
import com.qmuiteam.qmui.widget.QMUITopBar
|
||||
import com.tencent.bugly.crashreport.CrashReport
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -212,7 +211,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
mDataViewModel.getHomeBindPetList(this@HomeV2Activity)
|
||||
|
||||
//设置bugly的用户id
|
||||
CrashReport.setUserId(MMKVUtil.getString(MMKVKey.Email))
|
||||
// CrashReport.setUserId(MMKVUtil.getString(MMKVKey.Email))
|
||||
//预先加载相册,防止上传头像几千张照片加载慢
|
||||
XXPermissions.with(this).permission(PermissionLists.getReadMediaImagesPermission())
|
||||
.request { _, deniedList ->
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.baidu.mapapi.SDKInitializer
|
||||
import com.hjq.toast.Toaster
|
||||
import com.qmuiteam.qmui.arch.QMUIActivity
|
||||
import com.stripe.android.PaymentConfiguration
|
||||
import com.tencent.bugly.crashreport.CrashReport
|
||||
import com.tencent.mm.opensdk.constants.ConstantsAPI
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI
|
||||
import java.util.Calendar
|
||||
@@ -220,8 +219,8 @@ class SplashActivity : QMUIActivity() {
|
||||
}
|
||||
|
||||
//腾讯bugly初始化
|
||||
val buglyKey = Util.getMetadata(applicationContext, KeyNames.BUG_LY_KEY_NAME)
|
||||
CrashReport.initCrashReport(applicationContext, buglyKey, AppUtils.isDebug())
|
||||
// val buglyKey = Util.getMetadata(applicationContext, KeyNames.BUG_LY_KEY_NAME)
|
||||
// CrashReport.initCrashReport(applicationContext, buglyKey, AppUtils.isDebug())
|
||||
}
|
||||
|
||||
private fun initMapbox() {
|
||||
|
||||
@@ -71,6 +71,9 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
var mFencesList: GetFencesBean? = null
|
||||
var isEditFences = false
|
||||
|
||||
//冻结点击
|
||||
private var isBlockedClick = false
|
||||
|
||||
private var mShowCenterLocationType = ConstantInt.OtherLocationType
|
||||
private val mDefaultFencesName =
|
||||
arrayOf("Home", "Office", "Garden", "Park", "Play", "Unsafe", "Vegetable Garden", "Water")
|
||||
@@ -211,6 +214,11 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
setFenceName()
|
||||
}
|
||||
|
||||
override fun leftBackOnClick() {
|
||||
if (isBlockedClick) return
|
||||
super.leftBackOnClick()
|
||||
}
|
||||
|
||||
open fun mapLoadOk() {
|
||||
drawFences()
|
||||
}
|
||||
@@ -358,7 +366,7 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setButtonEnabled(mViewBinding.btnSaveFencesZone, ConstantInt.Type1)
|
||||
setDisableState(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -376,6 +384,11 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
R.string.txt_delete_success, isFinish = true, gravity = Gravity.CENTER
|
||||
)
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setDisableState(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
mFencesManageViewModel.mUpdateFenceLiveData.observe(this) {
|
||||
@@ -391,7 +404,7 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
setButtonEnabled(mViewBinding.btnSaveFencesZone, ConstantInt.Type1)
|
||||
setDisableState(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -416,6 +429,23 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
showToast(resStringId, isFinish = true, gravity = Gravity.CENTER)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置禁止状态
|
||||
*/
|
||||
private fun setDisableState(isDisable: Boolean) {
|
||||
isBlockedClick = isDisable
|
||||
mViewBinding.apply {
|
||||
if (isDisable) {
|
||||
ilFencesZoneNameInput.etInputContent.isEnabled = false
|
||||
setButtonEnabled(btnSaveFencesZone, ConstantInt.Type0)
|
||||
} else {
|
||||
ilFencesZoneNameInput.etInputContent.isEnabled = true
|
||||
setButtonEnabled(btnSaveFencesZone, ConstantInt.Type1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
bottomMarginOverlap()
|
||||
@@ -659,7 +689,7 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
else ConstantInt.Type2
|
||||
}
|
||||
mActionType = ConstantInt.Type0
|
||||
setButtonEnabled(mViewBinding.btnSaveFencesZone, ConstantInt.Type0)
|
||||
setDisableState(true)
|
||||
name = fenceName
|
||||
when (fenceShapeType) {
|
||||
ConstantInt.CircleShapeType -> {
|
||||
@@ -687,13 +717,14 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
* 更新围栏
|
||||
*/
|
||||
fun updateFences(fencesBean: FencesBean) {
|
||||
if (isBlockedClick) return
|
||||
val fenceName = mViewBinding.ilFencesZoneNameInput.etInputContent.text.toString()
|
||||
if (TextUtils.isEmpty(fenceName)) {
|
||||
showToast(R.string.txt_not_null, gravity = Gravity.CENTER)
|
||||
return
|
||||
}
|
||||
mActionType = ConstantInt.Type1
|
||||
setButtonEnabled(mViewBinding.btnSaveFencesZone, ConstantInt.Type0)
|
||||
setDisableState(true)
|
||||
mPetBean?.let {
|
||||
if (BleManager.getInstance().isConnected(it.macID)) {
|
||||
sendFenceData()
|
||||
@@ -746,12 +777,14 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
* 删除围栏
|
||||
*/
|
||||
fun deleteFences(fencesBean: FencesBean) {
|
||||
if (isBlockedClick) return
|
||||
ViewUtil.instance.showDialog(
|
||||
this, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener {
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
dialog.dismiss()
|
||||
mPetBean?.let {
|
||||
mActionType = ConstantInt.Type2
|
||||
setDisableState(true)
|
||||
if (BleManager.getInstance().isConnected(it.macID)) {
|
||||
//删除蓝牙标志
|
||||
fencesBean.isOn = ConstantInt.Type2
|
||||
@@ -884,7 +917,7 @@ open class AddAndEditFencesZoneBaseActivity :
|
||||
}
|
||||
|
||||
tvFencesZoneShapeResetBtn -> recoverDefaultFencesView()
|
||||
btnCancelFencesZone -> finish()
|
||||
btnCancelFencesZone -> if (!isBlockedClick) finish()
|
||||
ivFencesZoneMapSwitchBtn -> switchMapType()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ class PreviewFencesZoneActivity :
|
||||
//操作类型,0增加,1编辑,2删除
|
||||
private var mActionType = ConstantInt.Type1
|
||||
|
||||
//冻结点击
|
||||
private var isBlockedClick = false
|
||||
|
||||
override fun getTopBar() = mViewBinding.previewFencesZoneTopBar.titleTopBar
|
||||
|
||||
override fun initData() {
|
||||
@@ -129,6 +132,11 @@ class PreviewFencesZoneActivity :
|
||||
}
|
||||
}
|
||||
|
||||
override fun leftBackOnClick() {
|
||||
if (isBlockedClick) return
|
||||
super.leftBackOnClick()
|
||||
}
|
||||
|
||||
override fun liveDataObserve() {
|
||||
//获取所有围栏返回
|
||||
mFencesManageViewModel.mFencesLiveData.observe(this) {
|
||||
@@ -167,6 +175,11 @@ class PreviewFencesZoneActivity :
|
||||
XEventBus.post(EventName.DeleteFences)
|
||||
showToast(R.string.txt_delete_success, true, gravity = Gravity.CENTER)
|
||||
}
|
||||
|
||||
override fun onRequestError(exceptionCode: String?) {
|
||||
super.onRequestError(exceptionCode)
|
||||
isBlockedClick = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -367,6 +380,7 @@ class PreviewFencesZoneActivity :
|
||||
* 删除围栏
|
||||
*/
|
||||
private fun deleteFences() {
|
||||
if (isBlockedClick) return
|
||||
ViewUtil.instance.showDialog(
|
||||
this, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener {
|
||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||
@@ -374,6 +388,7 @@ class PreviewFencesZoneActivity :
|
||||
mPetBean?.let {
|
||||
mCurrentFences?.apply {
|
||||
mActionType = ConstantInt.Type2
|
||||
isBlockedClick = true
|
||||
if (modeType == ConstantInt.Type3) modeType = ConstantInt.Type3
|
||||
else if (BleManager.getInstance().isConnected(it.macID)) {
|
||||
//删除蓝牙标志
|
||||
@@ -402,6 +417,7 @@ class PreviewFencesZoneActivity :
|
||||
}
|
||||
|
||||
private fun goEditFences() {
|
||||
if (isBlockedClick) return
|
||||
Util.checkLocationPermissionsGpsEnabled(this, {
|
||||
mCurrentFences?.apply {
|
||||
val intent = if (fenceType == ConstantInt.SafeZone) Intent(
|
||||
@@ -422,7 +438,10 @@ class PreviewFencesZoneActivity :
|
||||
btnPreviewFencesEdit -> goEditFences()
|
||||
|
||||
mRightImageButton -> deleteFences()
|
||||
cbPreviewFencesSwitch -> mCurrentFences?.apply { changeOnAndOff(this) }
|
||||
cbPreviewFencesSwitch -> {
|
||||
if (isBlockedClick) return
|
||||
mCurrentFences?.apply { changeOnAndOff(this) }
|
||||
}
|
||||
|
||||
ivPreviewFencesMapSwitchBtn -> {
|
||||
mPreviewFencesMapCommon.switchSatelliteAndNormalMapType()
|
||||
|
||||
@@ -216,6 +216,7 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
|
||||
ilLiveV2OperateLayout.btnLiveV2Issue,
|
||||
ilMapLiveV2IssueLayout.tvCloseIssueBtn,
|
||||
ilLiveV3MapDeviceBatteryLayout.ivDeviceCloseBtn,
|
||||
ilLiveV3MapPetLocation.ivPetLocationNavigationBtn,
|
||||
ilLiveV3MapDeviceMsg.ivDeviceMsgCloseBtn
|
||||
)
|
||||
|
||||
@@ -1258,6 +1259,11 @@ class LiveActivityV3 : BaseActivity<ActivityLiveV3Binding>(ActivityLiveV3Binding
|
||||
mMapDeviceBean?.isCloseMsg = true
|
||||
ilLiveV3MapDeviceMsg.root.visibility = View.GONE
|
||||
}
|
||||
|
||||
ilLiveV3MapPetLocation.ivPetLocationNavigationBtn -> {
|
||||
if (isLimitClick()) return
|
||||
mMapViewModel.showNavigationDialog(this@LiveActivityV3, mMapDeviceBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.view.Gravity
|
||||
import android.view.View
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.commit
|
||||
@@ -28,20 +27,17 @@ import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.adapter.HomeMapDeviceStateAdapter
|
||||
import com.abbidot.tracker.adapter.SelectMapListDialogAdapter
|
||||
import com.abbidot.tracker.base.BaseDialog
|
||||
import com.abbidot.tracker.base.BaseFragment
|
||||
import com.abbidot.tracker.bean.BleReportDataBean
|
||||
import com.abbidot.tracker.bean.BleTrackDeviceBean
|
||||
import com.abbidot.tracker.bean.DataBean
|
||||
import com.abbidot.tracker.bean.MapDeviceBean
|
||||
import com.abbidot.tracker.bean.MenuTxtBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.FragmentMapV3Binding
|
||||
import com.abbidot.tracker.dialog.CommonDialog1
|
||||
import com.abbidot.tracker.dialog.SelectMapListDialog
|
||||
import com.abbidot.tracker.dialog.SelectMapTypeDialog
|
||||
import com.abbidot.tracker.ui.activity.HomeV2Activity
|
||||
import com.abbidot.tracker.ui.activity.map.LiveActivityV3
|
||||
@@ -107,13 +103,6 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
private var needGpsToGCJ02 = true
|
||||
private var mAnimatorSet: AnimatorSet? = null
|
||||
|
||||
private val mMapGooglePackageName = "com.google.android.apps.maps"
|
||||
private val mMapGaoDePackageName = "com.autonavi.minimap"
|
||||
private val mMapBaiduPackageName = "com.baidu.BaiduMap"
|
||||
|
||||
private lateinit var mSelectMapListDialogAdapter: SelectMapListDialogAdapter
|
||||
private var mSelectMapListDialog: SelectMapListDialog? = null
|
||||
|
||||
//一键定位开始的时间戳
|
||||
private var notifyRefreshLocationTimestamp = 0L
|
||||
|
||||
@@ -940,88 +929,6 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
// }
|
||||
// }
|
||||
|
||||
private fun showNavigationDialog() {
|
||||
if (null == mSelectMapListDialog) {
|
||||
val mapList = mutableListOf<MenuTxtBean>()
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mapList,
|
||||
getString(R.string.map_navigate_map_google),
|
||||
mMapGooglePackageName,
|
||||
R.drawable.ico_map_google
|
||||
)
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mapList,
|
||||
getString(R.string.map_navigate_map_gaode),
|
||||
mMapGaoDePackageName,
|
||||
R.drawable.ico_map_gaode
|
||||
)
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mapList,
|
||||
getString(R.string.map_baidu_map),
|
||||
mMapBaiduPackageName,
|
||||
R.drawable.ico_map_gaode
|
||||
)
|
||||
|
||||
mSelectMapListDialogAdapter = SelectMapListDialogAdapter(mContext!!, mapList)
|
||||
mSelectMapListDialogAdapter.setOnItemClickListener(object :
|
||||
BaseRecyclerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(itemView: View?, pos: Int) {
|
||||
selectMapNavigation(mapList[pos])
|
||||
}
|
||||
})
|
||||
mSelectMapListDialog = SelectMapListDialog(mContext!!, mSelectMapListDialogAdapter)
|
||||
}
|
||||
mSelectMapListDialog!!.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择地图开始跳转
|
||||
*/
|
||||
private fun selectMapNavigation(item: MenuTxtBean) {
|
||||
mSelectMapListDialog?.dismiss()
|
||||
mMapDeviceBean?.apply {
|
||||
try {
|
||||
when (item.menuValue) {
|
||||
//谷歌地图
|
||||
mMapGooglePackageName -> {
|
||||
var lat = latitude
|
||||
var lon = longitude
|
||||
if (MMKVUtil.getBoolean(MMKVKey.isGpsToGCJ02)) {
|
||||
val convertLatLon =
|
||||
LonAndLatUtil.convertFromWGS84ToGCJ02(latitude, longitude)
|
||||
lat = convertLatLon[0]
|
||||
lon = convertLatLon[1]
|
||||
}
|
||||
val uri = "google.navigation:q=${lat},${lon}&mode=w".toUri()
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
intent.setPackage(item.menuValue)
|
||||
startActivity(intent)
|
||||
}
|
||||
//高德地图 https://lbs.amap.com/api/amap-mobile/guide/android/walk-navi
|
||||
mMapGaoDePackageName -> {
|
||||
val uri = "amapuri://openFeature?featureName=OnFootNavi&sourceApplication=${
|
||||
getString(
|
||||
R.string.app_name
|
||||
)
|
||||
}&lat=${latitude}&lon=${longitude}&dev=1".toUri()
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
intent.setPackage(item.menuValue)
|
||||
startActivity(intent)
|
||||
}
|
||||
//百度地图 https://lbs.baidu.com/docs/webapi?title=mapadjustment/uri/andriod
|
||||
mMapBaiduPackageName -> {
|
||||
val uri =
|
||||
"baidumap://map/direction?destination=name:|latlng:${latitude},${longitude}&mode=walking&coord_type=wgs84".toUri()
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
intent.setPackage(item.menuValue)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showToast(getString(R.string.txt_no_install), gravity = Gravity.CENTER)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
mViewBinding.apply {
|
||||
@@ -1094,7 +1001,9 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
ilHomeMapPetLocation.ivPetLocationNavigationBtn -> {
|
||||
if (isLimitClick()) return
|
||||
// goNavigation()
|
||||
showNavigationDialog()
|
||||
getHomeV2Activity()?.let {
|
||||
mMapViewModel.showNavigationDialog(it, mMapDeviceBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,33 @@
|
||||
package com.abbidot.tracker.vm
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.CountDownTimer
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.abbidot.baselibrary.constant.MMKVKey
|
||||
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
|
||||
import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.adapter.SelectMapListDialogAdapter
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.bean.DataBean
|
||||
import com.abbidot.tracker.bean.MapDeviceBean
|
||||
import com.abbidot.tracker.bean.MenuTxtBean
|
||||
import com.abbidot.tracker.bean.PetBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.dialog.SelectMapListDialog
|
||||
import com.abbidot.tracker.retrofit2.NetworkApi
|
||||
import com.abbidot.tracker.util.LonAndLatUtil
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
@@ -39,6 +49,13 @@ class MapViewModel : ViewModel() {
|
||||
|
||||
var mDeviceMsgType = ConstantInt.SpecialType
|
||||
|
||||
private val mMapGooglePackageName = "com.google.android.apps.maps"
|
||||
private val mMapGaoDePackageName = "com.autonavi.minimap"
|
||||
private val mMapBaiduPackageName = "com.baidu.BaiduMap"
|
||||
private var mSelectMapListDialogAdapter: SelectMapListDialogAdapter? = null
|
||||
private var mSelectMapListDialog: SelectMapListDialog? = null
|
||||
private var mMapDeviceBean: MapDeviceBean? = null
|
||||
|
||||
fun setupRefreshLocation(deviceId: String) {
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.setupRefreshLocation(deviceId)
|
||||
@@ -185,7 +202,10 @@ class MapViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
//网络无信号/ 分钟后无上报所有绿点取消显示
|
||||
else if (lteSignal <= ConstantInt.NoSignal || Util.isTimeoutReport(updateTime,gnssInterval)) {
|
||||
else if (lteSignal <= ConstantInt.NoSignal || Util.isTimeoutReport(
|
||||
updateTime, gnssInterval
|
||||
)
|
||||
) {
|
||||
// setNoState(context, deviceStateList)
|
||||
|
||||
//警告状态
|
||||
@@ -307,7 +327,7 @@ class MapViewModel : ViewModel() {
|
||||
) {
|
||||
mapDeviceBean.let {
|
||||
//是否超时上报
|
||||
val isTimeoutReport = Util.isTimeoutReport(it.updateTime,it.gnssInterval)
|
||||
val isTimeoutReport = Util.isTimeoutReport(it.updateTime, it.gnssInterval)
|
||||
deviceStateList[0].apply {
|
||||
menuType = ConstantInt.Open
|
||||
val lteValue =
|
||||
@@ -322,14 +342,12 @@ class MapViewModel : ViewModel() {
|
||||
deviceStateList[1].apply {
|
||||
menuType = ConstantInt.Open
|
||||
val gpsValue =
|
||||
if (isTimeoutReport || it.powerSwitch == ConstantInt.Type0 || it.powerSwitch == ConstantInt.Type2 || it.inWifiZone == ConstantInt.Type1) {
|
||||
if (isTimeoutReport || it.powerSwitch == ConstantInt.Type0 || it.powerSwitch == ConstantInt.Type2 || it.powerSwitch == ConstantInt.Type3 || it.inWifiZone == ConstantInt.Type1) {
|
||||
menuType = ConstantInt.Close
|
||||
context.getString(R.string.tracker_manage_set_led_off)
|
||||
} else if (it.gpsSignal > ConstantInt.WeakSignal) {
|
||||
context.getString(R.string.txt_strong_signal)
|
||||
} else {
|
||||
context.getString(R.string.txt_weak_signal)
|
||||
}
|
||||
} else if (it.gpsSignal > ConstantInt.WeakSignal) context.getString(R.string.txt_strong_signal)
|
||||
else if (it.gpsSignal == ConstantInt.NoSignal) context.getString(R.string.txt_no_signal)
|
||||
else context.getString(R.string.txt_weak_signal)
|
||||
value = context.getString(R.string.tracker_manage_set_gps) + ":$gpsValue"
|
||||
}
|
||||
deviceStateList[2].apply {
|
||||
@@ -550,6 +568,96 @@ class MapViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示导航地图
|
||||
*/
|
||||
fun showNavigationDialog(activity: BaseActivity<*>, mapDeviceBean: MapDeviceBean?) {
|
||||
mMapDeviceBean = mapDeviceBean
|
||||
if (null == mSelectMapListDialog) {
|
||||
val mapList = mutableListOf<MenuTxtBean>()
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mapList,
|
||||
activity.getString(R.string.map_navigate_map_google),
|
||||
mMapGooglePackageName,
|
||||
R.drawable.ico_map_google
|
||||
)
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mapList,
|
||||
activity.getString(R.string.map_navigate_map_gaode),
|
||||
mMapGaoDePackageName,
|
||||
R.drawable.ico_map_gaode
|
||||
)
|
||||
ViewUtil.instance.addMenuBean(
|
||||
mapList,
|
||||
activity.getString(R.string.map_baidu_map),
|
||||
mMapBaiduPackageName,
|
||||
R.drawable.ico_map_gaode
|
||||
)
|
||||
|
||||
mSelectMapListDialogAdapter = SelectMapListDialogAdapter(activity, mapList).apply {
|
||||
setOnItemClickListener(object : BaseRecyclerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(itemView: View?, pos: Int) {
|
||||
selectMapNavigation(activity, mapList[pos])
|
||||
}
|
||||
})
|
||||
}
|
||||
mSelectMapListDialog = SelectMapListDialog(activity, mSelectMapListDialogAdapter!!)
|
||||
}
|
||||
mSelectMapListDialog?.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择地图开始跳转
|
||||
*/
|
||||
private fun selectMapNavigation(activity: BaseActivity<*>, item: MenuTxtBean) {
|
||||
mSelectMapListDialog?.dismiss()
|
||||
mMapDeviceBean?.apply {
|
||||
try {
|
||||
when (item.menuValue) {
|
||||
//谷歌地图
|
||||
mMapGooglePackageName -> {
|
||||
var lat = latitude
|
||||
var lon = longitude
|
||||
if (MMKVUtil.getBoolean(MMKVKey.isGpsToGCJ02)) {
|
||||
val convertLatLon =
|
||||
LonAndLatUtil.convertFromWGS84ToGCJ02(latitude, longitude)
|
||||
lat = convertLatLon[0]
|
||||
lon = convertLatLon[1]
|
||||
}
|
||||
val uri = "google.navigation:q=${lat},${lon}&mode=w".toUri()
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
intent.setPackage(item.menuValue)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
//高德地图 https://lbs.amap.com/api/amap-mobile/guide/android/walk-navi
|
||||
mMapGaoDePackageName -> {
|
||||
val uri = "amapuri://openFeature?featureName=OnFootNavi&sourceApplication=${
|
||||
activity.getString(
|
||||
R.string.app_name
|
||||
)
|
||||
}&lat=${latitude}&lon=${longitude}&dev=1".toUri()
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
intent.setPackage(item.menuValue)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
//百度地图 https://lbs.baidu.com/docs/webapi?title=mapadjustment/uri/andriod
|
||||
mMapBaiduPackageName -> {
|
||||
val uri =
|
||||
"baidumap://map/direction?destination=name:|latlng:${latitude},${longitude}&mode=walking&coord_type=wgs84".toUri()
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
intent.setPackage(item.menuValue)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
activity.showToast(
|
||||
activity.getString(R.string.txt_no_install), gravity = Gravity.CENTER
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止获取数据
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,8 @@ public class NoClickSlideSeekBar extends AppCompatSeekBar {
|
||||
private Rect mThumbRect;
|
||||
|
||||
private int mX, mY;
|
||||
//是否可以滑动
|
||||
private boolean isCanSile = true;
|
||||
|
||||
private NoClickSlideSeekBar(Context context) {
|
||||
super(context);
|
||||
@@ -42,22 +44,28 @@ public class NoClickSlideSeekBar extends AppCompatSeekBar {
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
if (MotionEvent.ACTION_DOWN == event.getAction()) {
|
||||
isCanSile = true;
|
||||
mThumbRect = getThumb().getBounds();
|
||||
}
|
||||
mX = (int) event.getX();
|
||||
mY = (int) event.getY();
|
||||
mX = (int) event.getX();
|
||||
mY = (int) event.getY();
|
||||
|
||||
if (mStaus == STATUS.STATUS_CLICK && !checkBound()) {
|
||||
isCanSile = false;
|
||||
return true;
|
||||
}
|
||||
if (mStaus == STATUS.STATUS_SLIDE && checkBound()) {
|
||||
isCanSile = false;
|
||||
return true;
|
||||
}
|
||||
if (mStaus == STATUS.STATUS_UNABLE) {
|
||||
isCanSile = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mStaus == STATUS.STATUS_CLICK && !checkBound()) {
|
||||
return true;
|
||||
}
|
||||
if (mStaus == STATUS.STATUS_SLIDE && checkBound()) {
|
||||
if (!isCanSile)
|
||||
return true;
|
||||
}
|
||||
if (mStaus == STATUS.STATUS_UNABLE) {
|
||||
return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user