中建365-家人实时测量开发

develop
wlh 1 year ago
parent 72f96fff0e
commit 27a3e0f31f

@ -805,7 +805,6 @@ class DynamicManagementFrag : BaseVmFrag<DynamicManagementVm>(){
healthMonitoringListExceed.clear()
mHealthAdapter.mainBean.clear()
LogUtils.e("DynamicManagementFrag","11111111")
val healthMonitoringListData = mViewModel.setHealthMonitoringListData(
requireContext(),

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

@ -94,7 +94,9 @@ class FamilyHealthAct : BaseListAct<FamilyHealthVm>() {
RouteManager.goAct(ARouterUrl.FAMILY_GUARDIAN_LIST_ACT)
}
R.id.tv_current_time ->{
// RouteManager.goAct(ARouterUrl.FAMILY_HEALTH_REAL_TIME_ACT)
bundle.clear()
bundle.putLong("id",familyHealthBean.userId)
RouteManager.goAct(ARouterUrl.FAMILY_HEALTH_REAL_TIME_ACT,bundle)
}
R.id.tv_watch ->{

@ -1,60 +1,110 @@
package com.zj365.health.act.familyhealth
import android.graphics.Rect
import android.annotation.SuppressLint
import android.os.Bundle
import android.os.CountDownTimer
import android.util.Log
import android.view.View
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.facade.annotation.Route
import com.amap.api.location.AMapLocationClient
import com.amap.api.location.AMapLocationClientOption
import com.amap.api.maps.AMap
import com.amap.api.maps.CameraUpdateFactory
import com.amap.api.maps.UiSettings
import com.amap.api.maps.model.BitmapDescriptor
import com.amap.api.maps.model.BitmapDescriptorFactory
import com.amap.api.maps.model.CameraPosition
import com.amap.api.maps.model.LatLng
import com.amap.api.maps.model.Marker
import com.amap.api.maps.model.MarkerOptions
import com.amap.api.maps.model.MyLocationStyle
import com.xty.base.act.BaseVmAct
import com.xty.base.vm.BaseVm
import com.xty.common.arouter.ARouterUrl
import com.xty.network.model.WatchCurrentTimeBean
import com.zj365.health.R
import com.zj365.health.adapter.familyhealth.FamilyHealthRealTimeAdapter
import com.zj365.health.databinding.ActFamilyHealthRealTimeBinding
import com.zj365.health.vm.FamilyHealthRealTimeVm
import java.util.Timer
import java.util.TimerTask
/**
* 家人健康-实时
*/
@Route(path = ARouterUrl.FAMILY_HEALTH_REAL_TIME_ACT)
class FamilyHealthRealTimeAct : BaseVmAct<BaseVm>() {
class FamilyHealthRealTimeAct : BaseVmAct<FamilyHealthRealTimeVm>() {
val binding by lazy { ActFamilyHealthRealTimeBinding.inflate(layoutInflater) }
val mAdapter by lazy { FamilyHealthRealTimeAdapter() }
private var bitmapDescriptor: BitmapDescriptor? = null
private var aMap: AMap? = null
private var latLng = LatLng(28.206548, 112.893712) //坐标
var userId:Long = 0
var measureBeanList = ArrayList<WatchCurrentTimeBean.MeasureBean>()
var myLocationStyle = MyLocationStyle()
var countDownTimer:CountDownTimer? = null
override fun liveObserver() {
mViewModel.watchCurrentTimeLiveData.observe(this){
measureBeanList.clear()
var latLng = LatLng(it.data.gps.lat, it.data.gps.lng)
locationPoint(R.mipmap.icon_location_market,latLng)
measureBeanList.add(WatchCurrentTimeBean.MeasureBean(1,it.data.tiwen.time,it.data.tiwen.v))
measureBeanList.add(WatchCurrentTimeBean.MeasureBean(2,it.data.xinlv.time,it.data.xinlv.v))
measureBeanList.add(WatchCurrentTimeBean.MeasureBean(3,it.data.xueya.time,it.data.xueya.v))
measureBeanList.add(WatchCurrentTimeBean.MeasureBean(4,it.data.xueyang.time,it.data.xueyang.v))
binding.tvTips.visibility = View.GONE
mAdapter.setNewInstance(measureBeanList)
}
}
fun timeStart() {
countDownTimer =object : CountDownTimer(60*1000,1000){//1000ms运行一次onTick里面的方法
override fun onFinish() {
loadingView.dismiss()
mViewModel.getWatchCurrentTime(userId)
}
override fun onTick(millisUntilFinished: Long) {
loadingView.binding.tipTextView.text = "测量中"
loadingView.show()
}
}.start()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.mapView.onCreate(savedInstanceState)
}
override fun initView() {
super.initView()
statusBar(binding.title.mView)
binding.title.mTvTitle.text ="实时详情"
userId = intent.extras!!.getLong("id")
binding.title.mIvBack.setOnClickListener {
finish()
}
initAdapter()
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(R.mipmap.icon_location_market))
mViewModel.getWatchCurrentTime(userId)
aMap = binding.mapView.map
aMap?.let {
val uiSettings: UiSettings = it.uiSettings
uiSettings.setLogoBottomMargin(-50) //隐藏logo
uiSettings.isZoomControlsEnabled=false
var cameraUpdate = CameraUpdateFactory.newCameraPosition(
CameraPosition(latLng, 15f, 0f, 0f)
)
it.moveCamera(cameraUpdate)
}
}
fun initAdapter(){
@ -64,8 +114,57 @@ class FamilyHealthRealTimeAct : BaseVmAct<BaseVm>() {
dividerItemDecoration.setDrawable(resources.getDrawable(R.drawable.shape_ebf_0_5))
binding.recycler.addItemDecoration(dividerItemDecoration)
mAdapter.addChildClickViewIds(R.id.tv_real_time_mearsure)
mAdapter.setOnItemChildClickListener{adapter, view, position ->
val measureBean = adapter.data[position] as WatchCurrentTimeBean.MeasureBean
timeStart()
mViewModel.measureData(userId,measureBean.type)
binding.tvTips.visibility = View.VISIBLE
}
}
override fun setLayout() = binding.root
private fun locationPoint(makerRes:Int,latLng:LatLng) {
aMap?.let {
bitmapDescriptor=BitmapDescriptorFactory
.fromResource(makerRes)
val cameraUpdate = CameraUpdateFactory.newCameraPosition(CameraPosition(latLng,15f,0f,0f))
it.moveCamera(cameraUpdate)
it.clear()
it.addMarker(MarkerOptions().position(latLng)
.icon(bitmapDescriptor)
)
}
}
override fun onDestroy() {
super.onDestroy()
binding.mapView.onDestroy()
countDownTimer?.cancel()
countDownTimer = null
}
override fun onPause() {
super.onPause()
binding.mapView.onPause()
}
override fun onResume() {
super.onResume()
binding.mapView.onResume()
}
@SuppressLint("MissingSuperCall")
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
binding.mapView.onSaveInstanceState(outState)
}
}

@ -1,11 +1,62 @@
package com.zj365.health.adapter.familyhealth
import android.graphics.Typeface
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.common.util.SpannableUtils
import com.xty.network.model.WatchCurrentTimeBean
import com.zj365.health.R
class FamilyHealthRealTimeAdapter : BaseAdapter<Any>(R.layout.item_family_health_real_time) {
override fun convert(holder: BaseViewHolder, item: Any) {
class FamilyHealthRealTimeAdapter : BaseAdapter<WatchCurrentTimeBean.MeasureBean>(R.layout.item_family_health_real_time) {
//器官名
private val units = arrayOf(
R.string.info_4_unit, R.string.info_1_unit, R.string.info_2_unit, R.string.info_3_unit
)
override fun convert(holder: BaseViewHolder, item: WatchCurrentTimeBean.MeasureBean) {
var imgTarget = holder.getView<ImageView>(R.id.img_body)
holder.setText(R.id.tv_update,"更新时间:${item.time}")
var tvValue = holder.getView<TextView>(R.id.tv_body_name)
var typeName = "心率:"
when(item.type){
1 ->{
imgTarget.setImageResource(R.mipmap.ic_temp)
typeName = "体温:"
}
2 ->{
imgTarget.setImageResource(R.mipmap.ic_xl)
typeName = "心率:"
}
3 ->{
imgTarget.setImageResource(R.mipmap.ic_xya)
typeName = "血压:"
}
4 ->{
imgTarget.setImageResource(R.mipmap.ic_oo)
typeName = "血氧:"
}
}
tvValue.text = SpannableUtils.setStrSpan(
"${typeName}${item.value}${context.getString(units[item.type-1])}",
14,
ContextCompat.getColor(
context, R.color.col_313
),
Typeface.BOLD,
0,
"${typeName}${item.value}${context.getString(units[item.type-1])}".length -
context.getString(units[item.type-1]).length)
}
}

@ -0,0 +1,34 @@
package com.zj365.health.vm
import androidx.lifecycle.MutableLiveData
import com.alibaba.fastjson.JSONObject
import com.xty.base.vm.BaseVm
import com.xty.network.model.RespBody
import com.xty.network.model.WatchCurrentTimeBean
class FamilyHealthRealTimeVm : BaseVm() {
val watchCurrentTimeLiveData by lazy { MutableLiveData<RespBody<WatchCurrentTimeBean>>() }
val measureLiveData by lazy { MutableLiveData<RespBody<Any>>() }
fun getWatchCurrentTime(id:Long){
startHttp {
var json = JSONObject()
json.put("id",id)
val request = apiInterface().getWatchCurrentTime(retrofits.getRequestBody(json.toString()))
request.getCodeStatus(watchCurrentTimeLiveData,nowData)
}
}
fun measureData(id:Long,type:Int){
startHttp (false){
var json = JSONObject()
json.put("id",id)
json.put("type",type)
val request = apiInterface().measureWatchData(retrofits.getRequestBody(json.toString()))
request.getCodeStatus(measureLiveData,nowData)
}
}
}

@ -11,7 +11,7 @@
<com.amap.api.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_317"/>
android:layout_height="@dimen/dp_350"/>
<LinearLayout
android:layout_width="match_parent"
@ -49,11 +49,13 @@
</LinearLayout>
<TextView
android:id="@+id/tv_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="手环正在测量中需等待1分钟左右"
android:textSize="@dimen/sp_13"
android:textColor="@color/col_c7c"
android:visibility="gone"
android:layout_marginTop="@dimen/dp_13"/>
<androidx.recyclerview.widget.RecyclerView

@ -13,8 +13,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/col_313"
android:textSize="@dimen/sp_13"
android:textSize="@dimen/sp_10"
tools:text="心率100次/分"
android:textStyle="bold"
android:layout_marginLeft="@dimen/dp_7"
android:layout_toRightOf="@+id/img_body"
android:id="@+id/tv_body_name"/>
@ -36,9 +37,9 @@
android:text="实时测量"
android:gravity="center"
android:textColor="@color/col_02c"
android:textSize="12sp"
android:textSize="@dimen/sp_12"
android:layout_alignParentEnd="true"
android:textStyle="bold"/>
/>

@ -1750,6 +1750,18 @@ interface ApiInterface {
@GET("customer/family/remove")
suspend fun exitCustody(@Query("id") id: String): RespBody<Any>
/**
* 获取手表实时数据
*/
@POST("customer/watch/realData")
suspend fun getWatchCurrentTime(@Body rb: RequestBody):RespBody<WatchCurrentTimeBean>
/**
* 实时测量
*/
@POST("customer/watch/realmeas")
suspend fun measureWatchData(@Body rb: RequestBody):RespBody<Any>
/**
* 获取演示模式

@ -8,6 +8,8 @@ data class FamilyHealthBean (
var avatarUrl:String,
var isMy:Int, //是否本人01
var power:String?, //电量
var isRealTime:Int ,//是否实时01
var dataList: ArrayList<FamilyTargetBean> ,//数据列表
var avatarList:ArrayList<String>?
) {

@ -0,0 +1,17 @@
package com.xty.network.model
data class WatchCurrentTimeBean(
var xueya:BodyDataBean,
var xueyang:BodyDataBean,
var xinlv:BodyDataBean,
var tiwen:BodyDataBean,
var gps:GPSBean
) {
data class BodyDataBean(val v:String,val time:String)
data class GPSBean(val lng:Double,val lat:Double)
data class MeasureBean(var type:Int,var time:String,var value:String)
}
Loading…
Cancel
Save