|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.zj365.dc.fragment
|
|
|
|
|
|
|
|
|
|
import android.Manifest
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.graphics.Color
|
|
|
|
@ -25,6 +26,7 @@ import com.xty.common.Const
|
|
|
|
|
import com.xty.common.LogUtils
|
|
|
|
|
import com.xty.common.MMkvHelper
|
|
|
|
|
import com.xty.common.UmengEventId
|
|
|
|
|
import com.xty.common.aMapUtils.AmapInit
|
|
|
|
|
import com.xty.common.app.MyApp
|
|
|
|
|
import com.xty.common.arouter.ARouterUrl
|
|
|
|
|
import com.xty.common.arouter.RouteManager
|
|
|
|
@ -53,6 +55,7 @@ import com.zj365.mime.weight.NoticeSettingDialog
|
|
|
|
|
import com.xty.network.MyRetrofit
|
|
|
|
|
import com.xty.network.model.FamilyBean
|
|
|
|
|
import com.xty.network.model.HealthMonitoringListBean
|
|
|
|
|
import com.xty.network.model.MainBean
|
|
|
|
|
import com.xty.network.model.MessageBean
|
|
|
|
|
import com.xty.network.model.ReportBean
|
|
|
|
|
import com.zj365.dc.BuildConfig
|
|
|
|
@ -74,6 +77,7 @@ import org.greenrobot.eventbus.Subscribe
|
|
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
|
|
import org.json.JSONArray
|
|
|
|
|
import org.json.JSONObject
|
|
|
|
|
import pub.devrel.easypermissions.EasyPermissions
|
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
|
import java.util.regex.Matcher
|
|
|
|
|
import java.util.regex.Pattern
|
|
|
|
@ -83,7 +87,7 @@ import kotlin.math.min
|
|
|
|
|
/**
|
|
|
|
|
* 动态管理页面
|
|
|
|
|
*/
|
|
|
|
|
class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() , EasyPermissions.PermissionCallbacks{
|
|
|
|
|
|
|
|
|
|
val binding by lazy { FragDynamicManagementBinding.inflate(layoutInflater) }
|
|
|
|
|
override fun setLayout(): View = binding.root
|
|
|
|
@ -148,10 +152,10 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
* 0.心率、1.血氧、2.呼吸率、3.体温、4.步数、5.睡眠、6.血压、7.血糖、8.心电、9.尿酸、10.血脂。
|
|
|
|
|
*/
|
|
|
|
|
private val pageIndexs = arrayOf(
|
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9/*, 10*/
|
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
|
|
|
|
)
|
|
|
|
|
private val pageNames = arrayOf(
|
|
|
|
|
"心率", "血氧", "呼吸率", "体温", "步数", "睡眠", "血压", "血糖", "心电", "尿酸"/*, "血脂"*/
|
|
|
|
|
"心率", "血氧", "呼吸率", "体温", "步数", "睡眠", "血压", "血糖", "心电", "尿酸", "血脂"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@SuppressLint("ResourceType")
|
|
|
|
@ -172,8 +176,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
//刷新注册
|
|
|
|
|
refresh()
|
|
|
|
|
|
|
|
|
|
updateWarningStatus()
|
|
|
|
|
|
|
|
|
|
binding.mGriddingList.mGridView.adapter = mHealthAdapter
|
|
|
|
|
binding.mGriddingList.mGridView.setOnItemClickListener { _, _, position, _ ->
|
|
|
|
|
val index = mHealthAdapter.getItem(position).type
|
|
|
|
@ -206,10 +208,16 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
|
|
|
|
|
5 -> {
|
|
|
|
|
val deviceType = MMkvHelper.getString(Const.DEVICE_TYPE)
|
|
|
|
|
if (deviceType == "U32" || deviceType == "A3") {
|
|
|
|
|
/*if (deviceType == "U32" || deviceType == "A3") {
|
|
|
|
|
goPage(index - 1)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
if (deviceType == "X1" || deviceType == "X2") {
|
|
|
|
|
goPage(index - 2)
|
|
|
|
|
} else {
|
|
|
|
|
goPage(index - 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -222,7 +230,7 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
9 -> {
|
|
|
|
|
9 -> { //心电隐藏的前提下,尿酸为8 否则为9
|
|
|
|
|
val deviceType = MMkvHelper.getString(Const.DEVICE_TYPE)
|
|
|
|
|
if (deviceType == "X1" || deviceType == "X2") {
|
|
|
|
|
goPage(6)
|
|
|
|
@ -255,8 +263,10 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
10 -> { //血脂
|
|
|
|
|
when (MMkvHelper.getString(Const.DEVICE_TYPE)) {
|
|
|
|
|
10 -> { // //心电隐藏的前提下血脂为9 否则为10
|
|
|
|
|
|
|
|
|
|
CommonToastUtils.showToast("尊敬的用户您好,血脂功能暂未开放,敬请期待哦~")
|
|
|
|
|
/*when (MMkvHelper.getString(Const.DEVICE_TYPE)) {
|
|
|
|
|
"X1", "X2" -> {
|
|
|
|
|
goPage(7)
|
|
|
|
|
}
|
|
|
|
@ -269,11 +279,11 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
else -> {
|
|
|
|
|
goPage(7)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
8 -> {//心电
|
|
|
|
|
/*8 -> {//心电 暂时隐藏 尿酸就改成8
|
|
|
|
|
// if (MMkvHelper.getInt(Const.Watch_Device_Type) == -1) { //演示模式
|
|
|
|
|
// showToast("尊敬的用户您好,心电功能暂未开放,敬请期待哦~")
|
|
|
|
|
// } else
|
|
|
|
@ -289,7 +299,7 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
// RouteManager.goAct(ARouterUrl.XD_HISTORY, bundle)
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -338,7 +348,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
private fun setOnClickListener() {
|
|
|
|
|
binding.mMsgLayout.setOnClickListener(onClickListener)
|
|
|
|
|
binding.mMsg.setOnClickListener(onClickListener)
|
|
|
|
|
binding.mHeader.mWearManager.setOnClickListener(onClickListener)
|
|
|
|
|
binding.mHeader.mCard.setOnClickListener(onClickListener)
|
|
|
|
|
binding.mHeader.mBtnBind.setOnClickListener(onClickListener)
|
|
|
|
|
binding.mGriddingList.mSub.setOnClickListener(onClickListener)
|
|
|
|
@ -361,8 +370,8 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
RouteManager.goAct(ARouterUrl.WARNING_MSG)
|
|
|
|
|
}
|
|
|
|
|
//设备连接
|
|
|
|
|
R.id.mWearManager -> {
|
|
|
|
|
val btnStr = binding.mHeader.mWearManager.text
|
|
|
|
|
R.id.mHealthRecords -> {
|
|
|
|
|
/*val btnStr = binding.mHeader.mWearManager.text
|
|
|
|
|
if (btnStr == "佩戴管理") {
|
|
|
|
|
if (MMkvHelper.getInt(Const.Watch_Device_Type) == Const.Companion.WatchDevice.LightA3.ordinal) {//4G手表
|
|
|
|
|
RouteManager.goAct(ARouterUrl.WEAR_MANAGER)
|
|
|
|
@ -380,7 +389,7 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
RouteManager.goAct(ARouterUrl.DEVICE_CHOICE)
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
//评估
|
|
|
|
|
R.id.mCard -> {
|
|
|
|
@ -606,6 +615,20 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
mViewModel.getMySetting()
|
|
|
|
|
mViewModel.getTips()
|
|
|
|
|
mViewModel.getRank(2)
|
|
|
|
|
if(EasyPermissions.hasPermissions(requireContext(), Manifest.permission.ACCESS_COARSE_LOCATION,
|
|
|
|
|
Manifest.permission.ACCESS_FINE_LOCATION)) {
|
|
|
|
|
AmapInit.startLocation(requireContext()) {
|
|
|
|
|
MMkvHelper.put(Const.LONGITUDE,it.longitude)
|
|
|
|
|
MMkvHelper.put(Const.LATITUDE,it.latitude)
|
|
|
|
|
mViewModel.getWeather()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
EasyPermissions.requestPermissions(this,"申请定位权限",
|
|
|
|
|
0x00022,
|
|
|
|
|
Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -750,6 +773,47 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置天气信息
|
|
|
|
|
*/
|
|
|
|
|
private fun setWeatherInfo(weather: MainBean.Weather?) {
|
|
|
|
|
if (null == weather) {
|
|
|
|
|
binding.mHeader.tvWeather.visibility = View.GONE
|
|
|
|
|
} else {
|
|
|
|
|
weather.apply {
|
|
|
|
|
if (weatherNo.isNullOrEmpty()) {
|
|
|
|
|
binding.mHeader.tvWeather.visibility = View.GONE
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var icon = when (weatherNo) {
|
|
|
|
|
"32" -> {//晴天
|
|
|
|
|
"晴天"
|
|
|
|
|
}
|
|
|
|
|
"44" -> {//多云
|
|
|
|
|
"多云"
|
|
|
|
|
}
|
|
|
|
|
"20" -> {//阴天
|
|
|
|
|
"阴天"
|
|
|
|
|
}
|
|
|
|
|
"12" -> {//雨天
|
|
|
|
|
"雨天"
|
|
|
|
|
}
|
|
|
|
|
"45" -> {//雷阵雨
|
|
|
|
|
"雷阵雨"
|
|
|
|
|
}
|
|
|
|
|
"16" -> {//雪
|
|
|
|
|
"雪"
|
|
|
|
|
}
|
|
|
|
|
else -> {
|
|
|
|
|
"晴天"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binding.mHeader.tvWeather.text = "${icon} ${weatherInfo}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有信息
|
|
|
|
|
*/
|
|
|
|
@ -814,6 +878,15 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mViewModel.weatherLiveDate.observe(this){
|
|
|
|
|
if(it.data == null){
|
|
|
|
|
binding.mHeader.tvWeather.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
binding.mHeader.tvWeather.text = "${it.data.text} ${it.data.temp}℃"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取首页所有信息返回
|
|
|
|
|
mViewModel.allData.observe(this) {
|
|
|
|
|
it.data.let { bean ->
|
|
|
|
@ -824,60 +897,36 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
(requireActivity() as MainActivity).isDemonstrate = isDemonstrate
|
|
|
|
|
if (isDemonstrate) {
|
|
|
|
|
binding.mHeader.mWearInfo.visibility = View.INVISIBLE
|
|
|
|
|
binding.mHeader.mWatchType.visibility = View.INVISIBLE
|
|
|
|
|
} else {
|
|
|
|
|
binding.mHeader.mWatchType.visibility = View.GONE
|
|
|
|
|
binding.mHeader.mWearInfo.visibility = View.VISIBLE
|
|
|
|
|
}
|
|
|
|
|
/*if (mFamilyAdapter.position != -1) {
|
|
|
|
|
if (mFamilyAdapter.getItem(mFamilyAdapter.position).userJointId != bean.user.id.toInt()) {
|
|
|
|
|
if (mFamilyAdapter.position == 0 && bean.user.id.toString() == CommonUtils.getMyUserId()) {//如果是自己加载用户头像并保存用户信息
|
|
|
|
|
} else {
|
|
|
|
|
LogUtils.e("当前用户与请求用户信息不一致,不作处理!")
|
|
|
|
|
return@observe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (showIdInfo.isNotEmpty()) { //自己
|
|
|
|
|
//// binding.mChildView.mGuide2.visibility = View.VISIBLE
|
|
|
|
|
// binding.mChildView.mInter.visibility = View.VISIBLE
|
|
|
|
|
// binding.mChildView.lleach.visibility = View.VISIBLE
|
|
|
|
|
// } else {
|
|
|
|
|
//// binding.mChildView.mGuide2.visibility = View.GONE//隐藏健康管家
|
|
|
|
|
// binding.mChildView.mInter.visibility = View.GONE//隐藏健康互动标题
|
|
|
|
|
// binding.mChildView.lleach.visibility = View.GONE//隐藏健康打卡,榜单,我的家人功能
|
|
|
|
|
Const.otherLiveData.value = bean
|
|
|
|
|
}
|
|
|
|
|
// setWeatherInfo(bean.weather)
|
|
|
|
|
Const.battery = bean.power
|
|
|
|
|
Const.watchType = bean.watchType
|
|
|
|
|
MMkvHelper.put(Const.Watch_Device_Type, bean.watchType)
|
|
|
|
|
|
|
|
|
|
binding.mHeader.tvNowTime.text = bean.nowDay
|
|
|
|
|
binding.mHeader.tvLanuDate.text = bean.chinaDay
|
|
|
|
|
// setWeatherInfo(bean.weather)
|
|
|
|
|
|
|
|
|
|
binding.mHeader.mBMI.text = "BMI ${bean.bmiInfo.bmi}"
|
|
|
|
|
binding.mHeader.mBMIStatus.text = "${bean.bmiInfo.levelName}"
|
|
|
|
|
|
|
|
|
|
binding.mHeader.tvWarningNum.text ="预警次数:${if (bean.warningCount == 0) "--" else bean.warningCount}次"
|
|
|
|
|
binding.mHeader.tvMonitorNum.text ="监测次数:${if (bean.healthCount == 0) "--" else bean.healthCount}次"
|
|
|
|
|
|
|
|
|
|
/*if (bean.watchType == -1) { //没有绑定设备
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bean.watchType == -1) { //没有绑定设备
|
|
|
|
|
binding.mHeader.mBindState.apply {
|
|
|
|
|
text = "未绑定"
|
|
|
|
|
val drawable = getDrawable(R.mipmap.ic_unbind)
|
|
|
|
|
drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
|
|
|
|
|
setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
visibility = View.VISIBLE
|
|
|
|
|
}
|
|
|
|
|
binding.mHeader.mWearManager.text = "绑定手表"
|
|
|
|
|
|
|
|
|
|
binding.mHeader.mBindState.visibility = View.GONE
|
|
|
|
|
binding.mHeader.mConnectStatu.visibility = View.GONE
|
|
|
|
|
binding.mHeader.mWatchType.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
} else if (Const.Companion.WatchDevice.LightA3.ordinal == bean.watchType) {//如果是4G设备,设置连接状态与电量信息
|
|
|
|
|
setDeviceInfo(
|
|
|
|
|
DeviceInfoBean(
|
|
|
|
|
true,
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connected,
|
|
|
|
|
if (Const.battery.isEmpty()) "" else "电量${Const.battery}%"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
} else {*/
|
|
|
|
|
if (showIdInfo.isEmpty()) { //自己
|
|
|
|
|
val localBlueMac = MMkvHelper.getString(Const.Blue_Tooth)
|
|
|
|
|
if (YCBBlueConnectHelper.getBleNowStatus() == YCBBlueConnectHelper.BLEConnectState.DisConnect) {//如果本地有蓝牙信息且属于未连接状态,则直接连接
|
|
|
|
@ -892,9 +941,9 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
getConnectStatus()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setDeviceInfo(null)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
get24HourReportInfo(showIdInfo)// 这里调用一次接口,防止首次进入App不会刷新评估状态
|
|
|
|
|
|
|
|
|
@ -948,6 +997,8 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//24小时健康报告返回信息
|
|
|
|
|
mViewModel.infoLive.observe(this) {
|
|
|
|
|
if (null == it.data) {
|
|
|
|
@ -1037,7 +1088,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
// binding.mContent.visibility = View.VISIBLE
|
|
|
|
|
binding.mHeader.mLayoutResult.visibility = View.GONE
|
|
|
|
|
binding.mHeader.mBtnBind.visibility = View.VISIBLE
|
|
|
|
|
setDeviceInfo(DeviceInfoBean(false))
|
|
|
|
|
// if (!(activity as MainActivity).isDialogShow) {
|
|
|
|
|
// dialogBind.show()
|
|
|
|
|
// }
|
|
|
|
@ -1068,13 +1118,7 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Const.Companion.WatchDevice.LightA3.ordinal == Const.watchType) {//如果是4G设备,设置连接状态与电量信息
|
|
|
|
|
setDeviceInfo(
|
|
|
|
|
DeviceInfoBean(
|
|
|
|
|
true,
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connected,
|
|
|
|
|
if (Const.battery.isEmpty()) "" else "电量${Const.battery}%"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
get24HourReportInfo(showIdInfo)// 这里调用一次接口,防止首次进入App不会刷新评估状态
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1130,13 +1174,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
mainScope.launch {
|
|
|
|
|
LogUtils.d("getDeviceInfo isOk:$isok;;; value=$value")
|
|
|
|
|
if (isok) {//获取到设备信息,设备准备就绪上传手表数据
|
|
|
|
|
setDeviceInfo(
|
|
|
|
|
DeviceInfoBean(
|
|
|
|
|
true,
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connected,
|
|
|
|
|
value
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1374,15 +1411,7 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
mainScope.launch(Dispatchers.Main) {
|
|
|
|
|
when (connectState) {
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connecting -> {
|
|
|
|
|
setDeviceInfo(
|
|
|
|
|
DeviceInfoBean(
|
|
|
|
|
true,
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connecting
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
// binding.mContent.visibility = View.GONE
|
|
|
|
|
// binding.mEle.visibility = View.VISIBLE
|
|
|
|
|
// binding.mEle.text = getString(R.string.blue_tooth_connecting)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connected -> {
|
|
|
|
@ -1491,16 +1520,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
mainScope.launch {
|
|
|
|
|
LogUtils.d("getDeviceInfo isOk:$isok;;; value=$value")
|
|
|
|
|
if (isok) {//获取到设备信息,设备准备就绪上传手表数据
|
|
|
|
|
// binding.mCom.visibility = View.GONE
|
|
|
|
|
// binding.mEle.visibility = View.VISIBLE
|
|
|
|
|
// binding.mEle.text = value
|
|
|
|
|
setDeviceInfo(
|
|
|
|
|
DeviceInfoBean(
|
|
|
|
|
true,
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connected,
|
|
|
|
|
value
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
uploadWhatchData()
|
|
|
|
|
|
|
|
|
@ -1562,9 +1581,7 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private fun initBlueToothStatu() {
|
|
|
|
|
setDeviceInfo(DeviceInfoBean(blueTooth(), YCBBlueConnectHelper.BLEConnectState.DisConnect))
|
|
|
|
|
// binding.mContent.visibility = View.VISIBLE
|
|
|
|
|
// binding.mEle.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun requestGPSPermission() {
|
|
|
|
@ -1644,134 +1661,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
mViewModel.get24HourReportInfo(userId, isShowLoading)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun updateWarningStatus() {
|
|
|
|
|
/*val position = mFamilyAdapter.position
|
|
|
|
|
if (position == 0 || position == -1) {
|
|
|
|
|
if (notifyStatus == 0) {
|
|
|
|
|
//未读
|
|
|
|
|
binding.mHeader.llWarning.visibility = View.VISIBLE
|
|
|
|
|
} else {
|
|
|
|
|
//已读
|
|
|
|
|
binding.mHeader.llWarning.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
binding.mHeader.llWarning.visibility = View.GONE
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置设备信息
|
|
|
|
|
*/
|
|
|
|
|
private fun setDeviceInfo(deviceInfo: DeviceInfoBean?) {
|
|
|
|
|
if (null != deviceInfo) {
|
|
|
|
|
if (blueTooth()) {
|
|
|
|
|
binding.mHeader.mWatchType.text = getString(R.string.blue_tooth)
|
|
|
|
|
val drawable = getDrawable(R.mipmap.ic_watch_bluetooth)
|
|
|
|
|
drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
|
|
|
|
|
binding.mHeader.mWatchType.setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
} else {
|
|
|
|
|
binding.mHeader.mWatchType.text = getString(R.string.lite_4g)
|
|
|
|
|
val drawable = getDrawable(R.mipmap.ic_watch_4g)
|
|
|
|
|
drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
|
|
|
|
|
binding.mHeader.mWatchType.setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
}
|
|
|
|
|
binding.mHeader.mBindState.visibility = View.VISIBLE
|
|
|
|
|
if (deviceInfo.bindState) {//已绑定
|
|
|
|
|
binding.mHeader.mBindState.apply {
|
|
|
|
|
text = "已绑定"
|
|
|
|
|
background = null
|
|
|
|
|
val drawable = getDrawable(R.mipmap.ic_bangding)
|
|
|
|
|
drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
|
|
|
|
|
setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
}
|
|
|
|
|
binding.mHeader.mWearManager.text = "佩戴管理"
|
|
|
|
|
|
|
|
|
|
when (deviceInfo.connectState) {
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connected -> {//已连接
|
|
|
|
|
binding.mHeader.mConnectStatu.apply {
|
|
|
|
|
setBackgroundResource(R.drawable.shape_bind_bg_new_2)
|
|
|
|
|
text = deviceInfo.battery
|
|
|
|
|
setTextColor(resources.getColor(R.color.col_27B8, null))
|
|
|
|
|
var drawable: Drawable = getDrawable(R.mipmap.ic_battery)
|
|
|
|
|
if (!deviceInfo.battery.isNullOrEmpty()) {
|
|
|
|
|
val str =
|
|
|
|
|
deviceInfo.battery.substring(2, deviceInfo.battery.length - 1)
|
|
|
|
|
val pattern: Pattern = Pattern.compile("[0-9]*")
|
|
|
|
|
val isNum: Matcher = pattern.matcher(str)
|
|
|
|
|
if (isNum.matches()) {
|
|
|
|
|
val battery = str.toInt()
|
|
|
|
|
drawable = if (battery > 20) {
|
|
|
|
|
getDrawable(R.mipmap.ic_battery)
|
|
|
|
|
// } else if (battery > 70) {
|
|
|
|
|
// getDrawable(R.mipmap.ic_battery_90)
|
|
|
|
|
// } else if (battery > 50) {
|
|
|
|
|
// getDrawable(R.mipmap.ic_battery_70)
|
|
|
|
|
// } else if (battery > 30) {
|
|
|
|
|
// getDrawable(R.mipmap.ic_battery_50)
|
|
|
|
|
// } else if (battery > 10) {
|
|
|
|
|
// getDrawable(R.mipmap.ic_battery_30)
|
|
|
|
|
} else {
|
|
|
|
|
setTextColor(resources.getColor(R.color.col_2628, null))
|
|
|
|
|
text =
|
|
|
|
|
context.resources.getString(R.string.health_low_battery)
|
|
|
|
|
setBackgroundResource(R.drawable.shape_bind_bg_new_1)
|
|
|
|
|
getDrawable(R.mipmap.ic_diancbuz)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
drawable.setBounds(
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
drawable.minimumWidth,
|
|
|
|
|
drawable.minimumHeight
|
|
|
|
|
)
|
|
|
|
|
setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.Connecting -> {//连接中
|
|
|
|
|
binding.mHeader.mConnectStatu.apply {
|
|
|
|
|
text = "连接中..."
|
|
|
|
|
setCompoundDrawables(null, null, null, null)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
YCBBlueConnectHelper.BLEConnectState.DisConnect -> {//未连接
|
|
|
|
|
binding.mHeader.mConnectStatu.apply {
|
|
|
|
|
text = "未连接"
|
|
|
|
|
val drawable = getDrawable(R.mipmap.ic_not_connect)
|
|
|
|
|
drawable.setBounds(
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
drawable.minimumWidth,
|
|
|
|
|
drawable.minimumHeight
|
|
|
|
|
)
|
|
|
|
|
setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
binding.mHeader.mConnectStatu.visibility = View.GONE
|
|
|
|
|
} else {
|
|
|
|
|
binding.mHeader.mBindState.apply {
|
|
|
|
|
text = "未绑定"
|
|
|
|
|
val drawable = getDrawable(R.mipmap.ic_unbind)
|
|
|
|
|
drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
|
|
|
|
|
setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
}
|
|
|
|
|
binding.mHeader.mWearManager.text = "绑定手表"
|
|
|
|
|
|
|
|
|
|
binding.mHeader.mConnectStatu.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
binding.mHeader.mWatchType.text = getString(R.string.blue_tooth)
|
|
|
|
|
val drawable = getDrawable(R.mipmap.ic_watch_bluetooth)
|
|
|
|
|
drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
|
|
|
|
|
binding.mHeader.mWatchType.setCompoundDrawables(drawable, null, null, null)
|
|
|
|
|
binding.mHeader.mBindState.visibility = View.GONE
|
|
|
|
|
binding.mHeader.mConnectStatu.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun blueTooth(): Boolean {
|
|
|
|
|
return CommonUtils.isBlueTooth(MMkvHelper.getInt(Const.Watch_Device_Type))
|
|
|
|
@ -1824,7 +1713,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
mViewModel.getAllInfo(event.showUserId, false)
|
|
|
|
|
getXtInfo(event.showUserId)
|
|
|
|
|
get24HourReportInfo(event.showUserId)
|
|
|
|
|
updateWarningStatus()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
|
@ -1841,4 +1729,16 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>() {
|
|
|
|
|
fun loginOutChange(event: LoginOutEvent){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onPermissionsGranted(requestCode: Int, perms: MutableList<String>) {
|
|
|
|
|
AmapInit.startLocation(requireContext()) {
|
|
|
|
|
MMkvHelper.put(Const.LONGITUDE,it.longitude)
|
|
|
|
|
MMkvHelper.put(Const.LATITUDE,it.latitude)
|
|
|
|
|
mViewModel.getWeather()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onPermissionsDenied(requestCode: Int, perms: MutableList<String>) {
|
|
|
|
|
}
|
|
|
|
|
}
|