|
|
@ -1,12 +1,14 @@
|
|
|
|
package com.zj365.health.act.healthrecord
|
|
|
|
package com.zj365.health.act.healthrecord
|
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Color
|
|
|
|
import android.graphics.Color
|
|
|
|
|
|
|
|
import android.text.TextUtils
|
|
|
|
import android.util.Log
|
|
|
|
import android.util.Log
|
|
|
|
import android.view.View
|
|
|
|
import android.view.View
|
|
|
|
import androidx.core.view.get
|
|
|
|
import androidx.core.view.get
|
|
|
|
import androidx.core.view.size
|
|
|
|
import androidx.core.view.size
|
|
|
|
import androidx.core.widget.NestedScrollView
|
|
|
|
import androidx.core.widget.NestedScrollView
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
|
|
|
|
import cn.jpush.android.api.JPushInterface
|
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
|
import com.androidkun.xtablayout.XTabLayout
|
|
|
|
import com.androidkun.xtablayout.XTabLayout
|
|
|
|
import com.xty.base.act.BaseVmAct
|
|
|
|
import com.xty.base.act.BaseVmAct
|
|
|
@ -56,7 +58,7 @@ class HealthRecordMainAct : BaseVmAct<HealthRecordMainVm>() {
|
|
|
|
|
|
|
|
|
|
|
|
mViewModel.balanceDietBeanLiveData.observe(this){
|
|
|
|
mViewModel.balanceDietBeanLiveData.observe(this){
|
|
|
|
binding.tvDietCalorie.text = "${it.data.heat_val}"
|
|
|
|
binding.tvDietCalorie.text = "${it.data.heat_val}"
|
|
|
|
binding.proCho.progress = it.data.cho_percent.toInt()
|
|
|
|
binding.proCho.progress = it.data.cho_percent
|
|
|
|
binding.proFat.progress = it.data.fat_percent
|
|
|
|
binding.proFat.progress = it.data.fat_percent
|
|
|
|
binding.proProtein.progress = it.data.protein_percent
|
|
|
|
binding.proProtein.progress = it.data.protein_percent
|
|
|
|
binding.tvProteinPro.text = "${it.data.protein_percent}%"
|
|
|
|
binding.tvProteinPro.text = "${it.data.protein_percent}%"
|
|
|
@ -65,13 +67,17 @@ class HealthRecordMainAct : BaseVmAct<HealthRecordMainVm>() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mViewModel.healthArchiveLiveData.observe(this){
|
|
|
|
mViewModel.healthArchiveLiveData.observe(this){
|
|
|
|
binding.tvBmi.text = "${it.data.bmiInfo.bmi}"
|
|
|
|
mSurveysList.clear()
|
|
|
|
binding.tvBmiDesc.text = it.data.bmiInfo.levelName
|
|
|
|
it.data.bmiInfo?.let {
|
|
|
|
if (it.data.bmiInfo.levelName.equals("理想")){
|
|
|
|
binding.tvBmi.text = "${it.bmi}"
|
|
|
|
binding.tvBmiDesc.setTextColor(Color.parseColor("#02C191"))
|
|
|
|
binding.tvBmiDesc.text = it.levelName
|
|
|
|
|
|
|
|
if (it.levelName.equals("理想")){
|
|
|
|
|
|
|
|
binding.tvBmiDesc.setTextColor(Color.parseColor("#02C191"))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
binding.tvBmr.text = "${it.data.bmr}"
|
|
|
|
|
|
|
|
binding.tvBodyFat.text = if(it.data.bodyFat == 0.00) { "--"} else NumUtils.formatter(it.data.bodyFat,"###.00")
|
|
|
|
binding.tvBmr.text = if(it.data.bmr == 0.00) { "--"} else "${it.data.bmr}"
|
|
|
|
|
|
|
|
binding.tvBodyFat.text = if(TextUtils.isEmpty(it.data.bodyFat)) { "--"} else it.data.bodyFat
|
|
|
|
binding.mProgress.progress = it.data.userSchedule * 10
|
|
|
|
binding.mProgress.progress = it.data.userSchedule * 10
|
|
|
|
binding.clBody.tvScore.text = "${it.data.surveys.score}"
|
|
|
|
binding.clBody.tvScore.text = "${it.data.surveys.score}"
|
|
|
|
mSurveysList = it.data.surveys.list
|
|
|
|
mSurveysList = it.data.surveys.list
|
|
|
@ -80,6 +86,25 @@ class HealthRecordMainAct : BaseVmAct<HealthRecordMainVm>() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mViewModel.settingLive.observe(this) {
|
|
|
|
|
|
|
|
if (null == it.data) return@observe
|
|
|
|
|
|
|
|
it.data.let { settingBean ->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.tvName.text = settingBean.user.name
|
|
|
|
|
|
|
|
if (settingBean.user.avatarUrl.isNullOrEmpty()) {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageResource(R.mipmap.icon_default_avator)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageUser(
|
|
|
|
|
|
|
|
this,
|
|
|
|
|
|
|
|
settingBean.user.avatarUrl,
|
|
|
|
|
|
|
|
settingBean.user.sex.toString()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Const.mainLiveData.value = settingBean
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun initView() {
|
|
|
|
override fun initView() {
|
|
|
@ -90,46 +115,25 @@ class HealthRecordMainAct : BaseVmAct<HealthRecordMainVm>() {
|
|
|
|
finish()
|
|
|
|
finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mViewModel.getBalanceDiet()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mViewModel.getHealthArchive()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initTab()
|
|
|
|
initTab()
|
|
|
|
// initSurvey()
|
|
|
|
// initSurvey()
|
|
|
|
initAdapter()
|
|
|
|
initAdapter()
|
|
|
|
initClickListener()
|
|
|
|
initClickListener()
|
|
|
|
|
|
|
|
|
|
|
|
Const.mainLiveData.observe(this){
|
|
|
|
|
|
|
|
binding.tvName.text = it.user.name
|
|
|
|
|
|
|
|
if (it.user.avatarUrl.isNullOrEmpty()) {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageResource(R.mipmap.icon_default_avator)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageUser(
|
|
|
|
|
|
|
|
this,
|
|
|
|
|
|
|
|
it.user.avatarUrl,
|
|
|
|
|
|
|
|
it.user.sex.toString()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Const.mainLiveData.value?.let {
|
|
|
|
|
|
|
|
binding.tvName.text = it.user.name
|
|
|
|
|
|
|
|
if (it.user.avatarUrl.isNullOrEmpty()) {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageResource(R.mipmap.icon_default_avator)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageUser(
|
|
|
|
|
|
|
|
this,
|
|
|
|
|
|
|
|
it.user.avatarUrl,
|
|
|
|
|
|
|
|
it.user.sex.toString()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun initClickListener(){
|
|
|
|
fun initClickListener(){
|
|
|
|
binding.llInquiryRecord.setOnClickListener {
|
|
|
|
binding.llInquiryRecord.setOnClickListener {
|
|
|
|
|
|
|
|
bundle.clear()
|
|
|
|
|
|
|
|
bundle.putString(
|
|
|
|
|
|
|
|
"web_site_url",
|
|
|
|
|
|
|
|
"${BuildConfig.h5url}pages/index/index?pageId=inquiries"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
RouteManager.goAct(ARouterUrl.H5_ACT, bundle)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binding.tvDairyRecords.setOnClickListener {
|
|
|
|
binding.tvDairyRecords.setOnClickListener {
|
|
|
@ -170,18 +174,8 @@ class HealthRecordMainAct : BaseVmAct<HealthRecordMainVm>() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun initSurvey(surveysList: ArrayList<HealthArchiveBean.SurveysInfoBean>){
|
|
|
|
fun initSurvey(surveysList: ArrayList<HealthArchiveBean.SurveysInfoBean>){
|
|
|
|
/* var surveyList = ArrayList<String>()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surveyList.add("免疫系统")
|
|
|
|
|
|
|
|
surveyList.add("神经系统")
|
|
|
|
|
|
|
|
surveyList.add("内分泌系统")
|
|
|
|
|
|
|
|
surveyList.add("泌尿系统")
|
|
|
|
|
|
|
|
surveyList.add("生殖系统")
|
|
|
|
|
|
|
|
surveyList.add("运动系统")
|
|
|
|
|
|
|
|
surveyList.add("心脑血管")
|
|
|
|
|
|
|
|
surveyList.add("消化系统")
|
|
|
|
|
|
|
|
surveyList.add("呼吸系统")*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.clBody.surveyView.removeAllViews()
|
|
|
|
binding.clBody.surveyView.setMenuItemTexts(surveysList)
|
|
|
|
binding.clBody.surveyView.setMenuItemTexts(surveysList)
|
|
|
|
|
|
|
|
|
|
|
|
binding.clBody.surveyView.setOnClicklisteners(object : HealthSurveyView.onItemClicked{
|
|
|
|
binding.clBody.surveyView.setOnClicklisteners(object : HealthSurveyView.onItemClicked{
|
|
|
@ -303,4 +297,26 @@ class HealthRecordMainAct : BaseVmAct<HealthRecordMainVm>() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun setLayout() = binding.root
|
|
|
|
override fun setLayout() = binding.root
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onResume() {
|
|
|
|
|
|
|
|
super.onResume()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mViewModel.getBalanceDiet()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mViewModel.getHealthArchive()
|
|
|
|
|
|
|
|
Const.mainLiveData.value?.let {
|
|
|
|
|
|
|
|
binding.tvName.text = it.user.name
|
|
|
|
|
|
|
|
if (it.user.avatarUrl.isNullOrEmpty()) {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageResource(R.mipmap.icon_default_avator)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
binding.imgAvatar.setImageUser(
|
|
|
|
|
|
|
|
this,
|
|
|
|
|
|
|
|
it.user.avatarUrl,
|
|
|
|
|
|
|
|
it.user.sex.toString()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Const.mainLiveData.value?:mViewModel.getMySetting()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|