中建365-家人实时测量开发
parent
72f96fff0e
commit
27a3e0f31f
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
@ -1,11 +1,62 @@
|
|||||||
package com.zj365.health.adapter.familyhealth
|
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.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||||
import com.xty.base.adapter.BaseAdapter
|
import com.xty.base.adapter.BaseAdapter
|
||||||
|
import com.xty.common.util.SpannableUtils
|
||||||
|
import com.xty.network.model.WatchCurrentTimeBean
|
||||||
import com.zj365.health.R
|
import com.zj365.health.R
|
||||||
|
|
||||||
class FamilyHealthRealTimeAdapter : BaseAdapter<Any>(R.layout.item_family_health_real_time) {
|
class FamilyHealthRealTimeAdapter : BaseAdapter<WatchCurrentTimeBean.MeasureBean>(R.layout.item_family_health_real_time) {
|
||||||
override fun convert(holder: BaseViewHolder, item: Any) {
|
//器官名
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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…
Reference in New Issue