From eda1955a7e89c63043fe3c50d0190e61c0f2d072 Mon Sep 17 00:00:00 2001 From: wlh <646507849@qq.com> Date: Fri, 19 Jan 2024 14:26:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E5=BB=BA365-=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=E5=BC=80=E5=8F=91-=E5=95=86=E5=9F=8E=E5=BC=80=E5=8F=91/AI?= =?UTF-8?q?=E7=B3=96=E5=8C=BB/=E8=A1=80=E8=84=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 + .../com/zj365/dc/activity/MainActivity.kt | 2 +- .../dc/activity/shop/CreateGoodsOrderAct.kt | 52 +- .../dc/fragment/DynamicManagementFrag.kt | 3 +- .../com/zj365/dc/fragment/HealthHomeFrag.kt | 11 + .../com/zj365/dc/vm/DynamicManagementVm.kt | 62 +- .../main/java/com/zj365/dc/vm/ShopMallVm.kt | 14 +- .../res/layout/act_create_goods_order.xml | 5 +- .../java/com/xty/base/h5/CloudJSBridge.kt | 6 +- .../com/xty/base/model/CreateOrderBean.kt | 23 + .../com/xty/base/utils/OrganStatusCalcUtil.kt | 20 +- .../main/java/com/xty/base/utils/PayUtils.kt | 135 +- .../java/com/xty/common/arouter/ARouterUrl.kt | 1 + .../zj365/health/act/BloodLipidAdjustAct.kt | 147 ++- .../health/act/BloodLipidAdjustRecordsAct.kt | 21 +- .../zj365/health/act/ComparePageDataAct.kt | 6 +- .../com/zj365/health/act/HealthMainAct.kt | 8 +- .../health/act/HealthSkyHourReportAct.kt | 283 +++- .../act/HealthWeekMonthHourReportAct.kt | 170 ++- .../com/zj365/health/act/PreventCancertAct.kt | 109 +- .../act/exception/AllExceptionDataActivity.kt | 29 +- .../health/act/skin/SkinMeasurementMainAct.kt | 184 +-- .../health/adapter/HealthSignDataAdapter.kt | 14 + .../adapter/bloodfat/BloodFatAdapter.kt | 4 +- .../bloodfat/BloodLipidAdjustAdapter.kt | 9 +- .../fragment/bloodlipid/BaseChartInitUtils.kt | 24 +- .../bloodlipid/BloodFatCompareDataFrag.kt | 594 +++++---- .../bloodlipid/BloodFatExceptionDataAct.kt | 21 +- .../bloodlipid/BloodFatExceptionFrag.kt | 62 +- .../fragment/bloodlipid/BloodFatFrag.kt | 423 +++--- .../bloodlipid/BloodLipidDataDealWithList.kt | 1165 ++++++++++++++--- .../bloodlipid/BloodLipidGetMinMaxChart.kt | 41 +- .../com/zj365/health/vm/BloodFatCompareVm.kt | 1 - .../com/zj365/health/vm/SkinMeasurementVm.kt | 18 +- .../res/layout/act_blood_lipid_adjust.xml | 16 +- .../res/layout/act_health_sky_hour_report.xml | 19 +- .../act_health_week_month_hour_report.xml | 19 +- .../res/layout/custom_marker_view_xuezhi.xml | 48 + .../layout/frag_blood_lipid_compare_data.xml | 122 +- health/src/main/res/layout/frag_boold_fat.xml | 59 +- health/src/main/res/layout/item_blood_fat.xml | 25 +- .../main/res/layout/item_health_sign_data.xml | 17 + .../main/java/com/xty/network/ApiInterface.kt | 14 +- .../com/xty/network/model/BloodFatBean.kt | 15 +- .../xty/network/model/BloodLipidDataBean.kt | 34 +- .../java/com/xty/network/model/ReportBean.kt | 173 +-- .../xty/network/model/ShopGoodsOrderBean.kt | 7 + 47 files changed, 2998 insertions(+), 1241 deletions(-) create mode 100644 base/src/main/java/com/xty/base/model/CreateOrderBean.kt create mode 100644 health/src/main/java/com/zj365/health/adapter/HealthSignDataAdapter.kt create mode 100644 health/src/main/res/layout/custom_marker_view_xuezhi.xml create mode 100644 health/src/main/res/layout/item_health_sign_data.xml create mode 100644 network/src/main/java/com/xty/network/model/ShopGoodsOrderBean.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7807c8e..6e0266e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -163,6 +163,10 @@ android:launchMode="singleTop" android:screenOrientation="portrait" /> + + (), Consumer { private fun addNv() { val menuView = binding.mBottom.getChildAt(0) as BottomNavigationMenuView //这里就是获取所添加的每一个Tab(或者叫menu), - val tab = menuView.getChildAt(2) as BottomNavigationItemView + val tab = menuView.getChildAt(3) as BottomNavigationItemView //加载我们的角标View,新创建的一个布局 badegView = LayoutInflater.from(this).inflate(R.layout.item_msg_count, tab, true) diff --git a/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt b/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt index a2344ac..50a1d6f 100644 --- a/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt +++ b/app/src/main/java/com/zj365/dc/activity/shop/CreateGoodsOrderAct.kt @@ -1,18 +1,43 @@ package com.zj365.dc.activity.shop +import android.view.LayoutInflater import android.view.View +import android.widget.ImageView +import android.widget.LinearLayout +import android.widget.TextView +import com.alibaba.android.arouter.facade.annotation.Route +import com.google.android.material.bottomsheet.BottomSheetDialog import com.xty.base.act.BaseVmAct +import com.xty.base.model.CreateOrderBean +import com.xty.base.utils.PayUtils import com.xty.base.vm.BaseVm import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager +import com.xty.common.setImage +import com.xty.common.util.SpannableUtils +import com.xty.network.model.ShopGoodsOrderBean import com.zj365.dc.BuildConfig import com.zj365.dc.databinding.ActCreateGoodsOrderBinding import com.zj365.dc.vm.ShopMallVm +import com.zj365.health.R +@Route(path = ARouterUrl.CREATE_SHOP_ORDER_ACT) class CreateGoodsOrderAct : BaseVmAct() { val binding by lazy { ActCreateGoodsOrderBinding.inflate(layoutInflater) } + + var bean:CreateOrderBean?= null + + var couponsId:Long? = null + var addrId:Long? = null + + var bottomSheetDialog: BottomSheetDialog? = null + override fun liveObserver() { + mViewModel.createOrderLiveData.observe(this){ + PayUtils(this).payForGoods(it.data.pay_price.toFloat(),it.data.order_no) + } + } override fun initView() { @@ -23,12 +48,36 @@ class CreateGoodsOrderAct : BaseVmAct() { finish() } + bean = intent.getParcelableExtra("bean") onClickedListener() + bean?.let { + refreshUI(it) + } + } + + fun refreshUI(bean: CreateOrderBean){ + binding.imgGoods.setImage(this,bean.pic) + binding.tvGoodsName.text = bean.prod_name + binding.tvSpec.text = bean.skuName + binding.tvNum.text = "数量:${bean.skuNum}" + binding.tvPrice.text = "商品原价:¥ ${bean.ori_price}" + binding.tvTotalPrice.text ="¥ ${bean.skuPrice * bean.skuNum}" + binding.tvPlatformDiscounts.text = "${(bean.ori_price * bean.skuNum) - (bean.skuPrice * bean.skuNum)}" + + if (bean.delivery_mode == 0){ //0,无需发货,1,需要发货 + binding.rxAddress.visibility = View.GONE + }else{ + binding.rxAddress.visibility = View.VISIBLE + } + + } fun onClickedListener(){ binding.tvPay.setOnClickListener { - + bean?.let { + mViewModel.createOrder(it.skuId.toString(),it.skuNum,addrId,couponsId) + } } binding.tvChooseAddress.setOnClickListener { @@ -53,4 +102,5 @@ class CreateGoodsOrderAct : BaseVmAct() { override fun setLayout()=binding.root + } \ No newline at end of file diff --git a/app/src/main/java/com/zj365/dc/fragment/DynamicManagementFrag.kt b/app/src/main/java/com/zj365/dc/fragment/DynamicManagementFrag.kt index aae0360..8901c14 100644 --- a/app/src/main/java/com/zj365/dc/fragment/DynamicManagementFrag.kt +++ b/app/src/main/java/com/zj365/dc/fragment/DynamicManagementFrag.kt @@ -227,7 +227,8 @@ class DynamicManagementFrag : BaseVmFrag() , EasyPermission } "bloodFat" -> { // //心电隐藏的前提下血脂为9 否则为10 - CommonToastUtils.showToast("尊敬的用户您好,血脂功能暂未开放,敬请期待哦~") + goPage(index - 1,functionType) + // CommonToastUtils.showToast("尊敬的用户您好,血脂功能暂未开放,敬请期待哦~") } "ecg" ->{ //心电 暂时隐藏 CommonToastUtils.showToast("尊敬的用户您好,心电功能暂未开放,敬请期待哦~") diff --git a/app/src/main/java/com/zj365/dc/fragment/HealthHomeFrag.kt b/app/src/main/java/com/zj365/dc/fragment/HealthHomeFrag.kt index aec31c5..e4a34ae 100644 --- a/app/src/main/java/com/zj365/dc/fragment/HealthHomeFrag.kt +++ b/app/src/main/java/com/zj365/dc/fragment/HealthHomeFrag.kt @@ -363,6 +363,17 @@ HealthHomeFrag : BaseVmFrag() { // CommonToastUtils.showToast("敬请期待") } + "AI_SUGAR_MEDICINE" ->{ + + bundle.clear() + bundle.putInt("type",1) + RouteManager.goAct(ARouterUrl.AI_SKIN_MEASUREMENT_ACTIVITY,bundle) + + } + "AI_SKIN" ->{ + + } + else ->{ CommonToastUtils.showToast("敬请期待") } diff --git a/app/src/main/java/com/zj365/dc/vm/DynamicManagementVm.kt b/app/src/main/java/com/zj365/dc/vm/DynamicManagementVm.kt index f5c37ce..f6c0b06 100644 --- a/app/src/main/java/com/zj365/dc/vm/DynamicManagementVm.kt +++ b/app/src/main/java/com/zj365/dc/vm/DynamicManagementVm.kt @@ -626,17 +626,69 @@ class DynamicManagementVm : BaseVm() { ) ) }else if(DeviceFunctionUtils.hasFunction(it,"bloodFat")){ //血脂 + //血脂 + var statusXZ = 0 + var contentXZ = "" + var mTimeXZ = "" + when (bloodFatData.status) { + //0 未开通 1:建模中 2:建模完成 + 0 -> { + if (TextUtils.isEmpty(bloodFatData.expireTime)) { + contentXZ = "未开通" + mTimeXZ = "免费体验100天" + statusXZ = 3 + } else { + contentXZ = "续费" + mTimeXZ = RxTimeTool.getCurrentDateTime("yyyy-MM-dd HH:mm") + statusXZ = 0 + } + } + + 1 -> { + statusXZ = 1 + contentXZ = "建模中" + mTimeXZ = if (bloodFatData.time.isNullOrEmpty()) { + "${RxTimeTool.getCurrentDateTime("yyyy-MM-dd HH")}:00" + } else if (bloodFatData.time.contains("-")) { + bloodFatData.time + } else { +// "${ +// RxTimeTool.simpleDateFormat( +// "yyyy-MM-dd HH", +// RxTimeTool.string2Date( +// "yyyy-MM-dd HH:mm:ss", +// bloodFatData.time +// ) +// ) +// }:00" + milliseconds2String(bloodFatData.time) + } + } + + 2 -> { + statusXZ = + if (bloodFatData.value == "0" || TextUtils.isEmpty(bloodFatData.value)) { + 0 + } else if (bloodFatData.message.contains("正常")) { + 1 + } else { + 2 + } + contentXZ = + if (!TextUtils.isEmpty(bloodFatData.value)) bloodFatData.value else "--" + mTimeXZ = milliseconds2String(bloodFatData.time) + } + } healthMonitoringList.add( HealthMonitoringListBean( "血脂", - 0, - "", - "敬请期待", + statusXZ, + mTimeXZ, + contentXZ, R.mipmap.bg_fat, R.mipmap.ic_fat, 10, - it.type, - calorie = bean.healthCount.toString() + it.type ) ) } diff --git a/app/src/main/java/com/zj365/dc/vm/ShopMallVm.kt b/app/src/main/java/com/zj365/dc/vm/ShopMallVm.kt index a027a46..20cf294 100644 --- a/app/src/main/java/com/zj365/dc/vm/ShopMallVm.kt +++ b/app/src/main/java/com/zj365/dc/vm/ShopMallVm.kt @@ -6,6 +6,7 @@ import com.xty.base.vm.BaseVm import com.xty.network.model.GoodsRecordsBean import com.xty.network.model.RespBody import com.xty.network.model.ShopCategoryBean +import com.xty.network.model.ShopGoodsOrderBean class ShopMallVm : BaseVm() { @@ -13,7 +14,7 @@ class ShopMallVm : BaseVm() { val goodsLiveData by lazy { MutableLiveData>() } - val createOrderLiveData by lazy { MutableLiveData>() } + val createOrderLiveData by lazy { MutableLiveData>() } fun getGoodsCategory(parentId:Long){ startHttp { @@ -37,14 +38,19 @@ class ShopMallVm : BaseVm() { } } - fun createOrder(skuId:String,num:Int,addrId:String,couponsId:String){ + fun createOrder(skuId:String,num:Int,addrId:Long?,couponsId:Long?){ startHttp { var json = JSONObject() json.put("skuId",skuId) json.put("num",num) - json.put("addrId",addrId) - json.put("couponsId",couponsId) + addrId?.let { + json.put("addrId",it) + } + couponsId?.let { + json.put("couponsId",it) + + } var code = apiInterface().createOrder(retrofits.getRequestBody(json.toString())) code.getCodeStatus(createOrderLiveData, nowData) } diff --git a/app/src/main/res/layout/act_create_goods_order.xml b/app/src/main/res/layout/act_create_goods_order.xml index d3997e9..8038c38 100644 --- a/app/src/main/res/layout/act_create_goods_order.xml +++ b/app/src/main/res/layout/act_create_goods_order.xml @@ -129,7 +129,7 @@ + android:layout_marginTop="@dimen/dp_26" + android:layout_marginBottom="@dimen/dp_25"> 2.82f && statu < 5.21f) {//2.83-5.20 "正常" } else { "异常" @@ -206,7 +205,7 @@ object OrganStatusCalcUtil { } fun tcStatus(status: Float):Int{ //tc 0是正常 1是异常 - return if (status <= 5.20) { + return if (status > 2.82f && status < 5.21f) {//2.83-5.20 0 } else { 1 @@ -214,8 +213,7 @@ object OrganStatusCalcUtil { } fun tgStatuText(statu: Float): String {//tg甘油三酯 - - return if (statu <= 1.69) { + return if (statu > 0.44f && statu < 1.70f) {//0.45-1.69 "正常" } else { "异常" @@ -223,15 +221,14 @@ object OrganStatusCalcUtil { } fun tgStatus(status:Float):Int{ //tg 0是正常 1是异常 - return if (status <= 1.69) { + return if (status > 0.44f && status < 1.70f) {//0.45-1.69 0 } else { 1 } } fun hdlStatuText(statu: Float): String {//hdl高密度脂蛋白 - - return if (statu >= 0.93) { + return if(statu > 0.92f && statu < 1.94f) {//0.93-1.93 "正常" } else { "异常" @@ -239,7 +236,7 @@ object OrganStatusCalcUtil { } fun hdlStatus(status:Float) :Int{ // hdl 0是正常 1是异常 - return if (status >= 0.93) { + return if (status > 0.92f && status < 1.94f) {//0.93-1.93 0 } else { 1 @@ -247,8 +244,7 @@ object OrganStatusCalcUtil { } fun ldlStatuText(statu: Float): String {//ldl低密度脂蛋白 - - return if (statu <= 3.12) { + return if (statu > -1f && statu < 3.13f) {//0.0-3.12 "正常" } else { "异常" @@ -256,7 +252,7 @@ object OrganStatusCalcUtil { } fun ldlStatus(status:Float): Int{ // ldl 0是正常 1是异常 - return if (status <= 3.12) { + return if (status > -1f && status < 3.13f) {//0.0-3.12 0 } else { 1 diff --git a/base/src/main/java/com/xty/base/utils/PayUtils.kt b/base/src/main/java/com/xty/base/utils/PayUtils.kt index fd140b8..68f8cf1 100644 --- a/base/src/main/java/com/xty/base/utils/PayUtils.kt +++ b/base/src/main/java/com/xty/base/utils/PayUtils.kt @@ -41,7 +41,71 @@ open class PayUtils(var context: Context) { var price:Float? = null + var isPayGoods:Boolean = false + open fun reChangeWatch(xPrice:Float,orderNo:String){ + isPayGoods = false + bottomSheetDialog = BottomSheetDialog(context, R.style.Theme_ChartDialogManager) + bottomSheetDialog?.let { dialog -> + val view = LayoutInflater.from(context).inflate(R.layout.dialog_pay, null) + dialog.setContentView(view) + + val tvprice = view.findViewById(R.id.tvPrice) + tvprice.text = SpannableUtils.setSpanMoney(xPrice) + val ivClose = view.findViewById(R.id.close_button) + ivClose.setOnClickListener { + dialog.dismiss() + } + val tvZhifubao = view.findViewById(R.id.tv_gouxuan_zhifubao) + val tvWeixin = view.findViewById(R.id.tv_gouxuan_weixin) + tvWeixin.isSelected = true + val tvDuihuanma = view.findViewById(R.id.tv_gouxuan_duihuanma) + val llWeixin = view.findViewById(R.id.llWeixin) + val llZhifu = view.findViewById(R.id.llZhifu) + val tvZhifu = view.findViewById(R.id.tvZhifu) + llZhifu.setOnClickListener { + tvZhifubao.isSelected = true + tvDuihuanma.isSelected = false + tvWeixin.isSelected = false + tvZhifu.text = "确认支付" + } + llWeixin.setOnClickListener { + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = false + tvWeixin.isSelected = true + tvZhifu.text = "确认支付" + } + val llDuihuan = view.findViewById(R.id.llDuihuan) + llDuihuan.setOnClickListener { + tvWeixin.isSelected = false + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = true + tvZhifu.text = "去兑换" + } + + tvZhifu.setOnClickListener { + //支付 + if (tvZhifubao.isSelected) { + //支付宝 + mViewModel.payWatch(orderNo, "ALIPAY_APP") + } else if (tvWeixin.isSelected) { + //微信 + mViewModel.payWatch(orderNo, "WEIXIN_APP") + } else { + + } + + liveObserver() + } + } + bottomSheetDialog?.show() + + + } + + + open fun payForGoods(xPrice:Float,orderNo:String){ + isPayGoods = true bottomSheetDialog = BottomSheetDialog(context, R.style.Theme_ChartDialogManager) bottomSheetDialog?.let { dialog -> val view = LayoutInflater.from(context).inflate(R.layout.dialog_pay, null) @@ -186,21 +250,32 @@ open class PayUtils(var context: Context) { bundle.putString("orderType", "1") RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle)*/ - Toast.makeText( - context, - "支付成功", - Toast.LENGTH_SHORT - ) - .show() + if(isPayGoods){ + + }else{ + Toast.makeText( + context, + "支付成功", + Toast.LENGTH_SHORT + ) + .show() + + EventBus.getDefault().post(ReChangeEvent()) + } + - EventBus.getDefault().post(ReChangeEvent()) } else { - Toast.makeText( - context, - "支付失败,请联系客服", - Toast.LENGTH_SHORT - ) - .show() + if(isPayGoods){ + + }else{ + Toast.makeText( + context, + "支付失败,请联系客服", + Toast.LENGTH_SHORT + ) + .show() + } + // 该笔订单真实的支付结果,需要依赖服务端的异步通知。 // com.alipay.sdk.pay.demo.PayDemoActivity.showAlert( @@ -218,13 +293,18 @@ open class PayUtils(var context: Context) { bundle.putString("orderNo", orderNo) bundle.putString("orderType", "1") RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle)*/ - EventBus.getDefault().post(ReChangeEvent()) - Toast.makeText( - context, - "支付成功", - Toast.LENGTH_SHORT - ) - .show() + if(isPayGoods){ + + }else{ + EventBus.getDefault().post(ReChangeEvent()) + Toast.makeText( + context, + "支付成功", + Toast.LENGTH_SHORT + ) + .show() + } + } BaseResp.ErrCode.ERR_USER_CANCEL -> { @@ -232,11 +312,16 @@ open class PayUtils(var context: Context) { } else -> { - Toast.makeText( - context, - "支付失败,请联系客服", - Toast.LENGTH_SHORT - ).show() + if(isPayGoods){ + + }else{ + Toast.makeText( + context, + "支付失败,请联系客服", + Toast.LENGTH_SHORT + ).show() + } + } } } diff --git a/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt b/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt index 4b99bae..bf25f80 100644 --- a/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt +++ b/common/src/main/java/com/xty/common/arouter/ARouterUrl.kt @@ -26,6 +26,7 @@ class ARouterUrl { const val SHOP_CATEGORY = "/com/zj365/dc/activity/shop/ShopCategoryActivity" const val SHOP_ORDER_LIST_ACT = "/health/com/zj365/health/act/ShopOrderListAct" const val SHOP_ORDER_DETAIL_ACT = "/health/com/zj365/health/act/ShopOrderDetailAct" + const val CREATE_SHOP_ORDER_ACT = "/com/zj365/dc/activity/shop/CreateGoodsOrderAct" // const val FAMILY_INFO="/com/zj365/dc/act/FamilyMainAct" diff --git a/health/src/main/java/com/zj365/health/act/BloodLipidAdjustAct.kt b/health/src/main/java/com/zj365/health/act/BloodLipidAdjustAct.kt index 1f7bfe4..24a9fff 100644 --- a/health/src/main/java/com/zj365/health/act/BloodLipidAdjustAct.kt +++ b/health/src/main/java/com/zj365/health/act/BloodLipidAdjustAct.kt @@ -1,18 +1,19 @@ package com.zj365.health.act +import android.annotation.SuppressLint import android.view.LayoutInflater import android.view.View import android.widget.EditText import android.widget.TextView import androidx.core.view.get import com.alibaba.android.arouter.facade.annotation.Route -import com.hjq.toast.ToastUtils import com.tamsiree.rxkit.RxKeyboardTool import com.xty.base.act.BaseVmAct import com.xty.common.TimeSelect import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager import com.xty.common.util.ChineseNumberAndNumberUtils +import com.xty.common.util.CommonToastUtils import com.xty.common.util.PointLengthFilter import com.zj365.health.R import com.zj365.health.databinding.ActBloodLipidAdjustBinding @@ -20,6 +21,7 @@ import com.zj365.health.model.BloodLipidAdjustBean import com.zj365.health.vm.BloodLipidAdjustVm import com.zj365.health.weight.HealthDialog + /** * 血脂校准 */ @@ -28,7 +30,7 @@ class BloodLipidAdjustAct : BaseVmAct() { val binding by lazy { ActBloodLipidAdjustBinding.inflate(layoutInflater) } override fun setLayout() = binding.root - + private val MAX_LENGTH=10 val timSelect by lazy { TimeSelect(this) { }.apply { @@ -40,7 +42,8 @@ class BloodLipidAdjustAct : BaseVmAct() { private val submitDialog by lazy { HealthDialog(this, false, "请确保输入数据的准确性,确认是否提交?", true) { - val bloods: MutableList = getBloodLipidAdjustData() ?: return@HealthDialog + val bloods: MutableList = + getBloodLipidAdjustData() ?: return@HealthDialog mViewModel.submitBloodLipidAdjustData(bloods) } } @@ -51,6 +54,7 @@ class BloodLipidAdjustAct : BaseVmAct() { finish() } } + override fun liveObserver() { mViewModel.calibrationLive.observe(this) { successDialog.setCancelable(false) @@ -66,7 +70,7 @@ class BloodLipidAdjustAct : BaseVmAct() { override fun initView() { super.initView() - binding.title.mTvTitle.text ="血脂校准" + binding.title.mTvTitle.text = "血脂校准" statusBar(binding.title.mView) binding.title.mIvBack.setOnClickListener { finish() } @@ -83,15 +87,32 @@ class BloodLipidAdjustAct : BaseVmAct() { addChildViews() } + //血脂校准须知 + binding.mTip.setOnClickListener { + val webUrl = "https://mp.weixin.qq.com/s?__biz=Mzg4MDEyMDA3Mw==&mid=22474949" + + "13&idx=1&sn=ff21da0895b646004a7281fce0881d61&chksm=cf78b567f80f3c" + + "710cd94ac3f9a5606bdc13af60e4b3ee5143e59faf5f766bcc3dbebf946409#rd" + bundle.clear() + bundle.putString("title", "血脂校准须知") + bundle.putString("url", webUrl) + RouteManager.goAct(ARouterUrl.WEB_ACT, bundle) + } } - private fun addChildViews(){ - val childView = LayoutInflater.from(this).inflate(R.layout.item_blood_lipid_adjust,null) + @SuppressLint("SetTextI18n") + private fun addChildViews() { val viewIndex = binding.childLayout.childCount val viewNum = viewIndex + 1 - childView.findViewById(R.id.mTitle).text = "第${ChineseNumberAndNumberUtils.intToChinese(viewNum)}次" + if (viewNum>MAX_LENGTH){ + CommonToastUtils.showToast("血脂校准最多添加"+MAX_LENGTH+"条") + return + } + val childView = LayoutInflater.from(this).inflate(R.layout.item_blood_lipid_adjust, null) + childView.findViewById(R.id.mTitle).text = + "第${ChineseNumberAndNumberUtils.intToChinese(viewNum)}次" childView.findViewById(R.id.mEditLDL).filters = arrayOf(PointLengthFilter(2)) - childView.findViewById(R.id.mEditCholesterol).filters = arrayOf(PointLengthFilter(2)) + childView.findViewById(R.id.mEditCholesterol).filters = + arrayOf(PointLengthFilter(2)) childView.findViewById(R.id.mEditTg).filters = arrayOf(PointLengthFilter(2)) childView.findViewById(R.id.mEditHDL).filters = arrayOf(PointLengthFilter(2)) @@ -112,42 +133,90 @@ class BloodLipidAdjustAct : BaseVmAct() { else binding.childLayout[index].findViewById(childId) } - private fun getBloodLipidAdjustData(): MutableList?{ - val list:MutableList = mutableListOf() - for(i in 0 until binding.childLayout.childCount){ + private fun getBloodLipidAdjustData(): MutableList? { + val list = mutableListOf() + for (i in 0 until binding.childLayout.childCount) { val bloodLipidAdjustBean = BloodLipidAdjustBean() - bloodLipidAdjustBean.bpTime = (getChildView(i,R.id.mVTimeView) as TextView).text.toString() - bloodLipidAdjustBean.tc = (getChildView(i,R.id.mEditCholesterol) as TextView).text.toString() - bloodLipidAdjustBean.tg = (getChildView(i,R.id.mEditTg) as TextView).text.toString() - bloodLipidAdjustBean.hdl = (getChildView(i,R.id.mEditHDL) as TextView).text.toString() - bloodLipidAdjustBean.ldl = (getChildView(i,R.id.mEditLDL) as TextView).text.toString() - - if (bloodLipidAdjustBean.bpTime.isNullOrEmpty()){ - ToastUtils.show("请选择测量时间") - return null - } - - if(bloodLipidAdjustBean.tc.isNullOrEmpty()){ - ToastUtils.show("请填写总胆固醇数值") - return null + bloodLipidAdjustBean.bpTime = (getChildView( + i, + R.id.mVTimeView + ) as TextView).text.toString() + bloodLipidAdjustBean.tc = (getChildView( + i, + R.id.mEditCholesterol + ) as TextView).text.toString() + bloodLipidAdjustBean.tg = (getChildView( + i, + R.id.mEditTg + ) as TextView).text.toString() + bloodLipidAdjustBean.hdl = (getChildView( + i, + R.id.mEditHDL + ) as TextView).text.toString() + bloodLipidAdjustBean.ldl = (getChildView( + i, + R.id.mEditLDL + ) as TextView).text.toString() + + if (list.size < 1) { + if (bloodLipidAdjustBean.bpTime.isNullOrEmpty()) { + CommonToastUtils.showToast("请选择测量时间") + return null + } + if (bloodLipidAdjustBean.tc.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写总胆固醇数值") + return null + } + if (bloodLipidAdjustBean.tg.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写甘油三酯数值") + return null + } + if (bloodLipidAdjustBean.hdl.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写高密度脂蛋白数值") + return null + } + if (bloodLipidAdjustBean.ldl.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写低密度脂蛋白数值") + return null + } + } else { + if (bloodLipidAdjustBean.bpTime.isNullOrEmpty() + && bloodLipidAdjustBean.tc.isNullOrEmpty() + && bloodLipidAdjustBean.tg.isNullOrEmpty() + && bloodLipidAdjustBean.hdl.isNullOrEmpty() + && bloodLipidAdjustBean.ldl.isNullOrEmpty() + ) { + continue + } else { + if (bloodLipidAdjustBean.bpTime.isNullOrEmpty()) { + CommonToastUtils.showToast("请选择测量时间") + return null + } + if (bloodLipidAdjustBean.tc.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写总胆固醇数值") + return null + } + if (bloodLipidAdjustBean.tg.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写甘油三酯数值") + return null + } + if (bloodLipidAdjustBean.hdl.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写高密度脂蛋白数值") + return null + } + if (bloodLipidAdjustBean.ldl.isNullOrEmpty()) { + CommonToastUtils.showToast("请填写低密度脂蛋白数值") + return null + } + } } - - if(bloodLipidAdjustBean.tg.isNullOrEmpty()){ - ToastUtils.show("请填写甘油三酯数值") - return null - } - if(bloodLipidAdjustBean.hdl.isNullOrEmpty()){ - ToastUtils.show("请填写高密度脂蛋白数值") - return null - } - if(bloodLipidAdjustBean.ldl.isNullOrEmpty()){ - ToastUtils.show("请填写低密度脂蛋白数值") - return null - } - bloodLipidAdjustBean.bpTime = "${bloodLipidAdjustBean.bpTime}:00" list.add(bloodLipidAdjustBean) } + if (list.size < 1) { + CommonToastUtils.showToast("数据不完整,请检查后再提交") + return null + } return list } } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/act/BloodLipidAdjustRecordsAct.kt b/health/src/main/java/com/zj365/health/act/BloodLipidAdjustRecordsAct.kt index d39856b..3ab2b55 100644 --- a/health/src/main/java/com/zj365/health/act/BloodLipidAdjustRecordsAct.kt +++ b/health/src/main/java/com/zj365/health/act/BloodLipidAdjustRecordsAct.kt @@ -14,6 +14,7 @@ import com.zj365.health.adapter.bloodfat.BloodLipidAdjustAdapter import com.zj365.health.databinding.ActBloodFatHistoryBinding import com.zj365.health.vm.BloodLipidAdjustRecordsVm + /** * 血脂校准记录 */ @@ -21,18 +22,17 @@ import com.zj365.health.vm.BloodLipidAdjustRecordsVm class BloodLipidAdjustRecordsAct : BaseListAct() { val binding by lazy { ActBloodFatHistoryBinding.inflate(layoutInflater) } + override fun setLayout() = binding.root var isManage = false var isEdit = false - override fun setLayout() = binding.root - val adapter by lazy { BloodLipidAdjustAdapter() } override fun initAdapter() { binding.mRecycle.adapter = adapter - binding.mRecycle.addItemDecoration(RecycleItem(this,50)) - binding.mRecycle.layoutManager= LinearLayoutManager(this) - setRecycleRefresh(binding.mRecycle,binding.mRefresh) + binding.mRecycle.addItemDecoration(RecycleItem(this, 50)) + binding.mRecycle.layoutManager = LinearLayoutManager(this) + setRecycleRefresh(binding.mRecycle, binding.mRefresh, true) adapter.setOnItemClickListener { _, view, position -> val bloodFatBean = adapter.data[position] @@ -51,14 +51,13 @@ class BloodLipidAdjustRecordsAct : BaseListAct() { override fun deleteData() { super.deleteData() mViewModel.deleteBloodFatDataRequest(adapter.getSelectData()) - } override fun initView() { super.initView() statusBar(binding.title.mView) binding.title.mIvBack.setOnClickListener { finish() } - binding.title.mTvTitle.text ="校准记录" + binding.title.mTvTitle.text = "校准记录" binding.mTvManage.setOnClickListener { toManage(!isManage) @@ -79,12 +78,12 @@ class BloodLipidAdjustRecordsAct : BaseListAct() { } override fun liveObserver() { - mViewModel.bloodLipidAdjustRecord.observe(this){ - setDate(adapter,it.data.records) - binding.title.mTvTitle.text ="校准记录(${it.data.total})" + mViewModel.bloodLipidAdjustRecord.observe(this) { + setDate(adapter, it.data.records) + binding.title.mTvTitle.text = "校准记录(${it.data.total})" } - mViewModel.deleteBloodFatData.observe(this){ + mViewModel.deleteBloodFatData.observe(this) { if (it.code == 0) { page = 1 loadData() diff --git a/health/src/main/java/com/zj365/health/act/ComparePageDataAct.kt b/health/src/main/java/com/zj365/health/act/ComparePageDataAct.kt index 1f5d1c3..bf32c14 100644 --- a/health/src/main/java/com/zj365/health/act/ComparePageDataAct.kt +++ b/health/src/main/java/com/zj365/health/act/ComparePageDataAct.kt @@ -76,9 +76,9 @@ class ComparePageDataAct : BaseVmAct() { }else if(DeviceFunctionUtils.hasFunction(it,"uric")){ listFragment.add(setArgumentFrag(UricAcidCompareDataFrag(),id)) - }/*else if(it.type == "bloodFat" && it.status == 1){ + }else if(DeviceFunctionUtils.hasFunction(it,"bloodFat")){ listFragment.add(setArgumentFrag(BloodFatCompareDataFrag(),id)) - }*/ + } } binding.mVp2.adapter = VpAdapter(listFragment, this) @@ -114,7 +114,7 @@ class ComparePageDataAct : BaseVmAct() { } private fun initTab(functionList :MutableList) { functionList.forEach { - if(it.type == "ecg" || it.type == "step" || it.type == "bloodFat"){ + if(it.type == "ecg" || it.type == "step"){ return@forEach } if (it.status == 1){ diff --git a/health/src/main/java/com/zj365/health/act/HealthMainAct.kt b/health/src/main/java/com/zj365/health/act/HealthMainAct.kt index c2f6213..a4d5940 100644 --- a/health/src/main/java/com/zj365/health/act/HealthMainAct.kt +++ b/health/src/main/java/com/zj365/health/act/HealthMainAct.kt @@ -140,7 +140,7 @@ class HealthMainAct : BaseVmAct() { private fun initTab(functionList :MutableList) { binding.xTablayout.removeAllTabs() functionList.forEach { - if (it.type == "step" || it.type == "bloodFat"){ + if (it.type == "step"){ return@forEach } if (it.status == 1){ @@ -204,9 +204,9 @@ class HealthMainAct : BaseVmAct() { }else if(DeviceFunctionUtils.hasFunction(it,"uric")){ listFragment.add(setArgumentFrag(UricAcidFrag(), id, sex)) - }/*else if(it.type == "bloodFat" && it.status == 1){ - listFragment.add(setArgumentFrag(BloodFatCompareDataFrag(),id)) - }*/ + }else if(DeviceFunctionUtils.hasFunction(it,"bloodFat")){ + listFragment.add(setArgumentFrag(BloodFatFrag(), id)) + } } diff --git a/health/src/main/java/com/zj365/health/act/HealthSkyHourReportAct.kt b/health/src/main/java/com/zj365/health/act/HealthSkyHourReportAct.kt index becb9f8..0f936f9 100644 --- a/health/src/main/java/com/zj365/health/act/HealthSkyHourReportAct.kt +++ b/health/src/main/java/com/zj365/health/act/HealthSkyHourReportAct.kt @@ -53,6 +53,7 @@ import com.zj365.health.weight.GridDividerItemDecoration import com.zj365.health.weight.HealthDialog import com.xty.network.model.ReportBean import com.xty.network.model.RespBody +import com.zj365.health.adapter.HealthSignDataAdapter import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job import kotlinx.coroutines.delay @@ -107,6 +108,14 @@ class HealthSkyHourReportAct : BaseVmAct() { private val infoAdapter by lazy { DayReportInfoAdapter() } private val mAdapterCount by lazy { ReportAnalysisAdapter() } + /** + * 综合分析列表 + */ + private val healthSignDataGriddingAdapter by lazy { HealthSignDataAdapter() } + private val healthSignDataAdapter by lazy { HealthSignDataAdapter() } + private val signDataGriddingList = mutableListOf() + private val signDataList = mutableListOf() + var functionList = ArrayList() @@ -562,6 +571,14 @@ class HealthSkyHourReportAct : BaseVmAct() { binding.mTvTime.setOnClickListener { timSelect.selectTime(it, "yyyy-MM-dd") } + + /** + * 综合分析列表 + */ + binding.recyclerViewGridding.layoutManager = GridLayoutManager(this, 2) + binding.recyclerViewGridding.adapter = healthSignDataGriddingAdapter + binding.recyclerViewList.layoutManager = LinearLayoutManager(this) + binding.recyclerViewList.adapter = healthSignDataAdapter } private fun getTabPosition(listPosition: Int): Int { @@ -911,7 +928,7 @@ class HealthSkyHourReportAct : BaseVmAct() { ) ) - /*if(bsseInfo.bloodFat == null){ + if(bsseInfo.bloodFat == null){ listInfo.add( ReportBean.HrInfo( "血脂", @@ -936,7 +953,7 @@ class HealthSkyHourReportAct : BaseVmAct() { R.mipmap.ic_uric_acid_small ) ) - }*/ + } if (bsseInfo.uricAcid == null) { //如果服务端没有返回数据,也就是演示模式,我们自己新增一些假数据用于展示 listInfo.add( @@ -1171,7 +1188,7 @@ class HealthSkyHourReportAct : BaseVmAct() { } list.add(uricAcid) - /* val bloodFat = if (it.data.bloodFat == null) { //服务端没有返回数据 + val bloodFat = if (it.data.bloodFat == null) { //服务端没有返回数据 com.xty.common.model.ReportBean().apply { title = "血脂" count = 1 @@ -1208,7 +1225,7 @@ class HealthSkyHourReportAct : BaseVmAct() { isShow = true } } - list.add(bloodFat)*/ + list.add(bloodFat) val yundong = com.xty.common.model.ReportBean().apply { title = "运动" @@ -1692,8 +1709,8 @@ class HealthSkyHourReportAct : BaseVmAct() { * 设置综合分析内容 */ @SuppressLint("SetTextI18n", "UseCompatLoadingForDrawables") - private fun setAnalysisInfo(it: RespBody) { - binding.analysisTv1.text = "平均心率:" + it.data.signData.hr.avg + "次/分" + private fun setAnalysisInfo(it: RespBody) { + /* binding.analysisTv1.text = "平均心率:" + it.data.signData.hr.avg + "次/分" binding.analysisTv2.text = "平均血氧:" + it.data.signData.so.avg + "%" binding.analysisTv3.text = "平均呼吸率:" + it.data.signData.respiratory.avg + "次/分" if (!DeviceFunctionUtils.hasFunction(functionList,"temp")) { @@ -1710,7 +1727,7 @@ class HealthSkyHourReportAct : BaseVmAct() { binding.analysisTv5.text = "平均运动:" + it.data.signData.stepData.avg + "步" binding.analysisTv6.text = "平均睡眠:${minutesToHours(it.data.signData.sleep.avgTime)}" - binding.analysisTv7.text = "平均血压:" + it.data.signData.dbp.avg + "mmHg" + binding.analysisTv7.text = "平均血压:" + it.data.signData.dbp.avg + "mmHg"*/ /*if(!TextUtils.isEmpty(it.data.signData.bloodFat.tgAvg)){ binding.analysisTv9.text = "平均血脂:" + it.data.signData.bloodFat.tgAvg + "mmol" @@ -1719,50 +1736,228 @@ class HealthSkyHourReportAct : BaseVmAct() { binding.analysisTv9.text = "平均血脂:0mmol" }*/ - binding.state.apply { - val statusInt = it.data.healthy.result - val star = if (it.data.star.isEmpty()) 0 else Integer.valueOf(it.data.star) - text = UserInfoDefin.getHealthArray(context)[statusInt + 1] - setTextColor( - ContextCompat.getColor( - context, - UserInfoDefin.healthCol[statusInt + 1] + + val signData = it.data.signData + if (signData != null) { + val list = mutableListOf() + val hrAvg = signData.hr.avg.toInt() + list.add( + "平均心率:${ + if (hrAvg > 0) { + hrAvg + } else { + "--" + } + }次/分" + ) + val soAvg = signData.so.avg.toFloat() + list.add( + "平均血氧:${ + if (soAvg > 0) { + soAvg + } else { + "--" + } + }%" + ) + val respiratoryAvg = signData.respiratory.avg.toInt() + list.add( + "平均呼吸率:${ + if (respiratoryAvg > 0) { + respiratoryAvg + } else { + "--" + } + }次/分" + ) + if (DeviceFunctionUtils.hasFunction(functionList, "temp")) { + val tempAvg = signData.temp.avg + val stringToDoubleOne = CommonUtils.stringToDoubleOne(tempAvg).toFloat() + list.add( + "平均体温:${ + if (stringToDoubleOne > 0) { + stringToDoubleOne + } else { + "--" + } + }°C" ) + } + val stepDataAvg = signData.stepData.avg.toInt() + list.add( + "平均步数:${ + if (stepDataAvg > 0) { + stepDataAvg + } else { + "--" + } + }步" ) - append("\t") - val selectStarImage = UserInfoDefin.getStarImage(context, statusInt) - selectStarImage.setBounds( - 0, - 0, - selectStarImage.minimumWidth, - selectStarImage.minimumHeight + val avgTime = signData.sleep.avgTime!!.toInt() + val sleepAvgTime = minutesToHours(avgTime.toString()) + list.add( + "平均睡眠时间:${ + if (avgTime > 0) { + sleepAvgTime + } else { + "--小时" + } + }" ) - - val unSelectStarImage = context.getDrawable(R.mipmap.icon_insufficient) - unSelectStarImage?.setBounds( - 0, - 0, - unSelectStarImage.minimumWidth, - unSelectStarImage.minimumHeight + val dbpAvg = signData.dbp.avg + val split = dbpAvg.split("/") + val s = split[0].toInt() + val s1 = split[1].toInt() + list.add( + "平均血压:${ + if (s > 0) { + s + } else { + "--" + } + }/${ + if (s1 > 0) { + s1 + } else { + "--" + } + }mmHg" ) - - for (i in 1..5) {//五颗星 - val spanStr = SpannableString("custom$i ") - val span = - (if (star >= i) selectStarImage else unSelectStarImage)?.let { starDrawable -> - CenterImageSpan(starDrawable) + val bloodSugarAvg = signData.bloodSugar.avg.toFloat() + list.add( + "平均血糖:${ + if (bloodSugarAvg > 0) { + bloodSugarAvg + } else { + "--" } - spanStr.setSpan(span, 0, spanStr.length - 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE) - //添加至textview - append(spanStr) + }mmol/L" + ) + val uricAcidAvg = signData.uricAcid.avg.toFloat() + list.add( + "平均尿酸:${ + if (uricAcidAvg > 0) { + uricAcidAvg + } else { + "--" + } + }μmol/L" + ) + if (signData.bloodFat != null) { + val tcAvg = signData.bloodFat.tcAvg.toFloat() + list.add( + "平均总胆固醇:${ + if (tcAvg > 0) { + tcAvg + } else { + "--" + } + }mmol/L" + ) + val tgAvg = signData.bloodFat.tgAvg.toFloat() + list.add( + "平均甘油三酯:${ + if (tgAvg > 0) { + tgAvg + } else { + "--" + } + }mmol/L" + ) + val hdlAvg = signData.bloodFat.hdlAvg.toFloat() + list.add( + "平均高密度脂蛋白:${ + if (hdlAvg > 0) { + hdlAvg + } else { + "--" + } + }mmol/L" + ) + val ldlAvg = signData.bloodFat.ldlAvg.toFloat() + list.add( + "平均低密度脂蛋白:${ + if (ldlAvg > 0) { + ldlAvg + } else { + "--" + } + }mmol/L" + ) + } else { + list.add("平均总胆固醇:3.11mmol/L") + list.add("平均甘油三酯:2.22mmol/L") + list.add("平均高密度脂蛋白:1.22mmol/L") + list.add("平均低密度脂蛋白:3.33mmol/L") } - setOnClickListener { - tipDialog.show() + signDataList.clear() + signDataGriddingList.clear() + if (list.isNotEmpty()) { + list.forEachIndexed { index, data -> + if (index < 8) { + signDataGriddingList.add(data) + } else { + signDataList.add(data) + } + } + if (signDataGriddingList.size > 0) { + binding.recyclerViewGridding.visibility = View.VISIBLE + healthSignDataGriddingAdapter.setNewInstance(signDataGriddingList) + } + if (signDataList.size > 0) { + binding.recyclerViewList.visibility = View.VISIBLE + healthSignDataAdapter.setNewInstance(signDataList) + } + } else { + binding.recyclerViewGridding.visibility = View.GONE + binding.recyclerViewList.visibility = View.GONE } - } - binding.tipsIcon.apply { - setOnClickListener { - tipDialog.show() + + binding.state.apply { + val statusInt = it.data.healthy.result + val star = if (it.data.star.isEmpty()) 0 else Integer.valueOf(it.data.star) + text = UserInfoDefin.getHealthArray(context)[statusInt + 1] + setTextColor( + ContextCompat.getColor( + context, + UserInfoDefin.healthCol[statusInt + 1] + ) + ) + append("\t") + val selectStarImage = UserInfoDefin.getStarImage(context, statusInt) + selectStarImage.setBounds( + 0, + 0, + selectStarImage.minimumWidth, + selectStarImage.minimumHeight + ) + + val unSelectStarImage = context.getDrawable(R.mipmap.icon_insufficient) + unSelectStarImage?.setBounds( + 0, + 0, + unSelectStarImage.minimumWidth, + unSelectStarImage.minimumHeight + ) + + for (i in 1..5) {//五颗星 + val spanStr = SpannableString("custom$i ") + val span = + (if (star >= i) selectStarImage else unSelectStarImage)?.let { starDrawable -> + CenterImageSpan(starDrawable) + } + spanStr.setSpan(span, 0, spanStr.length - 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE) + //添加至textview + append(spanStr) + } + setOnClickListener { + tipDialog.show() + } + } + binding.tipsIcon.apply { + setOnClickListener { + tipDialog.show() + } } } } diff --git a/health/src/main/java/com/zj365/health/act/HealthWeekMonthHourReportAct.kt b/health/src/main/java/com/zj365/health/act/HealthWeekMonthHourReportAct.kt index 2737da1..0e1de92 100644 --- a/health/src/main/java/com/zj365/health/act/HealthWeekMonthHourReportAct.kt +++ b/health/src/main/java/com/zj365/health/act/HealthWeekMonthHourReportAct.kt @@ -75,6 +75,7 @@ import com.zj365.health.weight.GridDividerItemDecoration import com.zj365.health.weight.HealthDialog import com.zj365.health.weight.PopWindowUserInfo import com.xty.network.model.RespBody +import com.zj365.health.adapter.HealthSignDataAdapter import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job import kotlinx.coroutines.delay @@ -141,6 +142,15 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { private val mTitless = mutableListOf() + /** + * 综合分析列表 + */ + private val healthSignDataGriddingAdapter by lazy { HealthSignDataAdapter() } + private val healthSignDataAdapter by lazy { HealthSignDataAdapter() } + private val signDataGriddingList = mutableListOf() + private val signDataList = mutableListOf() + + var functionList = ArrayList() private val tipDialog by lazy { @@ -315,6 +325,14 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { else -> {} } } + + /** + * 综合分析列表 + */ + binding.recyclerViewGridding.layoutManager = GridLayoutManager(this, 2) + binding.recyclerViewGridding.adapter = healthSignDataGriddingAdapter + binding.recyclerViewList.layoutManager = LinearLayoutManager(this) + binding.recyclerViewList.adapter = healthSignDataAdapter } @SuppressLint("SetTextI18n") @@ -1350,7 +1368,7 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { ) } - /*if(bsseInfo.bloodFat == null){ + if(bsseInfo.bloodFat == null){ listInfo.add( com.xty.network.model.ReportBean.HrInfo( "血脂", @@ -1375,7 +1393,7 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { R.mipmap.ic_uric_acid_small ) ) - }*/ + } infoAdapter.setNewInstance(listInfo) @@ -1582,7 +1600,7 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { } list.add(uricAcid) - /*val bloodFat = if (it.data.bloodFat == null) { //服务端没有返回数据 + val bloodFat = if (it.data.bloodFat == null) { //服务端没有返回数据 ReportBean().apply { title = "血脂" count = 1 @@ -1619,7 +1637,7 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { isShow = true } } - list.add(bloodFat)*/ + list.add(bloodFat) val yundong = ReportBean().apply { title = "运动" @@ -1951,11 +1969,60 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { */ @SuppressLint("SetTextI18n", "UseCompatLoadingForDrawables") private fun setAnalysisInfo(it: RespBody) { - var sleep = it.data.analyse.sleep - if (sleep == null) { - sleep = "" - } - binding.analysisTv1.text = "平均心率: " + it.data.analyse.hr + val analyse = it.data.analyse + if (analyse != null) { + var sleep = analyse.sleep + if (TextUtils.isEmpty(sleep)) { + sleep = "--小时" + } + val list = mutableListOf() + list.add("平均心率: ${analyse.hr}") + list.add("平均血氧: ${analyse.so}") + list.add("平均呼吸率: ${analyse.respiratory}") + if (DeviceFunctionUtils.hasFunction(functionList, "temp")) { + val tempAvg = it.data.signData.temp.avg.toFloat() + list.add( + "平均体温: ${ + if (tempAvg > 0) { + tempAvg + } else { + "--" + } + }" + ) + } + list.add("平均步数: ${analyse.exerciseStep}") + list.add("平均睡眠时间: $sleep") + list.add("平均血压: ${analyse.dbp}") + list.add("平均血糖: ${analyse.bloodsugar}") + list.add("平均尿酸: ${analyse.uricAcid}") + list.add("平均总胆固醇: ${analyse.tc}") + list.add("平均甘油三酯: ${analyse.tg}") + list.add("平均高密度脂蛋白: ${analyse.hdl}") + list.add("平均低密度脂蛋白: ${analyse.ldl}") + signDataList.clear() + signDataGriddingList.clear() + if (list.isNotEmpty()) { + list.forEachIndexed { index, data -> + if (index < 8) { + signDataGriddingList.add(data) + } else { + signDataList.add(data) + } + } + if (signDataGriddingList.size > 0) { + binding.recyclerViewGridding.visibility = View.VISIBLE + healthSignDataGriddingAdapter.setNewInstance(signDataGriddingList) + } + if (signDataList.size > 0) { + binding.recyclerViewList.visibility = View.VISIBLE + healthSignDataAdapter.setNewInstance(signDataList) + } + } else { + binding.recyclerViewGridding.visibility = View.GONE + binding.recyclerViewList.visibility = View.GONE + } + /*binding.analysisTv1.text = "平均心率: " + it.data.analyse.hr binding.analysisTv2.text = "平均血氧: " + it.data.analyse.so binding.analysisTv3.text = "平均呼吸率: " + it.data.analyse.respiratory if (!DeviceFunctionUtils.hasFunction(functionList,"temp")) { @@ -1971,59 +2038,60 @@ class HealthWeekMonthHourReportAct : BaseVmAct() { } binding.analysisTv5.text = "平均步数: " + it.data.analyse.exerciseStep binding.analysisTv6.text = "平均睡眠: $sleep" - binding.analysisTv7.text = "平均血压: " + it.data.analyse.dbp + binding.analysisTv7.text = "平均血压: " + it.data.analyse.dbp*/ - /* if(!TextUtils.isEmpty(it.data.signData.bloodFat.tgAvg)){ + /* if(!TextUtils.isEmpty(it.data.signData.bloodFat.tgAvg)){ binding.analysisTv9.text = "平均血脂:" + it.data.signData.bloodFat.tgAvg + "mmol" }else{ binding.analysisTv9.text = "平均血脂:0mmol" }*/ - binding.state.apply { - val statusInt = it.data.analyse.status.toInt() - val star = if (it.data.star.isEmpty()) 0 else Integer.valueOf(it.data.star) - text = UserInfoDefin.getHealthArray(context)[statusInt + 1] - setTextColor( - ContextCompat.getColor( - context, - UserInfoDefin.healthCol[statusInt + 1] + binding.state.apply { + val statusInt = analyse.status.toInt() + val star = if (it.data.star.isEmpty()) 0 else Integer.valueOf(it.data.star) + text = UserInfoDefin.getHealthArray(context)[statusInt + 1] + setTextColor( + ContextCompat.getColor( + context, + UserInfoDefin.healthCol[statusInt + 1] + ) + ) + append("\t") + val selectStarImage = UserInfoDefin.getStarImage(context, statusInt) + selectStarImage.setBounds( + 0, + 0, + selectStarImage.minimumWidth, + selectStarImage.minimumHeight ) - ) - append("\t") - val selectStarImage = UserInfoDefin.getStarImage(context, statusInt) - selectStarImage.setBounds( - 0, - 0, - selectStarImage.minimumWidth, - selectStarImage.minimumHeight - ) - val unSelectStarImage = context.getDrawable(R.mipmap.icon_insufficient) - unSelectStarImage?.setBounds( - 0, - 0, - unSelectStarImage.minimumWidth, - unSelectStarImage.minimumHeight - ) + val unSelectStarImage = context.getDrawable(R.mipmap.icon_insufficient) + unSelectStarImage?.setBounds( + 0, + 0, + unSelectStarImage.minimumWidth, + unSelectStarImage.minimumHeight + ) - for (i in 1..5) {//五颗星 - val spanStr = SpannableString("custom$i ") - val span = - (if (star >= i) selectStarImage else unSelectStarImage)?.let { starDrawable -> - CenterImageSpan(starDrawable) - } - spanStr.setSpan(span, 0, spanStr.length - 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE) - //添加至textview - append(spanStr) - } - setOnClickListener { - tipDialog.show() + for (i in 1..5) {//五颗星 + val spanStr = SpannableString("custom$i ") + val span = + (if (star >= i) selectStarImage else unSelectStarImage)?.let { starDrawable -> + CenterImageSpan(starDrawable) + } + spanStr.setSpan(span, 0, spanStr.length - 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE) + //添加至textview + append(spanStr) + } + setOnClickListener { + tipDialog.show() + } } - } - binding.tipsIcon.apply { - setOnClickListener { - tipDialog.show() + binding.tipsIcon.apply { + setOnClickListener { + tipDialog.show() + } } } } diff --git a/health/src/main/java/com/zj365/health/act/PreventCancertAct.kt b/health/src/main/java/com/zj365/health/act/PreventCancertAct.kt index 07d561a..473a32d 100644 --- a/health/src/main/java/com/zj365/health/act/PreventCancertAct.kt +++ b/health/src/main/java/com/zj365/health/act/PreventCancertAct.kt @@ -142,73 +142,76 @@ class PreventCancertAct : BaseVmAct() { var bottomSheetDialog: BottomSheetDialog? = null fun initBottomDialog() { - if (bottomSheetDialog == null) { - bottomSheetDialog = BottomSheetDialog(this,R.style.Theme_ChartDialogManager) - bottomSheetDialog?.let { dialog -> - val view = LayoutInflater.from(this).inflate(R.layout.bottom_cancer, null) - dialog.setContentView(view) - - val tvprice = view.findViewById(R.id.tvPrice) - tvprice.text = SpannableUtils.setSpanMoney(price) - val ivClose = view.findViewById(R.id.close_button) - ivClose.setOnClickListener { - dialog.dismiss() - } - val tvZhifubao = view.findViewById(R.id.tv_gouxuan_zhifubao) - val tvWeixin = view.findViewById(R.id.tv_gouxuan_weixin) - tvWeixin.isSelected = true - val tvDuihuanma = view.findViewById(R.id.tv_gouxuan_duihuanma) - val llWeixin = view.findViewById(R.id.llWeixin) - val llZhifu = view.findViewById(R.id.llZhifu) - val tvZhifu = view.findViewById(R.id.tvZhifu) - llZhifu.setOnClickListener { - tvZhifubao.isSelected = true - tvDuihuanma.isSelected = false - tvWeixin.isSelected = false - tvZhifu.text = "确认支付" - } - llWeixin.setOnClickListener { - tvZhifubao.isSelected = false - tvDuihuanma.isSelected = false + price?.let { + if (bottomSheetDialog == null) { + bottomSheetDialog = BottomSheetDialog(this,R.style.Theme_ChartDialogManager) + bottomSheetDialog?.let { dialog -> + val view = LayoutInflater.from(this).inflate(R.layout.bottom_cancer, null) + dialog.setContentView(view) + + val tvprice = view.findViewById(R.id.tvPrice) + tvprice.text = SpannableUtils.setSpanMoney(it) + val ivClose = view.findViewById(R.id.close_button) + ivClose.setOnClickListener { + dialog.dismiss() + } + val tvZhifubao = view.findViewById(R.id.tv_gouxuan_zhifubao) + val tvWeixin = view.findViewById(R.id.tv_gouxuan_weixin) tvWeixin.isSelected = true - tvZhifu.text = "确认支付" - } - val llDuihuan = view.findViewById(R.id.llDuihuan) - llDuihuan.setOnClickListener { - tvWeixin.isSelected = false - tvZhifubao.isSelected = false - tvDuihuanma.isSelected = true - tvZhifu.text = "去兑换" - } + val tvDuihuanma = view.findViewById(R.id.tv_gouxuan_duihuanma) + val llWeixin = view.findViewById(R.id.llWeixin) + val llZhifu = view.findViewById(R.id.llZhifu) + val tvZhifu = view.findViewById(R.id.tvZhifu) + llZhifu.setOnClickListener { + tvZhifubao.isSelected = true + tvDuihuanma.isSelected = false + tvWeixin.isSelected = false + tvZhifu.text = "确认支付" + } + llWeixin.setOnClickListener { + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = false + tvWeixin.isSelected = true + tvZhifu.text = "确认支付" + } + val llDuihuan = view.findViewById(R.id.llDuihuan) + llDuihuan.setOnClickListener { + tvWeixin.isSelected = false + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = true + tvZhifu.text = "去兑换" + } - tvZhifu.setOnClickListener { - //支付 - if (tvZhifubao.isSelected) { - //支付宝 - mViewModel.payUrl(goodsId, "ALIPAY_APP", "") - } else if (tvWeixin.isSelected) { - //微信 - mViewModel.payUrl(goodsId, "WEIXIN_APP", "") - } else { - //跳转兑换 + tvZhifu.setOnClickListener { + //支付 + if (tvZhifubao.isSelected) { + //支付宝 + mViewModel.payUrl(goodsId, "ALIPAY_APP", "") + } else if (tvWeixin.isSelected) { + //微信 + mViewModel.payUrl(goodsId, "WEIXIN_APP", "") + } else { + //跳转兑换 // bundle.clear() // bundle.putString("id",goodsId) // RouteManager.goAct(ARouterUrl.DUIHUAN, bundle) - bundle.clear() - bundle.putString("id", goodsId) - bundle.putString("orderNo", orderNo) - RouteManager.goAct(ARouterUrl.DUIHUAN, bundle) + bundle.clear() + bundle.putString("id", goodsId) + bundle.putString("orderNo", orderNo) + RouteManager.goAct(ARouterUrl.DUIHUAN, bundle) + } + dialog.dismiss() } - dialog.dismiss() } } } + } private val SDK_PAY_FLAG = 1 private val WEIXIN_PAY_FLAG = 2 - var price:Float = 0f + var price:Float? = null var goodsId = "" var orderNo = "" var filePath = "" diff --git a/health/src/main/java/com/zj365/health/act/exception/AllExceptionDataActivity.kt b/health/src/main/java/com/zj365/health/act/exception/AllExceptionDataActivity.kt index d39a663..00acc5d 100644 --- a/health/src/main/java/com/zj365/health/act/exception/AllExceptionDataActivity.kt +++ b/health/src/main/java/com/zj365/health/act/exception/AllExceptionDataActivity.kt @@ -98,7 +98,8 @@ class AllExceptionDataActivity : BaseVmAct() { } Const.bloodFatExcep ->{ - tabName = arrayOf("总胆固醇偏高","甘油三酯偏高","高密度脂蛋白偏低","低密度脂蛋白偏高") + tabName = + arrayOf("总胆固醇", "甘油三酯", "高密度脂蛋白", "低密度脂蛋白") if (currentTime.isNotEmpty()) { //日报 mViewModel.getWatchAbnormalDataBloodFat(id,timeType.toString(),currentTime,"10") @@ -324,35 +325,35 @@ class AllExceptionDataActivity : BaseVmAct() { } - mViewModel.exceptionBloodFatData.observe(this){ - var mData1 = arrayListOf() - var mTime1 = arrayListOf() + mViewModel.exceptionBloodFatData.observe(this) { + val mData1 = arrayListOf() + val mTime1 = arrayListOf() it.data.tcList.asReversed().forEach { mData1.add("${it.data}") mTime1.add("${it.time}") } - listFragment.add(setArgumentFrag(BloodFatExceptionFrag(),tabName[0],mData1,mTime1)) - var mData2 = arrayListOf() - var mTime2 = arrayListOf() + listFragment.add(setArgumentFrag(BloodFatExceptionFrag(), tabName[0], mData1, mTime1)) + val mData2 = arrayListOf() + val mTime2 = arrayListOf() it.data.tgList.asReversed().forEach { mData2.add("${it.data}") mTime2.add("${it.time}") } - listFragment.add(setArgumentFrag(BloodFatExceptionFrag(),tabName[1],mData2,mTime2)) - var mData3 = arrayListOf() - var mTime3 = arrayListOf() + listFragment.add(setArgumentFrag(BloodFatExceptionFrag(), tabName[1], mData2, mTime2)) + val mData3 = arrayListOf() + val mTime3 = arrayListOf() it.data.hdlList.asReversed().forEach { mData3.add("${it.data}") mTime3.add("${it.time}") } - listFragment.add(setArgumentFrag(BloodFatExceptionFrag(),tabName[2],mData3,mTime3)) - var mData4 = arrayListOf() - var mTime4 = arrayListOf() + listFragment.add(setArgumentFrag(BloodFatExceptionFrag(), tabName[2], mData3, mTime3)) + val mData4 = arrayListOf() + val mTime4 = arrayListOf() it.data.ldlList.asReversed().forEach { mData4.add("${it.data}") mTime4.add("${it.time}") } - listFragment.add(setArgumentFrag(BloodFatExceptionFrag(),tabName[3],mData4,mTime4)) + listFragment.add(setArgumentFrag(BloodFatExceptionFrag(), tabName[3], mData4, mTime4)) initTab() initViewPager() } diff --git a/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt b/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt index ae696ae..c4f3422 100644 --- a/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt +++ b/health/src/main/java/com/zj365/health/act/skin/SkinMeasurementMainAct.kt @@ -11,6 +11,7 @@ import android.widget.LinearLayout import android.widget.TextView import android.widget.Toast import com.alibaba.android.arouter.facade.annotation.Route +import com.alipay.sdk.app.PayTask import com.google.android.material.bottomsheet.BottomSheetDialog import com.tencent.mm.opensdk.modelbase.BaseResp import com.tencent.mm.opensdk.modelpay.PayReq @@ -21,6 +22,7 @@ import com.xty.common.LogUtils import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager import com.xty.common.event.WxPayEvent +import com.xty.common.setImage import com.xty.common.util.SpannableUtils import com.xty.network.model.PayGoodsBean import com.xty.network.model.WeixinPayBean @@ -43,18 +45,51 @@ class SkinMeasurementMainAct : BaseVmAct() { var bottomSheetDialog: BottomSheetDialog? = null - lateinit var payGoodsBean: PayGoodsBean + var payGoodsBean: PayGoodsBean? = null - val tipDialog by lazy { +/* val tipDialog by lazy { CancerDialog(this, false, "温馨提示", { bottomSheetDialog?.show() }, { bundle.clear() RouteManager.goAct(ARouterUrl.TONGUE_ORDER_LIST_ACTIVITY, bundle) }) - } + }*/ override fun liveObserver() { + mViewModel.payGoodsObservable.observe(this){ + if (it.data == null){ + return@observe + } + payGoodsBean = it.data + binding.ivBg.setImage(this,it.data.advUrl) + initBottomDialog() + } + + mViewModel.payObservable.observe(this){ + it.data?.let { + val orderInfo: String? = it.alipayOrderInfo // 支付宝订单信息 + val wxmodel: WeixinPayBean? = it.wxmodel // 微信订单信息 + if (wxmodel != null) { + startWechatPay(wxmodel) + } else if (orderInfo != null) { + LogUtils.i("start Alipay") + val orderInfo: String = it.alipayOrderInfo!! // 订单信息 + val payRunnable = Runnable { + val alipay = PayTask(this) + val result = alipay.payV2(orderInfo, true) + val msg = Message() + msg.what = SDK_PAY_FLAG + msg.obj = result + mHandler.sendMessage(msg) + } + // 必须异步调用 + val payThread = Thread(payRunnable) + payThread.start() + } + + } + } } override fun setLayout() = binding.root @@ -70,6 +105,7 @@ class SkinMeasurementMainAct : BaseVmAct() { binding.title.mTvRight.visibility = View.VISIBLE }else{ binding.title.mTvTitle.text ="AI糖医" + mViewModel.getAIGoods() } binding.title.mTvRight.setOnClickListener { @@ -81,74 +117,72 @@ class SkinMeasurementMainAct : BaseVmAct() { } binding.tvSubmit.setOnClickListener { - if (isShowTip) { - tipDialog.setContent("您的舌诊评估记录中,有存在未完成的记录确认需要再次购买吗?") - tipDialog?.show() - } else { - bottomSheetDialog?.show() - } + + bottomSheetDialog?.show() } initBottomDialog() - mViewModel.getAIoods() - mViewModel.aiHasNoFinishOrder() + } fun initBottomDialog() { - if (bottomSheetDialog == null) { - bottomSheetDialog = BottomSheetDialog(this,R.style.Theme_ChartDialogManager) - bottomSheetDialog?.let { dialog -> - val view = LayoutInflater.from(this).inflate(R.layout.dialog_pay, null) - dialog.setContentView(view) - - val tvprice = view.findViewById(R.id.tvPrice) - tvprice.text = SpannableUtils.setSpanMoney(payGoodsBean.price!!) - val ivClose = view.findViewById(R.id.close_button) - ivClose.setOnClickListener { - dialog.dismiss() - } - val tvZhifubao = view.findViewById(R.id.tv_gouxuan_zhifubao) - val tvWeixin = view.findViewById(R.id.tv_gouxuan_weixin) - tvWeixin.isSelected = true - val tvDuihuanma = view.findViewById(R.id.tv_gouxuan_duihuanma) - val llWeixin = view.findViewById(R.id.llWeixin) - val llZhifu = view.findViewById(R.id.llZhifu) - val tvZhifu = view.findViewById(R.id.tvZhifu) - llZhifu.setOnClickListener { - tvZhifubao.isSelected = true - tvDuihuanma.isSelected = false - tvWeixin.isSelected = false - tvZhifu.text = "确认支付" - } - llWeixin.setOnClickListener { - tvZhifubao.isSelected = false - tvDuihuanma.isSelected = false + payGoodsBean?.let { bean -> + if (bottomSheetDialog == null) { + bottomSheetDialog = BottomSheetDialog(this,R.style.Theme_ChartDialogManager) + bottomSheetDialog?.let { dialog -> + val view = LayoutInflater.from(this).inflate(R.layout.dialog_pay, null) + dialog.setContentView(view) + + val tvprice = view.findViewById(R.id.tvPrice) + tvprice.text = SpannableUtils.setSpanMoney(bean.price!!) + val ivClose = view.findViewById(R.id.close_button) + ivClose.setOnClickListener { + dialog.dismiss() + } + val tvZhifubao = view.findViewById(R.id.tv_gouxuan_zhifubao) + val tvWeixin = view.findViewById(R.id.tv_gouxuan_weixin) tvWeixin.isSelected = true - tvZhifu.text = "确认支付" - } - val llDuihuan = view.findViewById(R.id.llDuihuan) - llDuihuan.visibility = View.GONE - llDuihuan.setOnClickListener { - tvWeixin.isSelected = false - tvZhifubao.isSelected = false - tvDuihuanma.isSelected = true - tvZhifu.text = "去兑换" - } + val tvDuihuanma = view.findViewById(R.id.tv_gouxuan_duihuanma) + val llWeixin = view.findViewById(R.id.llWeixin) + val llZhifu = view.findViewById(R.id.llZhifu) + val tvZhifu = view.findViewById(R.id.tvZhifu) + llZhifu.setOnClickListener { + tvZhifubao.isSelected = true + tvDuihuanma.isSelected = false + tvWeixin.isSelected = false + tvZhifu.text = "确认支付" + } + llWeixin.setOnClickListener { + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = false + tvWeixin.isSelected = true + tvZhifu.text = "确认支付" + } + val llDuihuan = view.findViewById(R.id.llDuihuan) + llDuihuan.visibility = View.GONE + llDuihuan.setOnClickListener { + tvWeixin.isSelected = false + tvZhifubao.isSelected = false + tvDuihuanma.isSelected = true + tvZhifu.text = "去兑换" + } - tvZhifu.setOnClickListener { - //支付 - if (tvZhifubao.isSelected) { - //支付宝 - mViewModel.payTongueOrder(payGoodsBean.id.toString(), false) - } else { - //微信 - mViewModel.payTongueOrder(payGoodsBean.id.toString(), true) + tvZhifu.setOnClickListener { + //支付 + if (tvZhifubao.isSelected) { + //支付宝 + mViewModel.payAISugarMedicineOrder(bean.id.toString(), false) + } else { + //微信 + mViewModel.payAISugarMedicineOrder(bean.id.toString(), true) + } + dialog.dismiss() } - dialog.dismiss() } } } + } private val SDK_PAY_FLAG = 1 @@ -207,35 +241,31 @@ class SkinMeasurementMainAct : BaseVmAct() { val resultStatus: String = payResult.getResultStatus() // 判断resultStatus 为9000则代表支付成功 if (TextUtils.equals(resultStatus, "9000")) { - // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。 -// Toast.makeText(this@PreventCancertAct,"支付成功"+payResult,Toast.LENGTH_SHORT).show() -// com.alipay.sdk.pay.demo.PayDemoActivity.showAlert( -// this@PayDemoActivity, -// getString(R.string.pay_success) + payResult -// ) - bundle.clear() - bundle.putString("orderNo", mViewModel.payObservable.value?.data?.orderNo) - bundle.putString("orderType", payGoodsBean.goodsType.toString()) - RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle) + + payGoodsBean?.let { + bundle.clear() + bundle.putString("orderNo", mViewModel.payObservable.value?.data?.orderNo) + bundle.putString("orderType", it.goodsType.toString()) + RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle) + } + } else { Toast.makeText(this@SkinMeasurementMainAct, "支付失败,请联系客服", Toast.LENGTH_SHORT) .show() - // 该笔订单真实的支付结果,需要依赖服务端的异步通知。 -// com.alipay.sdk.pay.demo.PayDemoActivity.showAlert( -// this@PayDemoActivity, -// getString(R.string.pay_failed) + payResult -// ) } } WEIXIN_PAY_FLAG -> { val event = msg.obj as WxPayEvent when (event.code) { BaseResp.ErrCode.ERR_OK -> { - bundle.clear() - bundle.putString("orderNo", mViewModel.payObservable.value?.data?.orderNo) - bundle.putString("orderType", payGoodsBean.goodsType.toString()) - RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle) + payGoodsBean?.let { + bundle.clear() + bundle.putString("orderNo", mViewModel.payObservable.value?.data?.orderNo) + bundle.putString("orderType", it.goodsType.toString()) + RouteManager.goAct(ARouterUrl.PAY_SUCCESS, bundle) + } + } BaseResp.ErrCode.ERR_USER_CANCEL -> { diff --git a/health/src/main/java/com/zj365/health/adapter/HealthSignDataAdapter.kt b/health/src/main/java/com/zj365/health/adapter/HealthSignDataAdapter.kt new file mode 100644 index 0000000..3bfd12a --- /dev/null +++ b/health/src/main/java/com/zj365/health/adapter/HealthSignDataAdapter.kt @@ -0,0 +1,14 @@ +package com.zj365.health.adapter + +import com.chad.library.adapter.base.viewholder.BaseViewHolder +import com.xty.base.adapter.BaseAdapter +import com.zj365.health.R + +class HealthSignDataAdapter : BaseAdapter( + R.layout.item_health_sign_data +) { + + override fun convert(holder: BaseViewHolder, item: String) { + holder.setText(R.id.tvSignData, item) + } +} \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodFatAdapter.kt b/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodFatAdapter.kt index 3267b61..6c8f203 100644 --- a/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodFatAdapter.kt +++ b/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodFatAdapter.kt @@ -1,4 +1,4 @@ -package com.zj365.health.adapter.bloodfat +package com.zj365.health.adapter.bloodfat import android.graphics.Typeface import android.text.SpannableString @@ -10,10 +10,10 @@ import androidx.core.content.ContextCompat import com.chad.library.adapter.base.viewholder.BaseViewHolder import com.xty.base.adapter.BaseAdapter import com.xty.common.Dateutils -import com.zj365.health.R import com.xty.network.model.BloodFatBean import com.xty.network.model.BloodFatHeadInfo import com.xty.network.model.BloodFatType +import com.zj365.health.R class BloodFatAdapter : BaseAdapter(R.layout.item_blood_fat) { override fun convert(holder: BaseViewHolder, item: BloodFatHeadInfo.BloodFat) { diff --git a/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodLipidAdjustAdapter.kt b/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodLipidAdjustAdapter.kt index acf2ca5..d35f544 100644 --- a/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodLipidAdjustAdapter.kt +++ b/health/src/main/java/com/zj365/health/adapter/bloodfat/BloodLipidAdjustAdapter.kt @@ -1,4 +1,4 @@ -package com.zj365.health.adapter.bloodfat +package com.zj365.health.adapter.bloodfat import android.annotation.SuppressLint import android.widget.ImageView @@ -7,12 +7,10 @@ import androidx.core.content.ContextCompat import com.chad.library.adapter.base.viewholder.BaseViewHolder import com.xty.base.adapter.BaseAdapter import com.xty.common.SizeUtil -import com.zj365.health.R import com.xty.network.model.BloodLipidAdjustBean +import com.zj365.health.R -class BloodLipidAdjustAdapter : BaseAdapter( - R.layout.item_blood_lipid_records - ) { +class BloodLipidAdjustAdapter : BaseAdapter(R.layout.item_blood_lipid_records) { var isSelect = false @@ -35,7 +33,6 @@ class BloodLipidAdjustAdapter : BaseAdapter( holder: BaseViewHolder, item: BloodLipidAdjustBean ) { - holder.setGone(R.id.ivSelected, !isSelect) val view = holder.getView(R.id.ivSelected) view.isSelected = item.isSelected diff --git a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BaseChartInitUtils.kt b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BaseChartInitUtils.kt index fff8bda..92278cd 100644 --- a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BaseChartInitUtils.kt +++ b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BaseChartInitUtils.kt @@ -291,7 +291,7 @@ object BaseChartInitUtils { y.setDrawGridLines(true) //绘制横者的x轴 y.setDrawZeroLine(true) y.xOffset = 5f - var markerView = ICompareMarkView( + val markerView = ICompareMarkView( context, R.layout.mark_view_compare, unit, mark ) @@ -430,8 +430,8 @@ object BaseChartInitUtils { ) { chart.let { it.clear() - it.setNoDataText(context.getString(com.zj365.health.R.string.line_chart_not_data)) - it.setNoDataTextColor(ContextCompat.getColor(context, com.zj365.health.R.color.col_455)) + it.setNoDataText(context.getString(R.string.line_chart_not_data)) + it.setNoDataTextColor(ContextCompat.getColor(context, R.color.col_455)) it.setLayerType(View.LAYER_TYPE_SOFTWARE, null) it.setBackgroundColor(Color.WHITE) ///color @@ -471,7 +471,7 @@ object BaseChartInitUtils { val x = it.xAxis x.granularity = 1f //精准设置 - x.textColor = ContextCompat.getColor(context, com.zj365.health.R.color.col_92a) + x.textColor = ContextCompat.getColor(context, R.color.col_92a) x.isEnabled = true x.setDrawGridLines(false) //不绘制y x.setDrawAxisLine(false) @@ -489,10 +489,10 @@ object BaseChartInitUtils { //y轴 val y = it.axisLeft y.setLabelCountAndMaxMinValue(6, false, min - 1, max + 1) - y.textColor = ContextCompat.getColor(context, com.zj365.health.R.color.col_92a) + y.textColor = ContextCompat.getColor(context, R.color.col_92a) y.setDrawAxisLine(false) y.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART) - y.gridColor = ContextCompat.getColor(context, com.zj365.health.R.color.col_92a) + y.gridColor = ContextCompat.getColor(context, R.color.col_92a) y.setGridDashedLine(DashPathEffect(floatArrayOf(5f, 5f), 0f)) y.setDrawGridLines(true) //绘制横者的x轴 y.setDrawZeroLine(true) @@ -541,16 +541,16 @@ object BaseChartInitUtils { lineDataSet.circleRadius = circleRadius lineDataSet.highLightColor = - ContextCompat.getColor(context, com.zj365.health.R.color.col_e0b) //设置点后高亮颜色 + ContextCompat.getColor(context, R.color.col_e0b) //设置点后高亮颜色 lineDataSet.enableDashedHighlightLine(10f, 5f, 0f) lineDataSet.setCircleColor( ContextCompat.getColor( context, - com.zj365.health.R.color.col_41c + R.color.col_41c ) ) //#41C4AF lineDataSet.color = - ContextCompat.getColor(context, com.zj365.health.R.color.col_9BDd) //xian de yanse + ContextCompat.getColor(context, R.color.col_9BDd) //xian de yanse //set1.setFillColor(Color.WHITE); // set1.fillAlpha = 100 if (isShadow) { @@ -596,16 +596,16 @@ object BaseChartInitUtils { lineDataSet.setDrawCircleHole(false) lineDataSet.circleRadius = 3.5f lineDataSet.highLightColor = - ContextCompat.getColor(context, com.zj365.health.R.color.col_e0b) //设置点后高亮颜色 + ContextCompat.getColor(context, R.color.col_e0b) //设置点后高亮颜色 lineDataSet.enableDashedHighlightLine(10f, 5f, 0f) lineDataSet.setCircleColor( ContextCompat.getColor( context, - com.zj365.health.R.color.col_9BD + R.color.col_9BD ) ) //#41C4AF lineDataSet.color = - ContextCompat.getColor(context, com.zj365.health.R.color.col_9BD) //xian de yanse + ContextCompat.getColor(context, R.color.col_9BD) //xian de yanse //set1.setFillColor(Color.WHITE); // set1.fillAlpha = 100 lineDataSet.setDrawHorizontalHighlightIndicator(false) diff --git a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatCompareDataFrag.kt b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatCompareDataFrag.kt index dc58cba..873e3b8 100644 --- a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatCompareDataFrag.kt +++ b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatCompareDataFrag.kt @@ -38,16 +38,17 @@ import java.util.Locale /** * 血脂数据对比 */ -@Suppress("NAME_SHADOWING") class BloodFatCompareDataFrag : BaseVmFrag() { - private var week: Int = 1//默认点击时间是选择时间还是对比时间 1,选择, 2 对比 val binding by lazy { FragBloodLipidCompareDataBinding.inflate(layoutInflater) } - val tcAdapter by lazy { CompareAdapter() } + override fun setLayout() = binding.root + override fun setViewModel() = BloodFatCompareVm() - val tgAdapter by lazy { CompareAdapter() } - val hdlAdapter by lazy { CompareAdapter() } - val ldlAdapter by lazy { CompareAdapter() } + private var week: Int = 1//默认点击时间是选择时间还是对比时间 1,选择, 2 对比 + private val tcAdapter by lazy { CompareAdapter() } + private val tgAdapter by lazy { CompareAdapter() } + private val hdlAdapter by lazy { CompareAdapter() } + private val ldlAdapter by lazy { CompareAdapter() } val fomartStr by lazy { arrayOf("HH:mm", "HH:mm", "MM-dd", "MM-dd", "yy-MM") } @@ -57,8 +58,8 @@ class BloodFatCompareDataFrag : BaseVmFrag() { private val mTitles = arrayOf( "日", "周", "月", "年" ) -/* var lineValue = arrayListOf() //曲线数据 - var lineValueCompare = arrayListOf() //曲线数据*/ + /* var lineValue = arrayListOf() //曲线数据 + var lineValueCompare = arrayListOf() //曲线数据*/ var id: String = "" @@ -81,6 +82,11 @@ class BloodFatCompareDataFrag : BaseVmFrag() { private var bottomSheetDialog: BottomSheetDialog? = null private var weekWheelView: WheelView? = null + private lateinit var tcList: MutableList + private lateinit var tcListCompare: MutableList + + private var tcBarValue = arrayListOf() //柱形数据 + private var tcBarValueCompare = arrayListOf() //柱形数据 @SuppressLint("SuspiciousIndentation") fun initBottomDialog() { @@ -168,7 +174,6 @@ class BloodFatCompareDataFrag : BaseVmFrag() { return dateRanges }*/ - override fun setLayout() = binding.root override fun initData() { super.initData() id = arguments?.getString("id").toString() @@ -181,10 +186,10 @@ class BloodFatCompareDataFrag : BaseVmFrag() { initCharts() initRecycle() setTimeSelect() - binding.clTc.tvTitle.text ="总胆固醇" - binding.clTg.tvTitle.text ="甘油三酯" - binding.clHdl.tvTitle.text ="高密度脂蛋白" - binding.clLdl.tvTitle.text ="低密度脂蛋白" + binding.clTc.tvTitle.text = "总胆固醇" + binding.clTg.tvTitle.text = "甘油三酯" + binding.clHdl.tvTitle.text = "高密度脂蛋白" + binding.clLdl.tvTitle.text = "低密度脂蛋白" binding.tvShowDate.setOnClickListener { when (type) { @@ -211,7 +216,7 @@ class BloodFatCompareDataFrag : BaseVmFrag() { binding.tvHideDate.setOnClickListener { when (type) { 1 -> { - var calendar = Calendar.getInstance() + val calendar = Calendar.getInstance() if (!TextUtils.isEmpty(timeSelect!!.selectTime)) { val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) val date = dateFormat.parse(timeSelect!!.selectTime) @@ -259,8 +264,7 @@ class BloodFatCompareDataFrag : BaseVmFrag() { } 3 -> { - var calendar = Calendar.getInstance() - + val calendar = Calendar.getInstance() timeMonthSelect!!.selectTime if (!TextUtils.isEmpty(timeMonthSelect!!.selectTime)) { val dateFormat = SimpleDateFormat("yyyy-MM", Locale.getDefault()) @@ -302,8 +306,7 @@ class BloodFatCompareDataFrag : BaseVmFrag() { } 4 -> { - var calendar = Calendar.getInstance() - + val calendar = Calendar.getInstance() if (!TextUtils.isEmpty(timeYearSelect!!.selectTime)) { val dateFormat = SimpleDateFormat("yyyy", Locale.getDefault()) val date = dateFormat.parse(timeYearSelect!!.selectTime) @@ -338,7 +341,7 @@ class BloodFatCompareDataFrag : BaseVmFrag() { /* RxTimeTool.getCurTimeString(SimpleDateFormat("yyyy-MM-dd"))*/ SimpleDateFormat("yyyy-MM-dd").format(getdateMunise(-1)), SimpleDateFormat("yyyy-MM-dd").format(getdateMunise(-2)), id - )//TODO + ) } /** @@ -346,7 +349,6 @@ class BloodFatCompareDataFrag : BaseVmFrag() { */ @SuppressLint("SimpleDateFormat") private fun setTimeSelect() { - var calendar = Calendar.getInstance() calendar.time = getdateMunise(-1) binding.tvShowDate.text = SimpleDateFormat("yyyy-MM-dd").format(calendar.time) @@ -360,7 +362,8 @@ class BloodFatCompareDataFrag : BaseVmFrag() { mViewModel.getBloodLipidData( type, dayDate, - binding.tvHideDate.text.toString(), id + binding.tvHideDate.text.toString(), + id ) } timeSelect!!.startDate.set(1922, 1, 1) @@ -386,9 +389,13 @@ class BloodFatCompareDataFrag : BaseVmFrag() { mViewModel.getBloodLipidData( type, binding.tvShowDate.text.toString(), - binding.tvHideDate.text.toString(), id + binding.tvHideDate.text.toString(), + id + ) + timeMonthSelect?.selectTimeWithYearMonth( + binding.tvShowDate, + "yyyy-MM" ) - timeMonthSelect?.selectTimeWithYearMonth(binding.tvShowDate, "yyyy-MM") } timeMonthSelect!!.startDate.set(Calendar.YEAR, 1922) timeMonthSelect!!.startDate.set(Calendar.MONTH, 1) @@ -415,7 +422,10 @@ class BloodFatCompareDataFrag : BaseVmFrag() { binding.tvShowDate.text.toString(), binding.tvHideDate.text.toString(), id ) - timeYearSelect?.selectTimeWithYearMonth(binding.tvShowDate, "yyyy") + timeYearSelect?.selectTimeWithYearMonth( + binding.tvShowDate, + "yyyy" + ) } timeYearSelect!!.startDate.set(Calendar.YEAR, 1922) @@ -430,12 +440,12 @@ class BloodFatCompareDataFrag : BaseVmFrag() { mViewModel.getBloodLipidData( type, binding.tvShowDate.text.toString(), - binding.tvHideDate.text.toString(), id + binding.tvHideDate.text.toString(), + id ) } timeYearSelectCompare!!.startDate.set(Calendar.YEAR, 1922) timeYearSelectCompare!!.endDate = calendaryear - } private fun getdateMunise(int: Int): Date { @@ -444,24 +454,17 @@ class BloodFatCompareDataFrag : BaseVmFrag() { return calendar.time } - override fun setViewModel() = BloodFatCompareVm() - fun convertTimeToIndex(time: String): Int { // 将时间格式转换为小时和分钟 val parts = time.split(":") val hours = parts[0].toInt() val minutes = parts[1].toInt() - // 计算对应的分钟数 val totalMinutes = hours * 60 + minutes - // 计算对应的索引值 - val index = totalMinutes / 10 - - return index + return totalMinutes / 10 } - fun splitDataIntoSegments(dataList: MutableList): MutableList> { val segments = mutableListOf>() var currentSegment = mutableListOf() @@ -478,12 +481,10 @@ class BloodFatCompareDataFrag : BaseVmFrag() { currentSegment.add(model) } } - // 将最后一个线段添加到结果中 if (currentSegment.isNotEmpty()) { segments.add(currentSegment) } - return segments } @@ -500,7 +501,6 @@ class BloodFatCompareDataFrag : BaseVmFrag() { d.add(b) segmentsCompare.add(d) } - return segmentsCompare } @@ -516,7 +516,7 @@ class BloodFatCompareDataFrag : BaseVmFrag() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { when (type) { 1 -> {//日 - it.data.model =it.data.mapDataToTime(it.data.model) + it.data.model = it.data.mapDataToTime(it.data.model) it.data.modelCompare = it.data.mapDataToTime(it.data.modelCompare) } @@ -555,20 +555,16 @@ class BloodFatCompareDataFrag : BaseVmFrag() { setHDLChartData(it.data) setLDLChartData(it.data) - binding.clTc.comprehensiveContent.text = it.data.tcContent binding.clTg.comprehensiveContent.text = it.data.tgContent binding.clHdl.comprehensiveContent.text = it.data.hdlContent binding.clLdl.comprehensiveContent.text = it.data.ldlContent - binding.comprehensiveBlContent.text = it.data.comprehensiveContent - } } private fun initTab() { - val currentDay = Date() dayDate = TimeUtils.date2String(currentDay, "yyyy-MM-dd") // weekDate = "${TimeUtils.date2String(getDateAdd(6), "yyyy-MM-dd")}至$dayDate" @@ -587,7 +583,6 @@ class BloodFatCompareDataFrag : BaseVmFrag() { @SuppressLint("SetTextI18n") override fun onTabSelect(position: Int) { binding.commonTabLayout.currentTab = position - when (position) { 0 -> { type = 1 @@ -627,8 +622,10 @@ class BloodFatCompareDataFrag : BaseVmFrag() { 2 -> { binding.showTitle.text = "选择月" binding.hideTitle.text = "对比月" - binding.tvShowDate.text = HealthDateAndTimeUtils.getPreviousMonthDateRange(1) - binding.tvHideDate.text = HealthDateAndTimeUtils.getPreviousMonthDateRange(2) + binding.tvShowDate.text = + HealthDateAndTimeUtils.getPreviousMonthDateRange(1) + binding.tvHideDate.text = + HealthDateAndTimeUtils.getPreviousMonthDateRange(2) type = 3 mViewModel.getBloodLipidData( type, @@ -667,7 +664,8 @@ class BloodFatCompareDataFrag : BaseVmFrag() { }) } - /* *//** + /* */ + /** * 获取上个月 monthCount 月数 *//* fun getPreviousMonthDateRange(monthCount: Int): String { @@ -680,7 +678,8 @@ class BloodFatCompareDataFrag : BaseVmFrag() { return previousMonth } - *//** + */ + /** * 获取上周的礼拜 周数 *//* fun getPreviousWeekDateRange(weekCount: Int): String { @@ -704,293 +703,337 @@ class BloodFatCompareDataFrag : BaseVmFrag() { return startDate + "至$endDate" }*/ - lateinit var tcList: MutableList - private lateinit var tcListCompare: MutableList - - var tcBarValue = arrayListOf() //柱形数据 - var tcBarValueCompare = arrayListOf() //柱形数据 private fun setTCChartData(data: BloodLipidDataBean) { - setAvgInfo(data,BloodFatType.Tc) + setAvgInfo(data, BloodFatType.Tc) tcList = data.model tcListCompare = data.modelCompare tcBarValue.clear() tcBarValueCompare.clear() - var rever: IntProgression - if (tcList.size < tcListCompare.size) { - rever = (tcListCompare.indices).reversed() + val rever = if (tcList.size < tcListCompare.size) { + (tcListCompare.indices).reversed() } else { - rever = (tcList.indices).reversed() + (tcList.indices).reversed() } if (type == 3) { var compare = tcListCompare.size - tcList.size if (compare > 0) { for (Int in 1..compare) { - tcList.add(tcList.size,BloodLipidDataBean.ModelBean(0f,0f,0f,0f,tcListCompare[tcList.size].time)) + tcList.add( + tcList.size, + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + tcListCompare[tcList.size].time + ) + ) } } else if (compare < 0) { compare = 0 - compare for (Int in 1..compare) { tcListCompare.add( tcListCompare.size, - BloodLipidDataBean.ModelBean(0f,0f,0f,0f,tcList[tcListCompare.size].time) + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + tcList[tcListCompare.size].time + ) ) } } } for (i in rever) { //中间两端在x轴显示尺度 其他情况下不显示 - if (type == 1) { - var listTipG = mutableListOf() - listTipG.add(tcList[tcList.size - 1 - i].time) - listTipG.add("0") - listTipG.add(tcList[tcList.size - 1 - i].tc.toString()) - listTipG.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) - - if (tcList[tcList.size - 1 - i].tc == 0f) { - tcList[tcList.size - 1 - i].tc = Float.NaN - } else { - tcList[tcList.size - 1 - i].tc - } - tcBarValue.add( - BarEntry( - (tcList.size - 1 - i).toFloat(), - tcList[tcList.size - 1 - i].tc, - listTipG + when (type) { + 1 -> { + val listTipG = mutableListOf() + listTipG.add(tcList[tcList.size - 1 - i].time) + listTipG.add("0") + listTipG.add(tcList[tcList.size - 1 - i].tc.toString()) + listTipG.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) + + if (tcList[tcList.size - 1 - i].tc == 0f) { + tcList[tcList.size - 1 - i].tc = Float.NaN + } else { + tcList[tcList.size - 1 - i].tc + } + tcBarValue.add( + BarEntry( + (tcList.size - 1 - i).toFloat(), + tcList[tcList.size - 1 - i].tc, + listTipG + ) ) - ) - if (tcListCompare[tcListCompare.size - 1 - i].tc == 0f) - tcListCompare[tcListCompare.size - 1 - i].tc = Float.NaN - else - tcListCompare[tcListCompare.size - 1 - i].tc + if (tcListCompare[tcListCompare.size - 1 - i].tc == 0f) + tcListCompare[tcListCompare.size - 1 - i].tc = Float.NaN + else + tcListCompare[tcListCompare.size - 1 - i].tc - tcBarValueCompare.add( - BarEntry( - (tcListCompare.size - 1 - i).toFloat(), - tcListCompare[tcListCompare.size - 1 - i].tc, - listTipG + tcBarValueCompare.add( + BarEntry( + (tcListCompare.size - 1 - i).toFloat(), + tcListCompare[tcListCompare.size - 1 - i].tc, + listTipG + ) ) - ) - } else if (type == 2) { - var listTipW = mutableListOf() - listTipW.add(weeker[weeker.size - i - 1]) - listTipW.add("0") - listTipW.add(tcList[tcList.size - 1 - i].tc.toString()) - listTipW.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) - tcBarValue.add( - BarEntry( - (tcList.size - 1 - i).toFloat(), - tcList[tcList.size - 1 - i].tc, - listTipW + } + + 2 -> { + val listTipW = mutableListOf() + listTipW.add(weeker[weeker.size - i - 1]) + listTipW.add("0") + listTipW.add(tcList[tcList.size - 1 - i].tc.toString()) + listTipW.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) + tcBarValue.add( + BarEntry( + (tcList.size - 1 - i).toFloat(), + tcList[tcList.size - 1 - i].tc, + listTipW + ) ) - ) - tcBarValueCompare.add( - BarEntry( - (tcListCompare.size - 1 - i).toFloat(), - tcListCompare[tcListCompare.size - 1 - i].tc, - listTipW + tcBarValueCompare.add( + BarEntry( + (tcListCompare.size - 1 - i).toFloat(), + tcListCompare[tcListCompare.size - 1 - i].tc, + listTipW + ) ) - ) - } else if (type == 3) { + } - var listTipY = mutableListOf() - listTipY.add(tcList[tcList.size - 1 - i].time) - listTipY.add("0") - listTipY.add(tcList[tcList.size - 1 - i].tc.toString()) - listTipY.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) - tcBarValue.add( - BarEntry( - (tcList.size - 1 - i).toFloat(), - tcList[tcList.size - 1 - i].tc, - listTipY + 3 -> { + val listTipY = mutableListOf() + listTipY.add(tcList[tcList.size - 1 - i].time) + listTipY.add("0") + listTipY.add(tcList[tcList.size - 1 - i].tc.toString()) + listTipY.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) + tcBarValue.add( + BarEntry( + (tcList.size - 1 - i).toFloat(), + tcList[tcList.size - 1 - i].tc, + listTipY + ) ) - ) - tcBarValueCompare.add( - BarEntry( - (tcListCompare.size - 1 - i).toFloat(), - tcListCompare[tcListCompare.size - 1 - i].tc, - listTipY + tcBarValueCompare.add( + BarEntry( + (tcListCompare.size - 1 - i).toFloat(), + tcListCompare[tcListCompare.size - 1 - i].tc, + listTipY + ) ) - ) - } else { - var listTipY = mutableListOf() - listTipY.add(tcList[tcList.size - 1 - i].time) - listTipY.add("0") - listTipY.add(tcList[tcList.size - 1 - i].tc.toString()) - listTipY.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) - tcBarValue.add( - BarEntry( - (tcList.size - 1 - i).toFloat(), - tcList[tcList.size - 1 - i].tc, - listTipY + } + + else -> { + val listTipY = mutableListOf() + listTipY.add(tcList[tcList.size - 1 - i].time) + listTipY.add("0") + listTipY.add(tcList[tcList.size - 1 - i].tc.toString()) + listTipY.add(tcListCompare[tcListCompare.size - 1 - i].tc.toString()) + tcBarValue.add( + BarEntry( + (tcList.size - 1 - i).toFloat(), + tcList[tcList.size - 1 - i].tc, + listTipY + ) ) - ) - tcBarValueCompare.add( - BarEntry( - (tcListCompare.size - 1 - i).toFloat(), - tcListCompare[tcListCompare.size - 1 - i].tc, - listTipY + tcBarValueCompare.add( + BarEntry( + (tcListCompare.size - 1 - i).toFloat(), + tcListCompare[tcListCompare.size - 1 - i].tc, + listTipY + ) ) - ) + } } } binding.clTc.mBarChart.clear() - - val min = - BloodLipidGetMinMaxChart.getBloodLipidMix(data.value.minTc, data.valueCompare.minTc) - - val max = - BloodLipidGetMinMaxChart.getBloodLipidMax(data.value.maxTc, data.valueCompare.maxTc) + val min = BloodLipidGetMinMaxChart.getBloodLipidMix( + data.value.minTc, + data.valueCompare.minTc + ) + val max = BloodLipidGetMinMaxChart.getBloodLipidMax( + data.value.maxTc, + data.valueCompare.maxTc + ) BaseChartInitUtils.initBarChartTwo( - requireContext(), binding.clTc.mBarChart, min, max, tcBarValue, tcBarValueCompare, - ICompareMarkView.MarkPage.BloodFilip, "mmol/L", type, 1f + requireContext(), + binding.clTc.mBarChart, + min, + max, + tcBarValue, + tcBarValueCompare, + ICompareMarkView.MarkPage.BloodFilip, + "mmol/L", + type, + 1f ) } - lateinit var tgList: MutableList private lateinit var tgListCompare: MutableList var tgBarValue = arrayListOf() //柱形数据 var tgBarValueCompare = arrayListOf() //柱形数据 private fun setTGChartData(data: BloodLipidDataBean) { - setAvgInfo(data,BloodFatType.Tg) + setAvgInfo(data, BloodFatType.Tg) tgList = data.model tgListCompare = data.modelCompare tgBarValue.clear() tgBarValueCompare.clear() - var rever: IntProgression - if (tgList.size < tgListCompare.size) { - rever = (tgListCompare.indices).reversed() + val rever = if (tgList.size < tgListCompare.size) { + (tgListCompare.indices).reversed() } else { - rever = (tgList.indices).reversed() + (tgList.indices).reversed() } if (type == 3) { var compare = tgListCompare.size - tgList.size if (compare > 0) { for (Int in 1..compare) { - tgList.add(tgList.size,BloodLipidDataBean.ModelBean(0f,0f,0f,0f,tgListCompare[tgList.size].time)) + tgList.add( + tgList.size, + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + tgListCompare[tgList.size].time + ) + ) } } else if (compare < 0) { compare = 0 - compare for (Int in 1..compare) { tgListCompare.add( tgListCompare.size, - BloodLipidDataBean.ModelBean(0f,0f,0f,0f,tgList[tgListCompare.size].time) + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + tgList[tgListCompare.size].time + ) ) } } } for (i in rever) { //中间两端在x轴显示尺度 其他情况下不显示 - if (type == 1) { - var listTipG = mutableListOf() - listTipG.add(tgList[tgList.size - 1 - i].time) - listTipG.add("0") - listTipG.add(tgList[tgList.size - 1 - i].tg.toString()) - listTipG.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) - - if (tgList[tgList.size - 1 - i].tg == 0f) { - tgList[tgList.size - 1 - i].tg = Float.NaN - } else { - tgList[tgList.size - 1 - i].tg - } - tgBarValue.add( - BarEntry( - (tgList.size - 1 - i).toFloat(), - tgList[tgList.size - 1 - i].tg, - listTipG + when (type) { + 1 -> { + val listTipG = mutableListOf() + listTipG.add(tgList[tgList.size - 1 - i].time) + listTipG.add("0") + listTipG.add(tgList[tgList.size - 1 - i].tg.toString()) + listTipG.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) + + if (tgList[tgList.size - 1 - i].tg == 0f) { + tgList[tgList.size - 1 - i].tg = Float.NaN + } else { + tgList[tgList.size - 1 - i].tg + } + tgBarValue.add( + BarEntry( + (tgList.size - 1 - i).toFloat(), + tgList[tgList.size - 1 - i].tg, + listTipG + ) ) - ) - if (tgListCompare[tgListCompare.size - 1 - i].tg == 0f) - tgListCompare[tgListCompare.size - 1 - i].tg = Float.NaN - else - tgListCompare[tgListCompare.size - 1 - i].tg + if (tgListCompare[tgListCompare.size - 1 - i].tg == 0f) + tgListCompare[tgListCompare.size - 1 - i].tg = Float.NaN + else + tgListCompare[tgListCompare.size - 1 - i].tg - tgBarValueCompare.add( - BarEntry( - (tgListCompare.size - 1 - i).toFloat(), - tgListCompare[tgListCompare.size - 1 - i].tg, - listTipG + tgBarValueCompare.add( + BarEntry( + (tgListCompare.size - 1 - i).toFloat(), + tgListCompare[tgListCompare.size - 1 - i].tg, + listTipG + ) ) - ) - } else if (type == 2) { - var listTipW = mutableListOf() - listTipW.add(weeker[weeker.size - i - 1]) - listTipW.add("0") - listTipW.add(tgList[tgList.size - 1 - i].tg.toString()) - listTipW.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) - tgBarValue.add( - BarEntry( - (tgList.size - 1 - i).toFloat(), - tgList[tgList.size - 1 - i].tg, - listTipW + } + + 2 -> { + var listTipW = mutableListOf() + listTipW.add(weeker[weeker.size - i - 1]) + listTipW.add("0") + listTipW.add(tgList[tgList.size - 1 - i].tg.toString()) + listTipW.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) + tgBarValue.add( + BarEntry( + (tgList.size - 1 - i).toFloat(), + tgList[tgList.size - 1 - i].tg, + listTipW + ) ) - ) - tgBarValueCompare.add( - BarEntry( - (tgListCompare.size - 1 - i).toFloat(), - tgListCompare[tgListCompare.size - 1 - i].tg, - listTipW + tgBarValueCompare.add( + BarEntry( + (tgListCompare.size - 1 - i).toFloat(), + tgListCompare[tgListCompare.size - 1 - i].tg, + listTipW + ) ) - ) - } else if (type == 3) { + } - var listTipY = mutableListOf() - listTipY.add(tgList[tgList.size - 1 - i].time) - listTipY.add("0") - listTipY.add(tgList[tgList.size - 1 - i].tg.toString()) - listTipY.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) - tgBarValue.add( - BarEntry( - (tgList.size - 1 - i).toFloat(), - tgList[tgList.size - 1 - i].tg, - listTipY + 3 -> { + + var listTipY = mutableListOf() + listTipY.add(tgList[tgList.size - 1 - i].time) + listTipY.add("0") + listTipY.add(tgList[tgList.size - 1 - i].tg.toString()) + listTipY.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) + tgBarValue.add( + BarEntry( + (tgList.size - 1 - i).toFloat(), + tgList[tgList.size - 1 - i].tg, + listTipY + ) ) - ) - tgBarValueCompare.add( - BarEntry( - (tgListCompare.size - 1 - i).toFloat(), - tgListCompare[tgListCompare.size - 1 - i].tg, - listTipY + tgBarValueCompare.add( + BarEntry( + (tgListCompare.size - 1 - i).toFloat(), + tgListCompare[tgListCompare.size - 1 - i].tg, + listTipY + ) ) - ) - } else { - var listTipY = mutableListOf() - listTipY.add(tgList[tgList.size - 1 - i].time) - listTipY.add("0") - listTipY.add(tgList[tgList.size - 1 - i].tg.toString()) - listTipY.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) - tgBarValue.add( - BarEntry( - (tgList.size - 1 - i).toFloat(), - tgList[tgList.size - 1 - i].tg, - listTipY + } + + else -> { + var listTipY = mutableListOf() + listTipY.add(tgList[tgList.size - 1 - i].time) + listTipY.add("0") + listTipY.add(tgList[tgList.size - 1 - i].tg.toString()) + listTipY.add(tgListCompare[tgListCompare.size - 1 - i].tg.toString()) + tgBarValue.add( + BarEntry( + (tgList.size - 1 - i).toFloat(), + tgList[tgList.size - 1 - i].tg, + listTipY + ) ) - ) - tgBarValueCompare.add( - BarEntry( - (tgListCompare.size - 1 - i).toFloat(), - tgListCompare[tgListCompare.size - 1 - i].tg, - listTipY + tgBarValueCompare.add( + BarEntry( + (tgListCompare.size - 1 - i).toFloat(), + tgListCompare[tgListCompare.size - 1 - i].tg, + listTipY + ) ) - ) + } } } binding.clTg.mBarChart.clear() - - val min = BloodLipidGetMinMaxChart.getBloodLipidMix(data.value.minTg, data.valueCompare.minTg) - val max = BloodLipidGetMinMaxChart.getBloodLipidMax(data.value.maxTg, data.valueCompare.maxTg) @@ -999,13 +1042,14 @@ class BloodFatCompareDataFrag : BaseVmFrag() { ICompareMarkView.MarkPage.BloodFilip, "mmol/L", type, 1f ) } + lateinit var hdlList: MutableList private lateinit var hdlListCompare: MutableList var hdlBarValue = arrayListOf() //柱形数据 var hdlBarValueCompare = arrayListOf() //柱形数据 private fun setHDLChartData(data: BloodLipidDataBean) { - setAvgInfo(data,BloodFatType.Hdl) + setAvgInfo(data, BloodFatType.Hdl) hdlList = data.model hdlListCompare = data.modelCompare hdlBarValue.clear() @@ -1020,14 +1064,29 @@ class BloodFatCompareDataFrag : BaseVmFrag() { var compare = hdlListCompare.size - hdlList.size if (compare > 0) { for (Int in 1..compare) { - hdlList.add(hdlList.size,BloodLipidDataBean.ModelBean(0f,0f,0f,0f,hdlListCompare[hdlList.size].time)) + hdlList.add( + hdlList.size, + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + hdlListCompare[hdlList.size].time + ) + ) } } else if (compare < 0) { compare = 0 - compare for (Int in 1..compare) { hdlListCompare.add( hdlListCompare.size, - BloodLipidDataBean.ModelBean(0f,0f,0f,0f,hdlList[hdlListCompare.size].time) + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + hdlList[hdlListCompare.size].time + ) ) } } @@ -1133,13 +1192,11 @@ class BloodFatCompareDataFrag : BaseVmFrag() { } binding.clHdl.mBarChart.clear() - - val min = BloodLipidGetMinMaxChart.getBloodLipidMix(data.value.minHdl, data.valueCompare.minHdl) - val max = BloodLipidGetMinMaxChart.getBloodLipidMax(data.value.maxHdl, data.valueCompare.maxHdl) + BaseChartInitUtils.initBarChartTwo( requireContext(), binding.clHdl.mBarChart, min, max, hdlBarValue, hdlBarValueCompare, ICompareMarkView.MarkPage.BloodFilip, "mmol/L", type, 1f @@ -1152,7 +1209,7 @@ class BloodFatCompareDataFrag : BaseVmFrag() { var ldlBarValue = arrayListOf() //柱形数据 var ldlBarValueCompare = arrayListOf() //柱形数据 private fun setLDLChartData(data: BloodLipidDataBean) { - setAvgInfo(data,BloodFatType.Ldl) + setAvgInfo(data, BloodFatType.Ldl) ldlList = data.model ldlListCompare = data.modelCompare ldlBarValue.clear() @@ -1167,14 +1224,29 @@ class BloodFatCompareDataFrag : BaseVmFrag() { var compare = ldlListCompare.size - ldlList.size if (compare > 0) { for (Int in 1..compare) { - ldlList.add(ldlList.size,BloodLipidDataBean.ModelBean(0f,0f,0f,0f,ldlListCompare[ldlList.size].time)) + ldlList.add( + ldlList.size, + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + ldlListCompare[ldlList.size].time + ) + ) } } else if (compare < 0) { compare = 0 - compare for (Int in 1..compare) { ldlListCompare.add( ldlListCompare.size, - BloodLipidDataBean.ModelBean(0f,0f,0f,0f,ldlList[ldlListCompare.size].time) + BloodLipidDataBean.ModelBean( + 0f, + 0f, + 0f, + 0f, + ldlList[ldlListCompare.size].time + ) ) } } @@ -1281,7 +1353,6 @@ class BloodFatCompareDataFrag : BaseVmFrag() { binding.clLdl.mBarChart.clear() - val min = BloodLipidGetMinMaxChart.getBloodLipidMix(data.value.minLdl, data.valueCompare.minLdl) @@ -1292,8 +1363,9 @@ class BloodFatCompareDataFrag : BaseVmFrag() { ICompareMarkView.MarkPage.BloodFilip, "mmol/L", type, 1f ) } + @SuppressLint("SuspiciousIndentation") - private fun setAvgInfo(valueData: BloodLipidDataBean,dataType: BloodFatType) { + private fun setAvgInfo(valueData: BloodLipidDataBean, dataType: BloodFatType) { var list: MutableList = mutableListOf() list = BloodLipidDataDealWithList.setDataList( valueData.value, @@ -1304,22 +1376,24 @@ class BloodFatCompareDataFrag : BaseVmFrag() { dataType, list ) - when(dataType){ - BloodFatType.Tc ->{ + when (dataType) { + BloodFatType.Tc -> { tcAdapter.setNewInstance(list) } - BloodFatType.Tg ->{ + + BloodFatType.Tg -> { tgAdapter.setNewInstance(list) } - BloodFatType.Hdl ->{ + + BloodFatType.Hdl -> { hdlAdapter.setNewInstance(list) } - BloodFatType.Ldl ->{ + + BloodFatType.Ldl -> { ldlAdapter.setNewInstance(list) } } - } /*private fun calculateBarWidth(dataCount: Int): Float { val maximumBarWidth = 0.38f // 设置最大柱形图宽度 @@ -1360,7 +1434,7 @@ class BloodFatCompareDataFrag : BaseVmFrag() { binding.clLdl.mRecycle.adapter = ldlAdapter } - fun initCharts(){ + fun initCharts() { binding.clTc.mBarChart.setNoDataText(getString(R.string.line_chart_not_data)) binding.clTc.mBarChart.setNoDataTextColor( ContextCompat.getColor( diff --git a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionDataAct.kt b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionDataAct.kt index 0ca8c69..9390123 100644 --- a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionDataAct.kt +++ b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionDataAct.kt @@ -28,18 +28,16 @@ class BloodFatExceptionDataAct : BaseExceptionDataAct() { } override fun getHint(): String { - if(binding.title.mTvTitle.text.toString().equals("总胆固醇偏高")){ - return "正常范围:5.23-5.69mmol/L" - }else if(binding.title.mTvTitle.text.toString().equals("甘油三酯偏高")){ - return "正常范围:0.45-1.69mmol/L" - - }else if(binding.title.mTvTitle.text.toString().equals("高密度脂蛋白偏低")){ - return "正常范围:0.93-1.93mmol/L" - - }else if (binding.title.mTvTitle.text.toString().equals("低密度脂蛋白偏高")){ - return "正常范围:0-3.12mmol/L" + return if(binding.title.mTvTitle.text.toString() == "总胆固醇偏高"){ + "正常范围:2.83-5.20mmol/L" + }else if(binding.title.mTvTitle.text.toString() == "甘油三酯偏高"){ + "正常范围:0.45-1.69mmol/L" + }else if(binding.title.mTvTitle.text.toString() == "高密度脂蛋白偏低"){ + "正常范围:0.93-1.93mmol/L" + }else if (binding.title.mTvTitle.text.toString() == "低密度脂蛋白偏高"){ + "正常范围:0-3.12mmol/L" }else{ - return "正常范围:5.23-5.69mmol/L" + "正常范围:2.83-5.20mmol/L" } } @@ -56,7 +54,6 @@ class BloodFatExceptionDataAct : BaseExceptionDataAct() { leftAxis.setLabelCountAndMaxMinValue(6, true, 0f, 160f) } } - } override fun getMarkView(): IMarker? { diff --git a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionFrag.kt b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionFrag.kt index fc6371a..7d61cd1 100644 --- a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionFrag.kt +++ b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatExceptionFrag.kt @@ -1,5 +1,6 @@ package com.zj365.health.fragment.bloodlipid +import android.annotation.SuppressLint import android.content.Context import android.view.View import android.widget.TextView @@ -22,50 +23,63 @@ class BloodFatExceptionFrag: BaseExceptionDataFragment() { } override fun getHint(): String { - if (binding.tvListTitle.text == "总胆固醇"){ - return "正常范围:2.83-5.20mmol/L" - }else if(binding.tvListTitle.text == "甘油三酯"){ - return "正常范围:0.45-1.69mmol/L" - }else if(binding.tvListTitle.text == "高密度脂蛋白"){ - return "正常范围:0.93-1.93mmol/L" - }else{ - return "正常范围:0-3.12mmol/L" - } + return when (binding.tvListTitle.text) { + "总胆固醇" -> { + "正常范围:2.83-5.20mmol/L" + } + + "甘油三酯" -> { + "正常范围:0.45-1.69mmol/L" + } + + "高密度脂蛋白" -> { + "正常范围:0.93-1.93mmol/L" + } + else -> { + "正常范围:0-3.12mmol/L" + } + } } override fun setLabelCount(leftAxis: YAxis) { - leftAxis.setLabelCountAndMaxMinValue(6,false,0f,8f) + leftAxis.setLabelCountAndMaxMinValue(6, false, 0f, 8f) } override fun getMarkView(): IMarker? { - return CustomMarkerViewXueyang( + return CustomMarkerViewXuezhi( this.requireContext(), - R.layout.custom_marker_view_xueyang,result) + R.layout.custom_marker_view_xuezhi, result + ) } - class CustomMarkerViewXueyang(context: Context?, layoutResource: Int, var result:MutableList) : - MarkerView(context, layoutResource) { - private val mData: TextView - private val mTime: TextView + @SuppressLint("ViewConstructor") + class CustomMarkerViewXuezhi( + context: Context?, + layoutResource: Int, + var result: MutableList + ) : MarkerView(context, layoutResource) { + + private val mXueZhiData = findViewById(R.id.tvXueZhiData) as TextView + private val mXueZhiTime = findViewById(R.id.tvXueZhiTime) as TextView + + @SuppressLint("SimpleDateFormat", "SetTextI18n") override fun refreshContent(e: Entry, highlight: Highlight) { // 在 refreshContent 方法中设置需要显示的内容。 val barEntry = e as BarEntry val x = barEntry.x - val get = result.get(x.toInt()) - var data = get.data+"%" - mData.setText(data) - mTime.setText( RxTimeTool.milliseconds2String( + val get = result[x.toInt()] + val data = get.data + mXueZhiData.text = data + mXueZhiTime.text = RxTimeTool.milliseconds2String( get.time.toLong() * 1000, SimpleDateFormat("HH :mm") - )) - setOffset((-getWidth() / 2).toFloat(), (-getHeight()).toFloat() - 10f); + ) + setOffset((-width / 2).toFloat(), (-height).toFloat() - 10f) } init { // 在构造函数中获取 MarkerView 中的 TextView。 - mData = findViewById(R.id.tvData) as TextView - mTime = findViewById(R.id.tvTime) as TextView } } diff --git a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatFrag.kt b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatFrag.kt index c9a9b07..2c1cd46 100644 --- a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatFrag.kt +++ b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodFatFrag.kt @@ -43,6 +43,7 @@ import com.xty.common.TimeSelect import com.xty.common.arouter.ARouterUrl import com.xty.common.arouter.RouteManager import com.xty.common.event.BloodFilipOpenSuccessEvent +import com.xty.common.util.CommonToastUtils import com.xty.common.util.SpannableUtils import com.xty.common.weight.tablayout.TabEntity import com.xty.common.weight.tablayout.listener.CustomTabEntity @@ -81,7 +82,7 @@ class BloodFatFrag : BaseVmFrag() { val fomartStr by lazy { arrayOf("HH:mm", "HH:mm", "MM-dd", "MM-dd", "yy-MM") } private val weekStr by lazy { resources.getStringArray(R.array.week_day) } val dialogBind by lazy { - DialogTip(requireContext(), "需绑定中健三六五健康手表,才能查看", "去绑定") { + DialogTip(requireContext(), "需绑定安瑜健康手表,才能查看", "去绑定") { RouteManager.goAct(ARouterUrl.DEVICE_CHOICE) } } @@ -97,7 +98,7 @@ class BloodFatFrag : BaseVmFrag() { type = 1 dayDate = binding.tvShowDate.text.toString() mViewModel.getBloodFatInfo(type, binding.tvShowDate.text.toString(), id, isDemonstrate) - mViewModel.getBloodFatInfo(type, binding.tvShowDate.text.toString(), id, isDemonstrate) +// mViewModel.getBloodFatInfo(type, binding.tvShowDate.text.toString(), id, isDemonstrate) } } @@ -106,7 +107,6 @@ class BloodFatFrag : BaseVmFrag() { type = 3 mouthDate = binding.tvShowDate.text.toString() mViewModel.getBloodFatInfo(type, binding.tvShowDate.text.toString(), id, isDemonstrate) - } } @@ -121,7 +121,7 @@ class BloodFatFrag : BaseVmFrag() { } } - var tips = "" + private var tips = "" val tipDialog by lazy { HealthDialog(requireContext(), true, tips) { } @@ -155,6 +155,7 @@ class BloodFatFrag : BaseVmFrag() { } } + @SuppressLint("SetTextI18n") override fun initView() { super.initView() binding.tgLayout.tvBloodValue.text = "甘油三酯 (TG)" @@ -239,12 +240,11 @@ class BloodFatFrag : BaseVmFrag() { binding.tvBloodLipidAdjust.setOnClickListener { if (bloodFatStatus == 1) { -// val tip = "尿酸建模出值重要提示:\n" + -// "1、建模期间,累计有效佩戴满72小时;\n" + -// "2、建模完成后,每天18:00至第二天6:00期间,佩戴时长累计满6小时,APP出具尿酸值;\n" + -// "3、尿酸值每天7:00出值。本次值为前一天18:00到当天早上6:00尿酸平均值。" -// tipDialog.setContent(tip) -// tipDialog.show() + tips = "1、建模期间,累计有效佩戴满72小时;\n" + + "2、建模完成后,每天18:00至第二天6:00期间,佩戴时长累计满6小时,APP出具血脂值;\n" + + "3、血脂值每天7:00出值。本次值为前一天18:00到当天早上6:00血脂平均值。" + tipDialog.setContent(tips) + tipDialog.show() } else { RouteManager.goAct(ARouterUrl.BL_ADJUST) } @@ -260,13 +260,20 @@ class BloodFatFrag : BaseVmFrag() { private fun setKindLayoutClickListener(view: BloodFatChartBinding) { view.mLineChart.setNoDataText(getString(R.string.line_chart_not_data)) - view.mLineChart.setNoDataTextColor( ContextCompat.getColor( requireContext(), R.color.col_455 ) ) + view.mBarChart.setNoDataText(getString(R.string.line_chart_not_data)) + view.mBarChart.setNoDataTextColor( + ContextCompat.getColor( + requireContext(), + R.color.col_455 + ) + ) + view.zhexianTv.setOnClickListener { view.mLineChart.visibility = View.VISIBLE view.mBarChart.visibility = View.GONE @@ -352,22 +359,23 @@ class BloodFatFrag : BaseVmFrag() { RouteManager.goAct(ARouterUrl.BL_FAT_EXCEPTION_DATA, bundle) } + @SuppressLint("SetTextI18n", "SimpleDateFormat") override fun observer() { mViewModel.bloodFatHeadInfo.observe(this) { expireTimeStr = it.data.expireTime bloodFatStatus = it.data.status if (!TextUtils.isEmpty(expireTimeStr)) { - binding.tvEndTime.text = "到期时间:${expireTimeStr}" + binding.tvEndTime.text = "到期时间:${expireTimeStr}" } else { binding.tvEndTime.text = "" } when (it.data.status) { 0 -> { //没有开通 - setNoOpenBloodLipid(0) + setNoOpenBloodLipid(0, it.data.data) } 1 -> { //建模中 - setNoOpenBloodLipid(1) + setNoOpenBloodLipid(1, it.data.data) } else -> { @@ -477,7 +485,6 @@ class BloodFatFrag : BaseVmFrag() { } } - //设置数据 private fun setValuss( daysModelList: MutableList, @@ -549,6 +556,45 @@ class BloodFatFrag : BaseVmFrag() { } } + if (selectDay()) { + setOrganStatus(chartType) + } + + when (chartType) { + 0 -> { + binding.tcLayout.mLineChart.clear() + binding.tcLayout.mBarChart.clear() + } + + 1 -> { + binding.tgLayout.mLineChart.clear() + binding.tgLayout.mBarChart.clear() + } + + 2 -> { + binding.hdlLayout.mLineChart.clear() + binding.hdlLayout.mBarChart.clear() + } + + else -> { + binding.ldlLayout.mLineChart.clear() + binding.ldlLayout.mBarChart.clear() + } + } + + if (list.isNullOrEmpty()) { + return + } + + for ((index, modelCompare) in list.withIndex()) { + modelCompare.index = index +// modelCompare.uaValue = if (modelCompare.uaValue > 0f) { +// modelCompare.uaValue +// } else { +// Float.NaN +// } + } + for (i in list.indices) { //中间两端在x轴显示尺度 其他情况下不显示 lineValue.add( @@ -569,26 +615,34 @@ class BloodFatFrag : BaseVmFrag() { when (chartType) { 0 -> { - binding.tcLayout.mLineChart.clear() - binding.tcLayout.mBarChart.clear() - initChart(list, bean.value.minTc, bean.value.maxTc, chartType, lineValue, barValue) - if (selectDay()) { - setOrganStatus(chartType) - } +// binding.tcLayout.mLineChart.clear() +// binding.tcLayout.mBarChart.clear() + initChart( + list, + bean.value.minTc, + bean.value.maxTc, + chartType, + lineValue, + barValue + ) } 1 -> { - binding.tgLayout.mLineChart.clear() - binding.tgLayout.mBarChart.clear() - initChart(list, bean.value.minTg, bean.value.maxTg, chartType, lineValue, barValue) - if (selectDay()) { - setOrganStatus(chartType) - } +// binding.tgLayout.mLineChart.clear() +// binding.tgLayout.mBarChart.clear() + initChart( + list, + bean.value.minTg, + bean.value.maxTg, + chartType, + lineValue, + barValue + ) } 2 -> { - binding.hdlLayout.mLineChart.clear() - binding.hdlLayout.mBarChart.clear() +// binding.hdlLayout.mLineChart.clear() +// binding.hdlLayout.mBarChart.clear() initChart( list, bean.value.minHdl, @@ -597,15 +651,11 @@ class BloodFatFrag : BaseVmFrag() { lineValue, barValue ) - if (selectDay()) { - setOrganStatus(chartType) - } } else -> { - binding.ldlLayout.mLineChart.clear() - binding.ldlLayout.mBarChart.clear() - +// binding.ldlLayout.mLineChart.clear() +// binding.ldlLayout.mBarChart.clear() initChart( list, bean.value.minLdl, @@ -614,9 +664,6 @@ class BloodFatFrag : BaseVmFrag() { lineValue, barValue ) - if (selectDay()) { - setOrganStatus(chartType) - } } } } @@ -650,17 +697,17 @@ class BloodFatFrag : BaseVmFrag() { ): String { when (type) { 1 -> { - /*if (bean.uaValue == 0f) { - bean.uaValue = Float.NaN - }*/ - return bean.formatTime +// if (bean.uaValue == 0f) { +// bean.uaValue = Float.NaN +// } + return bean.time } 3 -> { - /* if (bean.uaValue == 0f) { - bean.uaValue = Float.NaN - }*/ - return bean.time + /* if (bean.uaValue == 0f) { + bean.uaValue = Float.NaN + }*/ + return bean.formatTime } 2 -> { @@ -711,7 +758,6 @@ class BloodFatFrag : BaseVmFrag() { } 1 -> { - when (OrganStatusCalcUtil.tgStatus(data.tg)) { 1 -> { tgAbNormalTime++ @@ -726,7 +772,6 @@ class BloodFatFrag : BaseVmFrag() { } 2 -> { - when (OrganStatusCalcUtil.hdlStatus(data.hdl)) { 1 -> { hdlAbNormalTime++ @@ -828,26 +873,18 @@ class BloodFatFrag : BaseVmFrag() { val barsetsNew = ArrayList() val segments = splitDataIntoSegments(list) +// if (segments.size > 0) { +// segments = checkData(segments) +// } val dataSets = segments.mapNotNull { segment -> if (segment.isEmpty()) return@mapNotNull null val entries = segment.mapIndexed { index, model -> - val time = if (type == 1 || type == 2 || type == 3) { - model.formatTime - } else { - model.time - } - var indes = 0 - list.forEachIndexed { index, modelCompare -> - if (time == modelCompare.formatTime || time == modelCompare.time) { - indes = index - } - } Entry( - indes.toFloat(), + model.index.toFloat(), model.uaValue, - lineValue[indes].data + lineValue[model.index].data ) } return@mapNotNull setData(entries, chartType) @@ -893,23 +930,10 @@ class BloodFatFrag : BaseVmFrag() { if (segment.isEmpty()) return@mapNotNull null val entries = segment.mapIndexed { index, model -> - - val time = if (type == 1 || type == 2 || type == 3) { - model.formatTime - } else { - model.time - } - var indes = 0 - list.forEachIndexed { index, modelCompare -> - if (time == modelCompare.formatTime || time == modelCompare.time) { - indes = index - } - } - BarEntry( - indes.toFloat(), + model.index.toFloat(), model.uaValue, - barValue[indes].data + barValue[model.index].data ) } return@mapNotNull setBarData(entries, chartType) @@ -980,21 +1004,24 @@ class BloodFatFrag : BaseVmFrag() { return max(minimumBarWidth, min(maximumBarWidth, calculatedBarWidth)) } - fun splitDataIntoSegments(dataList: MutableList): MutableList> { + fun splitDataIntoSegments( + dataList: MutableList + ): MutableList> { val segments = mutableListOf>() var currentSegment = mutableListOf() for (model in dataList) { - if (model.uaValue.isNaN()) { - // 遇到 Float.NaN,如果当前线段不为空,则添加到结果中,并开始新的线段 - if (currentSegment.isNotEmpty()) { - segments.add(currentSegment) - currentSegment = mutableListOf() - } - } else { - // 遇到有效数据,将其添加到当前线段中 - currentSegment.add(model) - } +// if (model.uaValue.isNaN()) { +// // 遇到 Float.NaN,如果当前线段不为空,则添加到结果中,并开始新的线段 +// if (currentSegment.isNotEmpty()) { +// segments.add(currentSegment) +// currentSegment = mutableListOf() +// } +// } else { +// // 遇到有效数据,将其添加到当前线段中 +// currentSegment.add(model) +// } + currentSegment.add(model) } // 将最后一个线段添加到结果中 @@ -1005,12 +1032,14 @@ class BloodFatFrag : BaseVmFrag() { return segments } - private fun checkData(segmentsCompare: MutableList>): MutableList> { + private fun checkData( + segmentsCompare: MutableList> + ): MutableList> { when (type) { 1 -> { - if (segmentsCompare[0][0].time != "00:00") { + if (segmentsCompare[0][0].time != "05:00") { val d = mutableListOf() - val b = BloodFatBean.ModelCompare(0f, "00:00") + val b = BloodFatBean.ModelCompare(0f, "05:00") d.add(b) segmentsCompare.add(d) } @@ -1018,10 +1047,11 @@ class BloodFatFrag : BaseVmFrag() { binding.tvShowDate.text.toString(), SimpleDateFormat("yyyy-MM-dd") ) && - segmentsCompare[segmentsCompare.size - 1][segmentsCompare[segmentsCompare.size - 1].size - 1].time != "23:50" + segmentsCompare[segmentsCompare.size - 1] + [segmentsCompare[segmentsCompare.size - 1].size - 1].time != "09:00" ) { val d = mutableListOf() - val b = BloodFatBean.ModelCompare(0f, "23:50") + val b = BloodFatBean.ModelCompare(0f, "09:00") d.add(b) segmentsCompare.add(d) } @@ -1191,7 +1221,7 @@ class BloodFatFrag : BaseVmFrag() { values, lineChart, 2.5f, - 2f, + 4f, true ) } @@ -1407,16 +1437,19 @@ class BloodFatFrag : BaseVmFrag() { when (chartType) { 0 -> { binding.clCurTc.mOrganView.tvFirstValue.text = SpannableUtils.setSpan( - tcNormalTime, Color.parseColor("#313131") + tcNormalTime, + Color.parseColor("#313131") ) - if (tcNormalTime > 0) { + if (tcNormalTime >= 0) { binding.clCurTc.mOrganView.ivFirst.visibility = View.VISIBLE } else { binding.clCurTc.mOrganView.ivFirst.visibility = View.INVISIBLE } - binding.clCurTc.mOrganView.tvSecondValue.text = - SpannableUtils.setSpan(tcAbNormalTime, Color.parseColor("#313131")) + binding.clCurTc.mOrganView.tvSecondValue.text = SpannableUtils.setSpan( + tcAbNormalTime, + Color.parseColor("#313131") + ) if (tcAbNormalTime > 0) { binding.clCurTc.mOrganView.ivSecond.visibility = View.VISIBLE } else { @@ -1425,9 +1458,11 @@ class BloodFatFrag : BaseVmFrag() { } 1 -> { - binding.clCurTg.mOrganView.tvFirstValue.text = - SpannableUtils.setSpan(tgNormalTime, Color.parseColor("#313131")) - if (tgNormalTime > 0) { + binding.clCurTg.mOrganView.tvFirstValue.text = SpannableUtils.setSpan( + tgNormalTime, + Color.parseColor("#313131") + ) + if (tgNormalTime >= 0) { binding.clCurTg.mOrganView.ivFirst.visibility = View.VISIBLE } else { binding.clCurTg.mOrganView.ivFirst.visibility = View.INVISIBLE @@ -1445,7 +1480,7 @@ class BloodFatFrag : BaseVmFrag() { 2 -> { binding.clCurHdl.mOrganView.tvFirstValue.text = SpannableUtils.setSpan(hdlNormalTime, Color.parseColor("#313131")) - if (hdlNormalTime > 0) { + if (hdlNormalTime >= 0) { binding.clCurHdl.mOrganView.ivFirst.visibility = View.VISIBLE } else { binding.clCurHdl.mOrganView.ivFirst.visibility = View.INVISIBLE @@ -1463,7 +1498,7 @@ class BloodFatFrag : BaseVmFrag() { else -> { binding.clCurLdl.mOrganView.tvFirstValue.text = SpannableUtils.setSpan(ldlNormalTime, Color.parseColor("#313131")) - if (ldlNormalTime > 0) { + if (ldlNormalTime >= 0) { binding.clCurLdl.mOrganView.ivFirst.visibility = View.VISIBLE } else { binding.clCurLdl.mOrganView.ivFirst.visibility = View.INVISIBLE @@ -1481,91 +1516,172 @@ class BloodFatFrag : BaseVmFrag() { } @SuppressLint("SetTextI18n") - fun setNoOpenBloodLipid(status: Int) { + fun setNoOpenBloodLipid(status: Int, data: BloodFatHeadInfo.Data?) { var valueDesc = "" if (status == 0) { - valueDesc = "未开通" - binding.llRenew.visibility = View.GONE + if (TextUtils.isEmpty(expireTimeStr)) { + valueDesc = "未开通" + binding.tvOpen.visibility = View.VISIBLE + binding.tvRenew.visibility = View.GONE + binding.compareTv.visibility = View.GONE + binding.llRenew.visibility = View.GONE + + binding.tcLayout.llEmpty.visibility = View.VISIBLE + binding.tgLayout.llEmpty.visibility = View.VISIBLE + binding.hdlLayout.llEmpty.visibility = View.VISIBLE + binding.ldlLayout.llEmpty.visibility = View.VISIBLE + binding.tcLayout.mBarChart.visibility = View.GONE + binding.tcLayout.mLineChart.visibility = View.GONE + binding.tgLayout.mBarChart.visibility = View.GONE + binding.tgLayout.mLineChart.visibility = View.GONE + binding.hdlLayout.mBarChart.visibility = View.GONE + binding.hdlLayout.mLineChart.visibility = View.GONE + binding.ldlLayout.mBarChart.visibility = View.GONE + binding.ldlLayout.mLineChart.visibility = View.GONE + binding.tcLayout.zhexianTv.visibility = View.GONE + binding.tcLayout.zhuzhuanTv.visibility = View.GONE + binding.tcLayout.mDesc.visibility = View.GONE + binding.tgLayout.zhexianTv.visibility = View.GONE + binding.tgLayout.zhuzhuanTv.visibility = View.GONE + binding.tgLayout.mDesc.visibility = View.GONE + binding.hdlLayout.zhexianTv.visibility = View.GONE + binding.hdlLayout.zhuzhuanTv.visibility = View.GONE + binding.hdlLayout.mDesc.visibility = View.GONE + binding.ldlLayout.zhexianTv.visibility = View.GONE + binding.ldlLayout.zhuzhuanTv.visibility = View.GONE + binding.ldlLayout.mDesc.visibility = View.GONE + } else { + valueDesc = "--" + binding.tvOpen.visibility = View.GONE + binding.compareTv.visibility = View.VISIBLE + binding.tvRenew.visibility = View.VISIBLE + binding.llRenew.visibility = View.VISIBLE + } } else if (status == 1) { valueDesc = "建模中" binding.llRenew.visibility = View.VISIBLE - binding.tvRenew.visibility = View.GONE binding.tvBloodLipidAdjust.text = "建模说明" + binding.tvRenew.visibility = View.GONE + binding.tvOpen.visibility = View.GONE + binding.compareTv.visibility = View.VISIBLE + + binding.tcLayout.llEmpty.visibility = View.VISIBLE + binding.tgLayout.llEmpty.visibility = View.VISIBLE + binding.hdlLayout.llEmpty.visibility = View.VISIBLE + binding.ldlLayout.llEmpty.visibility = View.VISIBLE + binding.tcLayout.mBarChart.visibility = View.GONE + binding.tcLayout.mLineChart.visibility = View.GONE + binding.tgLayout.mBarChart.visibility = View.GONE + binding.tgLayout.mLineChart.visibility = View.GONE + binding.hdlLayout.mBarChart.visibility = View.GONE + binding.hdlLayout.mLineChart.visibility = View.GONE + binding.ldlLayout.mBarChart.visibility = View.GONE + binding.ldlLayout.mLineChart.visibility = View.GONE + binding.tcLayout.zhexianTv.visibility = View.GONE + binding.tcLayout.zhuzhuanTv.visibility = View.GONE + binding.tcLayout.mDesc.visibility = View.GONE + binding.tgLayout.zhexianTv.visibility = View.GONE + binding.tgLayout.zhuzhuanTv.visibility = View.GONE + binding.tgLayout.mDesc.visibility = View.GONE + binding.hdlLayout.zhexianTv.visibility = View.GONE + binding.hdlLayout.zhuzhuanTv.visibility = View.GONE + binding.hdlLayout.mDesc.visibility = View.GONE + binding.ldlLayout.zhexianTv.visibility = View.GONE + binding.ldlLayout.zhuzhuanTv.visibility = View.GONE + binding.ldlLayout.mDesc.visibility = View.GONE + } + + binding.clCurTc.tvBloodValue.text = if (data != null) { + if (data.tc > 0) { + data.tc.toString() + } else { + valueDesc + } + } else { + valueDesc } - binding.tvOpen.visibility = View.VISIBLE - binding.compareTv.visibility = View.GONE - - - binding.tcLayout.zhexianTv.visibility = View.GONE - binding.tcLayout.zhuzhuanTv.visibility = View.GONE - binding.tcLayout.mDesc.visibility = View.GONE - binding.tcLayout.mBarChart.visibility = View.GONE - binding.tcLayout.mLineChart.visibility = View.GONE - binding.tcLayout.llEmpty.visibility = View.VISIBLE - - binding.tgLayout.zhexianTv.visibility = View.GONE - binding.tgLayout.zhuzhuanTv.visibility = View.GONE - binding.tgLayout.mDesc.visibility = View.GONE - binding.tgLayout.mBarChart.visibility = View.GONE - binding.tgLayout.mLineChart.visibility = View.GONE - binding.tgLayout.llEmpty.visibility = View.VISIBLE - - binding.hdlLayout.zhexianTv.visibility = View.GONE - binding.hdlLayout.zhuzhuanTv.visibility = View.GONE - binding.hdlLayout.mDesc.visibility = View.GONE - binding.hdlLayout.mBarChart.visibility = View.GONE - binding.hdlLayout.mLineChart.visibility = View.GONE - binding.hdlLayout.llEmpty.visibility = View.VISIBLE - - binding.ldlLayout.zhexianTv.visibility = View.GONE - binding.ldlLayout.zhuzhuanTv.visibility = View.GONE - binding.ldlLayout.mDesc.visibility = View.GONE - binding.ldlLayout.mBarChart.visibility = View.GONE - binding.ldlLayout.mLineChart.visibility = View.GONE - binding.ldlLayout.llEmpty.visibility = View.VISIBLE - - binding.clCurTc.tvBloodValue.text = valueDesc binding.clCurTc.tvTestTime.text = "mmol/L ${ Dateutils.formatTime(System.currentTimeMillis(), Dateutils.HH_MM_Format) }" binding.clCurTc.mOrganView.tvFirstValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + 0, + Color.parseColor("#313131") ) binding.clCurTc.mOrganView.tvSecondValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + tcAbNormalTime, + Color.parseColor("#313131") ) - binding.clCurTg.tvBloodValue.text = valueDesc + binding.clCurTg.tvBloodValue.text = if (data != null) { + if (data.tg > 0) { + data.tg.toString() + } else { + valueDesc + } + } else { + valueDesc + } binding.clCurTg.tvTestTime.text = "mmol/L ${ - Dateutils.formatTime(System.currentTimeMillis(), Dateutils.HH_MM_Format) + Dateutils.formatTime( + System.currentTimeMillis(), + Dateutils.HH_MM_Format + ) }" binding.clCurTg.mOrganView.tvFirstValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + 0, + Color.parseColor("#313131") ) binding.clCurTg.mOrganView.tvSecondValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + tgAbNormalTime, + Color.parseColor("#313131") ) - binding.clCurHdl.tvBloodValue.text = valueDesc + binding.clCurHdl.tvBloodValue.text = if (data != null) { + if (data.hdl > 0) { + data.hdl.toString() + } else { + valueDesc + } + } else { + valueDesc + } binding.clCurHdl.tvTestTime.text = "mmol/L ${ - Dateutils.formatTime(System.currentTimeMillis(), Dateutils.HH_MM_Format) + Dateutils.formatTime( + System.currentTimeMillis(), + Dateutils.HH_MM_Format + ) }" binding.clCurHdl.mOrganView.tvFirstValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + 0, + Color.parseColor("#313131") ) binding.clCurHdl.mOrganView.tvSecondValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + hdlAbNormalTime, + Color.parseColor("#313131") ) - binding.clCurLdl.tvBloodValue.text = valueDesc + binding.clCurLdl.tvBloodValue.text = if (data != null) { + if (data.ldl > 0) { + data.ldl.toString() + } else { + valueDesc + } + } else { + valueDesc + } binding.clCurLdl.tvTestTime.text = "mmol/L ${ - Dateutils.formatTime(System.currentTimeMillis(), Dateutils.HH_MM_Format) + Dateutils.formatTime( + System.currentTimeMillis(), + Dateutils.HH_MM_Format + ) }" binding.clCurLdl.mOrganView.tvFirstValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + 0, + Color.parseColor("#313131") ) binding.clCurLdl.mOrganView.tvSecondValue.text = SpannableUtils.setSpan( - 0, Color.parseColor("#313131") + ldlAbNormalTime, + Color.parseColor("#313131") ) } @@ -1575,6 +1691,7 @@ class BloodFatFrag : BaseVmFrag() { binding.tvRenew.visibility = View.GONE binding.compareTv.visibility = View.VISIBLE binding.llRenew.visibility = View.GONE + binding.tvEndTime.text = "2088-12-21 18:00:00" binding.clCurTc.tvBloodValue.text = "5.07" binding.clCurTc.tvTestTime.text = "mmol/L ${ diff --git a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidDataDealWithList.kt b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidDataDealWithList.kt index a2fd2d6..d4699a5 100644 --- a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidDataDealWithList.kt +++ b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidDataDealWithList.kt @@ -7,64 +7,99 @@ import com.xty.network.model.ValueMap object BloodLipidDataDealWithList { val tcContentStr by lazy { - arrayOf("日期","平均总胆固醇","正常次数","偏高次数") + arrayOf("日期", "平均总胆固醇", "正常次数", "偏高次数") } val tcOtherContentStr by lazy { - arrayOf("日期","平均总胆固醇","最高总胆固醇","最低总胆固醇","正常次数","偏高次数") + arrayOf( + "日期", + "平均总胆固醇", + "最高总胆固醇", + "最低总胆固醇", + "正常次数", + "偏高次数", + "累计次数" + ) } val tgContentStr by lazy { - arrayOf("日期","平均甘油三酯","正常次数","偏高次数") + arrayOf("日期", "平均甘油三酯", "正常次数", "偏高次数") } val tgOtherContentStr by lazy { - arrayOf("日期","平均甘油三酯","最高甘油三酯","最低甘油三酯","正常次数","偏高次数") + arrayOf( + "日期", + "平均甘油三酯", + "最高甘油三酯", + "最低甘油三酯", + "正常次数", + "偏高次数", + "累计次数" + ) } val hdlContentStr by lazy { - arrayOf("日期","平均高密度脂蛋白","正常次数","偏低次数") + arrayOf("日期", "平均高密度脂蛋白", "正常次数", "偏低次数") } val hdlOtherContentStr by lazy { - arrayOf("日期","平均甘油三酯","最高高密度脂蛋白","最低高密度脂蛋白","正常次数","偏高次数") + arrayOf( + "日期", + "平均甘油三酯", + "最高高密度脂蛋白", + "最低高密度脂蛋白", + "正常次数", + "偏高次数", + "累计次数" + ) } val ldlContentStr by lazy { - arrayOf("日期","平均低密度脂蛋白","正常次数","偏高次数") + arrayOf("日期", "平均低密度脂蛋白", "正常次数", "偏高次数") } val ldlOtherContentStr by lazy { - arrayOf("日期","平均甘油三酯","最高低密度脂蛋白","最低低密度脂蛋白","正常次数","偏高次数") + arrayOf( + "日期", + "平均甘油三酯", + "最高低密度脂蛋白", + "最低低密度脂蛋白", + "正常次数", + "偏高次数", + "累计次数" + ) } - open fun setDataList( + fun setDataList( valueData: BloodLipidDataBean.ValueCompare, compareValueData: BloodLipidDataBean.ValueCompare, - hideData:String, - showData:String, - type:Int, //1,日,2,周,3,月,4,年 - dataType:BloodFatType, // + hideData: String, + showData: String, + type: Int, //1,日,2,周,3,月,4,年 + dataType: BloodFatType, // list: MutableList ): MutableList { // 标题头 val data0 = ValueMap().apply { - when(dataType){ - BloodFatType.Tc ->{ + when (dataType) { + BloodFatType.Tc -> { title = tcContentStr[0] } - BloodFatType.Tg ->{ + + BloodFatType.Tg -> { title = tgContentStr[0] } - BloodFatType.Hdl ->{ + + BloodFatType.Hdl -> { title = hdlContentStr[0] } - BloodFatType.Ldl ->{ + + BloodFatType.Ldl -> { title = ldlContentStr[0] } } if (type == 2) { - var tv1 =hideData + var tv1 = hideData var tvarray = tv1.split("至") tv1 = tvarray[0].substring(5, tvarray[0].length) valueCompare = "对比周\n$tv1" @@ -80,18 +115,18 @@ object BloodLipidDataDealWithList { } else { when (type) { 3 -> {//月 - valueCompare = "对比月\n" + hideData - value = "选择月\n" + showData + valueCompare = "对比月\n$hideData" + value = "选择月\n$showData" } 4 -> {//年 - valueCompare = "对比年\n" + hideData - value = "选择年\n" + showData + valueCompare = "对比年\n$hideData" + value = "选择年\n$showData" } else -> {//日 - valueCompare = "对比日期\n" + hideData - value = "选择日期\n" +showData + valueCompare = "对比日期\n$hideData" + value = "选择日期\n$showData" } } } @@ -104,360 +139,1104 @@ object BloodLipidDataDealWithList { when (dataType) { BloodFatType.Tc -> { title = tcContentStr[1] - state = - if (valueData.avgTc > compareValueData.avgTc) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgTc > compareValueData.avgTc) { 1 - else if (valueData.avgTc < compareValueData.avgTc) + } else if (valueData.avgTc < compareValueData.avgTc) { 2 - else 0 - valueCompare = "${compareValueData.avgTc}mmol/L" - value = "${valueData.avgTc}mmol/L" + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgTc + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgTc + } else { + "--" + } + }mmol/L" } BloodFatType.Tg -> { title = tgContentStr[1] - state = - if (valueData.avgTg > compareValueData.avgTg) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgTg > compareValueData.avgTg) { 1 - else if (valueData.avgTg < compareValueData.avgTg) + } else if (valueData.avgTg < compareValueData.avgTg) { 2 - else 0 - valueCompare = "${compareValueData.avgTg}mmol/L" - value = "${valueData.avgTg}mmol/L" - + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgTg + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgTg + } else { + "--" + } + }mmol/L" } BloodFatType.Hdl -> { title = hdlContentStr[1] - state = - if (valueData.avgHdl > compareValueData.avgHdl) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgHdl > compareValueData.avgHdl) { 1 - else if (valueData.avgHdl < compareValueData.avgHdl) + } else if (valueData.avgHdl < compareValueData.avgHdl) { 2 - else 0 - valueCompare = "${compareValueData.avgHdl}mmol/L" - value = "${valueData.avgHdl}mmol/L" - + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgHdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgHdl + } else { + "--" + } + }mmol/L" } BloodFatType.Ldl -> { title = ldlContentStr[1] - state = - if (valueData.avgLdl > compareValueData.avgLdl) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgLdl > compareValueData.avgLdl) { 1 - else if (valueData.avgLdl < compareValueData.avgLdl) + } else if (valueData.avgLdl < compareValueData.avgLdl) { 2 - else 0 - valueCompare = "${compareValueData.avgLdl}mmol/L" - value = "${valueData.avgLdl}mmol/L" + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgLdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgLdl + } else { + "--" + } + }mmol/L" } } } list.add(data1) + //正常次数 val data2 = ValueMap().apply { when (dataType) { BloodFatType.Tc -> { title = tcContentStr[2] - state = - if (valueData.tcNormal > compareValueData.tcNormal) 1 else if (valueData.tcNormal < compareValueData.tcNormal) 2 else 0 - valueCompare = "${compareValueData.tcNormal}次" - value = "${valueData.tcNormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tcNormal > compareValueData.tcNormal) { + 1 + } else if (valueData.tcNormal < compareValueData.tcNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tcNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tcNormal + } else { + "--" + } + }次" } BloodFatType.Tg -> { title = tgContentStr[2] - state = - if (valueData.tgNormal > compareValueData.tgNormal) 1 else if (valueData.tgNormal < compareValueData.tgNormal) 2 else 0 - valueCompare = "${compareValueData.tgNormal}次" - value = "${valueData.tgNormal}次" - + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tgNormal > compareValueData.tgNormal) { + 1 + } else if (valueData.tgNormal < compareValueData.tgNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tgNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tgNormal + } else { + "--" + } + }次" } BloodFatType.Hdl -> { title = hdlContentStr[2] - state = - if (valueData.hdlNormal > compareValueData.hdlNormal) 1 else if (valueData.hdlNormal < compareValueData.hdlNormal) 2 else 0 - valueCompare = "${compareValueData.hdlNormal}次" - value = "${valueData.hdlNormal}次" - + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.hdlNormal > compareValueData.hdlNormal) { + 1 + } else if (valueData.hdlNormal < compareValueData.hdlNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.hdlNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.hdlNormal + } else { + "--" + } + }次" } BloodFatType.Ldl -> { title = ldlContentStr[2] - state = - if (valueData.ldlNormal > compareValueData.ldlNormal) 1 else if (valueData.ldlNormal < compareValueData.ldlNormal) 2 else 0 - valueCompare = "${compareValueData.ldlNormal}次" - value = "${valueData.ldlNormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.ldlNormal > compareValueData.ldlNormal) { + 1 + } else if (valueData.ldlNormal < compareValueData.ldlNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.ldlNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.ldlNormal + } else { + "--" + } + }次" } } - } list.add(data2) + //偏高次数 val data3 = ValueMap().apply { - when (dataType) { BloodFatType.Tc -> { title = tcContentStr[3] - state = - if (valueData.tcAbnormal > compareValueData.tcAbnormal) 1 else if (valueData.tcAbnormal < compareValueData.tcAbnormal) 2 else 0 - valueCompare = "${compareValueData.tcAbnormal}次" - value = "${valueData.tcAbnormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tcAbnormal > compareValueData.tcAbnormal) { + 1 + } else if (valueData.tcAbnormal < compareValueData.tcAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tcAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tcAbnormal + } else { + "--" + } + }次" } BloodFatType.Tg -> { title = tgContentStr[3] - state = - if (valueData.tgAbnormal > compareValueData.tgAbnormal) 1 else if (valueData.tgAbnormal < compareValueData.tgAbnormal) 2 else 0 - valueCompare = "${compareValueData.tgAbnormal}次" - value = "${valueData.tgAbnormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tgAbnormal > compareValueData.tgAbnormal) { + 1 + } else if (valueData.tgAbnormal < compareValueData.tgAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tgAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tgAbnormal + } else { + "--" + } + }次" } BloodFatType.Hdl -> { title = hdlContentStr[3] - state = - if (valueData.hdlAbnormal > compareValueData.hdlAbnormal) 1 else if (valueData.hdlAbnormal < compareValueData.hdlAbnormal) 2 else 0 - valueCompare = "${compareValueData.hdlAbnormal}次" - value = "${valueData.hdlAbnormal}次" - + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.hdlAbnormal > compareValueData.hdlAbnormal) { + 1 + } else if (valueData.hdlAbnormal < compareValueData.hdlAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.hdlAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.hdlAbnormal + } else { + "--" + } + }次" } BloodFatType.Ldl -> { title = ldlContentStr[3] - state = - if (valueData.ldlAbnormal > compareValueData.ldlAbnormal) 1 else if (valueData.ldlAbnormal < compareValueData.ldlAbnormal) 2 else 0 - valueCompare = "${compareValueData.ldlAbnormal}次" - value = "${valueData.ldlAbnormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.ldlAbnormal > compareValueData.ldlAbnormal) { + 1 + } else if (valueData.ldlAbnormal < compareValueData.ldlAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.ldlAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.ldlAbnormal + } else { + "--" + } + }次" } } - } list.add(data3) - }else{ + } else { + //累计次数 + val data6 = ValueMap().apply { + when (dataType) { + BloodFatType.Tc -> { + title = tcOtherContentStr[6] + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.count > compareValueData.count) { + 1 + } else if (valueData.count < compareValueData.count) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.count + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.count + } else { + "--" + } + }次" + } + + BloodFatType.Tg -> { + title = tcOtherContentStr[6] + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.count > compareValueData.count) { + 1 + } else if (valueData.count < compareValueData.count) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.count + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.count + } else { + "--" + } + }次" + } + + BloodFatType.Hdl -> { + title = tcOtherContentStr[6] + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.count > compareValueData.count) { + 1 + } else if (valueData.count < compareValueData.count) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.count + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.count + } else { + "--" + } + }次" + + } + + BloodFatType.Ldl -> { + title = tcOtherContentStr[6] + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.count > compareValueData.count) { + 1 + } else if (valueData.count < compareValueData.count) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.count + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.count + } else { + "--" + } + }次" + } + } + } + list.add(data6) + //平均数 val data1 = ValueMap().apply { when (dataType) { BloodFatType.Tc -> { title = tcOtherContentStr[1] - state = - if (valueData.avgTc > compareValueData.avgTc) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgTc > compareValueData.avgTc) { 1 - else if (valueData.avgTc < compareValueData.avgTc) + } else if (valueData.avgTc < compareValueData.avgTc) { 2 - else 0 - valueCompare = "${compareValueData.avgTc}mmol/L" - value = "${valueData.avgTc}mmol/L" + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgTc + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgTc + } else { + "--" + } + }mmol/L" } BloodFatType.Tg -> { title = tgOtherContentStr[1] - state = - if (valueData.avgTg > compareValueData.avgTg) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgTg > compareValueData.avgTg) { 1 - else if (valueData.avgTg < compareValueData.avgTg) + } else if (valueData.avgTg < compareValueData.avgTg) { 2 - else 0 - valueCompare = "${compareValueData.avgTg}mmol/L" - value = "${valueData.avgTg}mmol/L" - + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgTg + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgTg + } else { + "--" + } + }mmol/L" } BloodFatType.Hdl -> { title = hdlOtherContentStr[1] - state = - if (valueData.avgHdl > compareValueData.avgHdl) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgHdl > compareValueData.avgHdl) { 1 - else if (valueData.avgHdl < compareValueData.avgHdl) + } else if (valueData.avgHdl < compareValueData.avgHdl) { 2 - else 0 - valueCompare = "${compareValueData.avgHdl}mmol/L" - value = "${valueData.avgHdl}mmol/L" - + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgHdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgHdl + } else { + "--" + } + }mmol/L" } BloodFatType.Ldl -> { title = ldlOtherContentStr[1] - state = - if (valueData.avgLdl > compareValueData.avgLdl) + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.avgLdl > compareValueData.avgLdl) { 1 - else if (valueData.avgLdl < compareValueData.avgLdl) + } else if (valueData.avgLdl < compareValueData.avgLdl) { 2 - else 0 - valueCompare = "${compareValueData.avgLdl}mmol/L" - value = "${valueData.avgLdl}mmol/L" + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.avgLdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.avgLdl + } else { + "--" + } + }mmol/L" } } } list.add(data1) val data4 = ValueMap().apply { - when (dataType) { BloodFatType.Tc -> { title = tcOtherContentStr[2] - state = - if (valueData.maxTc > compareValueData.maxTc) 1 else if (valueData.maxTc < compareValueData.maxTc) 2 else 0 - valueCompare = "${compareValueData.maxTc}mmol/L" - value = "${valueData.maxTc}mmol/L" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.maxTc > compareValueData.maxTc) { + 1 + } else if (valueData.maxTc < compareValueData.maxTc) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.maxTc + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.maxTc + } else { + "--" + } + }mmol/L" } BloodFatType.Tg -> { title = tgOtherContentStr[2] - state = - if (valueData.maxTg > compareValueData.maxTg) 1 else if (valueData.maxTg < compareValueData.maxTg) 2 else 0 - valueCompare = "${compareValueData.maxTg}mmol/L" - value = "${valueData.maxTg}mmol/L" - + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.maxTg > compareValueData.maxTg) { + 1 + } else if (valueData.maxTg < compareValueData.maxTg) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.maxTg + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.maxTg + } else { + "--" + } + }mmol/L" } BloodFatType.Hdl -> { title = hdlOtherContentStr[2] - state = - if (valueData.maxHdl > compareValueData.maxHdl) 1 else if (valueData.maxHdl < compareValueData.maxHdl) 2 else 0 - valueCompare = "${compareValueData.maxHdl}mmol/L" - value = "${valueData.maxHdl}mmol/L" - + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.maxHdl > compareValueData.maxHdl) { + 1 + } else if (valueData.maxHdl < compareValueData.maxHdl) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.maxHdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.maxHdl + } else { + "--" + } + }mmol/L" } BloodFatType.Ldl -> { title = ldlOtherContentStr[2] - state = - if (valueData.maxLdl > compareValueData.maxLdl) 1 else if (valueData.maxLdl < compareValueData.maxLdl) 2 else 0 - valueCompare = "${compareValueData.maxLdl}mmol/L" - value = "${valueData.maxLdl}mmol/L" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.maxLdl > compareValueData.maxLdl) { + 1 + } else if (valueData.maxLdl < compareValueData.maxLdl) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.maxLdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.maxLdl + } else { + "--" + } + }mmol/L" } } - } - list.add(data4) val data5 = ValueMap().apply { - when (dataType) { BloodFatType.Tc -> { title = tcOtherContentStr[3] - state = - if (valueData.minTc > compareValueData.minTc) 1 else if (valueData.minTc < compareValueData.minTc) 2 else 0 - valueCompare = "${compareValueData.minTc}mmol/L" - value = "${valueData.minTc}mmol/L" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.minTc > compareValueData.minTc) { + 1 + } else if (valueData.minTc < compareValueData.minTc) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.minTc + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.minTc + } else { + "--" + } + }mmol/L" } BloodFatType.Tg -> { title = tgOtherContentStr[3] - state = - if (valueData.minTg > compareValueData.minTg) 1 else if (valueData.minTg < compareValueData.minTg) 2 else 0 - valueCompare = "${compareValueData.minTg}mmol/L" - value = "${valueData.minTg}mmol/L" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.minTg > compareValueData.minTg) { + 1 + } else if (valueData.minTg < compareValueData.minTg) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.minTg + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.minTg + } else { + "--" + } + }mmol/L" } BloodFatType.Hdl -> { title = hdlOtherContentStr[3] - state = - if (valueData.minHdl > compareValueData.minHdl) 1 else if (valueData.minHdl < compareValueData.minHdl) 2 else 0 - valueCompare = "${compareValueData.minHdl}mmol/L" - value = "${valueData.minHdl}mmol/L" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.minHdl > compareValueData.minHdl) { + 1 + } else if (valueData.minHdl < compareValueData.minHdl) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.minHdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.minHdl + } else { + "--" + } + }mmol/L" } BloodFatType.Ldl -> { title = ldlOtherContentStr[3] - state = - if (valueData.minLdl > compareValueData.minLdl) 1 else if (valueData.minLdl < compareValueData.minLdl) 2 else 0 - valueCompare = "${compareValueData.minLdl}mmol/L" - value = "${valueData.minLdl}mmol/L" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.minLdl > compareValueData.minLdl) { + 1 + } else if (valueData.minLdl < compareValueData.minLdl) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.minLdl + } else { + "--" + } + }mmol/L" + value = "${ + if (valueData.count > 0) { + valueData.minLdl + } else { + "--" + } + }mmol/L" } } - } - list.add(data5) + //正常次数 val data2 = ValueMap().apply { when (dataType) { BloodFatType.Tc -> { title = tcOtherContentStr[4] - state = - if (valueData.tcNormal > compareValueData.tcNormal) 1 else if (valueData.tcNormal < compareValueData.tcNormal) 2 else 0 - valueCompare = "${compareValueData.tcNormal}次" - value = "${valueData.tcNormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tcNormal > compareValueData.tcNormal) { + 1 + } else if (valueData.tcNormal < compareValueData.tcNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tcNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tcNormal + } else { + "--" + } + }次" } BloodFatType.Tg -> { title = tgOtherContentStr[4] - state = - if (valueData.tgNormal > compareValueData.tgNormal) 1 else if (valueData.tgNormal < compareValueData.tgNormal) 2 else 0 - valueCompare = "${compareValueData.tgNormal}次" - value = "${valueData.tgNormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tgNormal > compareValueData.tgNormal) { + 1 + } else if (valueData.tgNormal < compareValueData.tgNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tgNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tgNormal + } else { + "--" + } + }次" } BloodFatType.Hdl -> { title = hdlOtherContentStr[4] - state = - if (valueData.hdlNormal > compareValueData.hdlNormal) 1 else if (valueData.hdlNormal < compareValueData.hdlNormal) 2 else 0 - valueCompare = "${compareValueData.hdlNormal}次" - value = "${valueData.hdlNormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.hdlNormal > compareValueData.hdlNormal) { + 1 + } else if (valueData.hdlNormal < compareValueData.hdlNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.hdlNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.hdlNormal + } else { + "--" + } + }次" } BloodFatType.Ldl -> { title = ldlOtherContentStr[4] - state = - if (valueData.ldlNormal > compareValueData.ldlNormal) 1 else if (valueData.ldlNormal < compareValueData.ldlNormal) 2 else 0 - valueCompare = "${compareValueData.ldlNormal}次" - value = "${valueData.ldlNormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.ldlNormal > compareValueData.ldlNormal) { + 1 + } else if (valueData.ldlNormal < compareValueData.ldlNormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.ldlNormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.ldlNormal + } else { + "--" + } + }次" } } - } list.add(data2) + //偏高次数 val data3 = ValueMap().apply { - when (dataType) { BloodFatType.Tc -> { title = tcOtherContentStr[5] - state = - if (valueData.tcAbnormal > compareValueData.tcAbnormal) 1 else if (valueData.tcAbnormal < compareValueData.tcAbnormal) 2 else 0 - valueCompare = "${compareValueData.tcAbnormal}次" - value = "${valueData.tcAbnormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tcAbnormal > compareValueData.tcAbnormal) { + 1 + } else if (valueData.tcAbnormal < compareValueData.tcAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tcAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tcAbnormal + } else { + "--" + } + }次" } BloodFatType.Tg -> { title = tgOtherContentStr[5] - state = - if (valueData.tgAbnormal > compareValueData.tgAbnormal) 1 else if (valueData.tgAbnormal < compareValueData.tgAbnormal) 2 else 0 - valueCompare = "${compareValueData.tgAbnormal}次" - value = "${valueData.tgAbnormal}次" - + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.tgAbnormal > compareValueData.tgAbnormal) { + 1 + } else if (valueData.tgAbnormal < compareValueData.tgAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.tgAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.tgAbnormal + } else { + "--" + } + }次" } BloodFatType.Hdl -> { title = hdlOtherContentStr[5] - state = - if (valueData.hdlAbnormal > compareValueData.hdlAbnormal) 1 else if (valueData.hdlAbnormal < compareValueData.hdlAbnormal) 2 else 0 - valueCompare = "${compareValueData.hdlAbnormal}次" - value = "${valueData.hdlAbnormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.hdlAbnormal > compareValueData.hdlAbnormal) { + 1 + } else if (valueData.hdlAbnormal < compareValueData.hdlAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.hdlAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.hdlAbnormal + } else { + "--" + } + }次" } BloodFatType.Ldl -> { title = ldlOtherContentStr[5] - state = - if (valueData.ldlAbnormal > compareValueData.ldlAbnormal) 1 else if (valueData.ldlAbnormal < compareValueData.ldlAbnormal) 2 else 0 - valueCompare = "${compareValueData.ldlAbnormal}次" - value = "${valueData.ldlAbnormal}次" + state = if (valueData.count > 0 && compareValueData.count > 0) { + if (valueData.ldlAbnormal > compareValueData.ldlAbnormal) { + 1 + } else if (valueData.ldlAbnormal < compareValueData.ldlAbnormal) { + 2 + } else { + 0 + } + } else { + 3 + } + valueCompare = "${ + if (compareValueData.count > 0) { + compareValueData.ldlAbnormal + } else { + "--" + } + }次" + value = "${ + if (valueData.count > 0) { + valueData.ldlAbnormal + } else { + "--" + } + }次" } } - } list.add(data3) } - return list } } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidGetMinMaxChart.kt b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidGetMinMaxChart.kt index 195db88..fc2465f 100644 --- a/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidGetMinMaxChart.kt +++ b/health/src/main/java/com/zj365/health/fragment/bloodlipid/BloodLipidGetMinMaxChart.kt @@ -1,43 +1,40 @@ package com.zj365.health.fragment.bloodlipid import kotlin.math.max +import kotlin.math.min object BloodLipidGetMinMaxChart { - - fun getBloodLipidMax(maxValue:Float,maxCompareValue: Float):Float{ - val max = if (maxValue != 0f && maxCompareValue != 0f) { - if(maxValue >maxCompareValue){ + fun getBloodLipidMax(maxValue: Float, maxCompareValue: Float): Float { + val max = if (maxValue != 0f && maxCompareValue != 0f) { + if (maxValue > maxCompareValue) { maxValue - }else{ + } else { maxCompareValue } - } else if (maxValue== 0f && maxCompareValue != 0f) { + } else if (maxValue == 0f && maxCompareValue != 0f) { maxCompareValue - } else if(maxValue!= 0f && maxCompareValue== 0f) { + } else if (maxValue != 0f && maxCompareValue == 0f) { maxValue - }else{ - max(maxValue,maxCompareValue) + } else { + max(maxValue, maxCompareValue) } - return max } - fun getBloodLipidMix(minValue:Float,minCompareValue: Float):Float{ + + fun getBloodLipidMix(minValue: Float, minCompareValue: Float): Float { val mix = if (minValue != 0f && minCompareValue != 0f) { - if(minValue >minCompareValue){ - minValue - }else{ + if (minValue > minCompareValue) { minCompareValue + } else { + minValue } - } else if (minValue== 0f && minCompareValue != 0f) { - minCompareValue - } else if(minValue!= 0f && minCompareValue== 0f) { + } else if (minValue == 0f && minCompareValue != 0f) { minValue - }else{ - max(minValue,minCompareValue) + } else if (minValue != 0f && minCompareValue == 0f) { + minCompareValue + } else { + min(minValue, minCompareValue) } - return mix } - - } \ No newline at end of file diff --git a/health/src/main/java/com/zj365/health/vm/BloodFatCompareVm.kt b/health/src/main/java/com/zj365/health/vm/BloodFatCompareVm.kt index ac35d28..83691dc 100644 --- a/health/src/main/java/com/zj365/health/vm/BloodFatCompareVm.kt +++ b/health/src/main/java/com/zj365/health/vm/BloodFatCompareVm.kt @@ -8,7 +8,6 @@ import org.json.JSONObject class BloodFatCompareVm : BaseVm() { - // val avgLive by lazy { MutableLiveData>() } val dataLive by lazy { MutableLiveData>() } val setting by lazy { MutableLiveData>>() } diff --git a/health/src/main/java/com/zj365/health/vm/SkinMeasurementVm.kt b/health/src/main/java/com/zj365/health/vm/SkinMeasurementVm.kt index c87331b..8eeb671 100644 --- a/health/src/main/java/com/zj365/health/vm/SkinMeasurementVm.kt +++ b/health/src/main/java/com/zj365/health/vm/SkinMeasurementVm.kt @@ -12,34 +12,24 @@ class SkinMeasurementVm: BaseVm() { val payObservable by lazy { MutableLiveData>() } - val haveOrder by lazy { MutableLiveData>() } - fun getAIoods(){ + fun getAIGoods(){ startHttp { apiInterface().getTongueGoods() - var response = apiInterface().getTongueGoods() + var response = apiInterface().getAISugarMedicineGoods() response.getCodeStatus(payGoodsObservable, nowData) } } - //获取有无未完成订单 - fun aiHasNoFinishOrder() { - startHttp { - var json = JSONObject() - var response = - apiInterface().tongueHasNoFinishOrder(retrofits.getRequestBody(json.toString())) - response.getCodeStatus(haveOrder, nowData) - } - } //获取支付信息 - fun payTongueOrder(goodsId:String,isWeChatPay:Boolean){ + fun payAISugarMedicineOrder(goodsId:String,isWeChatPay:Boolean){ startHttp { var json = JSONObject() json.put("goodsId",goodsId) json.put("channelName", if (isWeChatPay) "WEIXIN_APP" else "ALIPAY_APP") - var response = apiInterface().payTongueOrder(retrofits.getRequestBody(json.toString())) + var response = apiInterface().payAISugarMedicineOrder(retrofits.getRequestBody(json.toString())) response.getCodeStatus(payObservable, nowData) } } diff --git a/health/src/main/res/layout/act_blood_lipid_adjust.xml b/health/src/main/res/layout/act_blood_lipid_adjust.xml index ed3adc8..8cc4581 100644 --- a/health/src/main/res/layout/act_blood_lipid_adjust.xml +++ b/health/src/main/res/layout/act_blood_lipid_adjust.xml @@ -9,10 +9,24 @@ android:id="@+id/title" layout="@layout/title_white_bar" /> + + - + + + + diff --git a/health/src/main/res/layout/act_health_week_month_hour_report.xml b/health/src/main/res/layout/act_health_week_month_hour_report.xml index 8b7a168..0c5eea1 100644 --- a/health/src/main/res/layout/act_health_week_month_hour_report.xml +++ b/health/src/main/res/layout/act_health_week_month_hour_report.xml @@ -711,7 +711,22 @@ - + + + + diff --git a/health/src/main/res/layout/custom_marker_view_xuezhi.xml b/health/src/main/res/layout/custom_marker_view_xuezhi.xml new file mode 100644 index 0000000..3dcf0d7 --- /dev/null +++ b/health/src/main/res/layout/custom_marker_view_xuezhi.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + diff --git a/health/src/main/res/layout/frag_blood_lipid_compare_data.xml b/health/src/main/res/layout/frag_blood_lipid_compare_data.xml index 8089e08..4ccf208 100644 --- a/health/src/main/res/layout/frag_blood_lipid_compare_data.xml +++ b/health/src/main/res/layout/frag_blood_lipid_compare_data.xml @@ -7,23 +7,26 @@ android:layout_height="match_parent" android:background="@color/col_6f7" android:orientation="vertical"> + + + android:orientation="vertical"> + + android:orientation="vertical"> + + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginHorizontal="@dimen/dp_16"> + + android:textColor="@color/col_313" + android:textSize="@dimen/sp_15" + tools:ignore="HardcodedText,UseCompatTextViewDrawableXml" /> - + tools:ignore="MissingConstraints,RtlHardcoded,UseCompatTextViewDrawableXml" + tools:text="2023-02-24 至 2023-02-24" /> + + android:layout_marginHorizontal="@dimen/dp_16" + android:background="@color/picture_color_f2" /> + android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/dp_16" + android:orientation="horizontal"> + + android:textColor="@color/col_313" + android:textSize="@dimen/sp_15" + tools:ignore="HardcodedText,UseCompatTextViewDrawableXml" /> + android:textSize="@dimen/sp_15" + tools:text="2023-02-24" + tools:ignore="RtlHardcoded,UseCompatTextViewDrawableXml" /> + + + android:layout_marginHorizontal="@dimen/dp_16" + android:background="@color/picture_color_f2" /> + + + layout="@layout/layout_blood_lipid_data_view" /> + layout="@layout/layout_blood_lipid_data_view" /> + layout="@layout/layout_blood_lipid_data_view" /> + layout="@layout/layout_blood_lipid_data_view" /> + + android:orientation="vertical"> + + tools:ignore="HardcodedText,UseCompatTextViewDrawableXml" /> + + android:textSize="@dimen/sp_13" + tools:text="对于多数人来说是正常的,不必过于担心。窦性心动过缓是指心率低于60次/分钟的人,是否会出现此症状,与其心跳过缓的频率和引起心跳过缓的原因有关。在安静状态下。长期从事体力劳动的人,一般人的心率若在40~50次/分钟之间。" /> - android:text="温馨提示:手表数据仅作为参考,不作为诊断、治疗依据。"/> + diff --git a/health/src/main/res/layout/frag_boold_fat.xml b/health/src/main/res/layout/frag_boold_fat.xml index 233e826..18bf980 100644 --- a/health/src/main/res/layout/frag_boold_fat.xml +++ b/health/src/main/res/layout/frag_boold_fat.xml @@ -29,19 +29,20 @@ android:id="@+id/compare_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/dp_16" + android:layout_marginStart="@dimen/dp_16" android:layout_marginTop="@dimen/dp_22" - android:layout_marginRight="@dimen/dp_12" + android:layout_marginEnd="@dimen/dp_12" android:layout_marginBottom="@dimen/dp_27" - android:drawableRight="@mipmap/arrow_right" + android:drawableEnd="@mipmap/arrow_right" android:drawablePadding="@dimen/dp_6" android:gravity="center_vertical" android:text="查看数据对比" android:textColor="@color/col_c7c" - android:textSize="@dimen/dp_13" + android:textSize="@dimen/sp_13" android:textStyle="bold" app:layout_constraintRight_toRightOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:ignore="HardcodedText,UseCompatTextViewDrawableXml" /> + app:layout_constraintTop_toTopOf="parent" + tools:ignore="HardcodedText,UseCompatTextViewDrawableXml" /> - - @@ -150,12 +147,15 @@ android:id="@+id/tv_renew" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/dp_9" - android:text="续费" - android:textColor="@color/col_02c" - android:textSize="@dimen/sp_12" + android:layout_gravity="center_vertical" + android:paddingStart="@dimen/dp_9" + android:text="立即续费" + android:textColor="@color/red_ff" + android:textSize="@dimen/sp_15" android:textStyle="bold" - android:visibility="gone" /> + android:visibility="gone" + tools:ignore="HardcodedText,RtlSymmetry" + tools:visibility="visible" /> @@ -164,12 +164,12 @@ android:layout_width="@dimen/dp_77" android:layout_height="@dimen/dp_31" android:layout_marginTop="@dimen/dp_12" - android:layout_marginBottom="@dimen/dp_18" android:background="@drawable/shape_r15_storke_25c" android:gravity="center" android:text="血脂校准" android:textColor="@color/col_02c" - android:textSize="@dimen/sp_13" /> + android:textSize="@dimen/sp_13" + tools:ignore="HardcodedText" /> @@ -232,7 +232,8 @@ android:visibility="invisible" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/ivPosition" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:ignore="HardcodedText" /> + app:layout_constraintTop_toTopOf="parent" + tools:ignore="HardcodedText" /> @@ -268,11 +270,12 @@ + android:textSize="@dimen/sp_15" + tools:ignore="HardcodedText" /> diff --git a/health/src/main/res/layout/item_blood_fat.xml b/health/src/main/res/layout/item_blood_fat.xml index 70574a4..fdddf37 100644 --- a/health/src/main/res/layout/item_blood_fat.xml +++ b/health/src/main/res/layout/item_blood_fat.xml @@ -1,8 +1,8 @@ + android:background="@mipmap/ic_bg_oval" + android:gravity="center"> + android:textStyle="bold" + tools:text="mmol/L 16:30" /> + + + android:text="总胆固醇(TC)" + android:textColor="@color/col_313" + android:textSize="@dimen/sp_16" /> + + android:layout_marginEnd="@dimen/dp_15" + android:background="@color/col_6f7" + android:visibility="gone" /> \ No newline at end of file diff --git a/health/src/main/res/layout/item_health_sign_data.xml b/health/src/main/res/layout/item_health_sign_data.xml new file mode 100644 index 0000000..dc07298 --- /dev/null +++ b/health/src/main/res/layout/item_health_sign_data.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/network/src/main/java/com/xty/network/ApiInterface.kt b/network/src/main/java/com/xty/network/ApiInterface.kt index a98b502..7e1e591 100644 --- a/network/src/main/java/com/xty/network/ApiInterface.kt +++ b/network/src/main/java/com/xty/network/ApiInterface.kt @@ -1559,6 +1559,18 @@ interface ApiInterface { @POST("customer/tongue/order/getTongueGoods") suspend fun getTongueGoods(): RespBody + /** + * AI 糖医 + */ + @POST("customer/sugarMedicine/getSugarMedicineGoods") + suspend fun getAISugarMedicineGoods():RespBody + + /** + * AI 糖医支付 + */ + @POST("pay/paySugarMedicineOrder") + suspend fun payAISugarMedicineOrder(@Body rb: RequestBody): RespBody + //上传信息 @POST("customer/tongue/order/updateOrder") suspend fun updateTongueOrder(@Body rb: RequestBody): RespBody @@ -1886,7 +1898,7 @@ interface ApiInterface { * 创建订单 */ @POST("customer/mall/order/createOrder") - suspend fun createOrder(@Body rb: RequestBody):RespBody + suspend fun createOrder(@Body rb: RequestBody):RespBody /** * 确认收货 diff --git a/network/src/main/java/com/xty/network/model/BloodFatBean.kt b/network/src/main/java/com/xty/network/model/BloodFatBean.kt index ca4fbcd..e50ff12 100644 --- a/network/src/main/java/com/xty/network/model/BloodFatBean.kt +++ b/network/src/main/java/com/xty/network/model/BloodFatBean.kt @@ -81,12 +81,16 @@ data class BloodFatBean( data class ModelCompare( var uaValue: Float, var time: String, - var formatTime: String = "" + var formatTime: String = "", + var index: Int = 0 ) @RequiresApi(Build.VERSION_CODES.O) fun mapDataToTime(dataList: MutableList): MutableList { + if (dataList.isEmpty()) { + return mutableListOf() + } val mappedData = mutableListOf() val dateFormat = SimpleDateFormat("HH:mm", Locale.getDefault()) // 创建一天的时间节点 @@ -164,6 +168,9 @@ data class BloodFatBean( dataList: MutableList, month: String ): MutableList { + if (dataList.isEmpty()) { + return mutableListOf() + } val filledDataList = mutableListOf() val dateFormat = SimpleDateFormat("MM-dd", Locale.getDefault()) @@ -213,6 +220,9 @@ data class BloodFatBean( startDate: String, endDate: String ): MutableList { + if (dataList.isEmpty()) { + return mutableListOf() + } val filledDataList = mutableListOf() val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) @@ -292,6 +302,9 @@ data class BloodFatBean( } fun fillMissingData(dataList: MutableList): MutableList { + if (dataList.isEmpty()) { + return mutableListOf() + } val filledDataList = mutableListOf() // 初始化日期范围 diff --git a/network/src/main/java/com/xty/network/model/BloodLipidDataBean.kt b/network/src/main/java/com/xty/network/model/BloodLipidDataBean.kt index e9107bb..8e93714 100644 --- a/network/src/main/java/com/xty/network/model/BloodLipidDataBean.kt +++ b/network/src/main/java/com/xty/network/model/BloodLipidDataBean.kt @@ -32,19 +32,19 @@ data class BloodLipidDataBean( val tcNormal:Int, val avgTg:Float, val avgTc:Float, - val tgNormal:Float, + val tgNormal:Int, val minTc:Float, val minTg:Float, - val hdlAbnormal:Float, + val hdlAbnormal:Int, val avgLdl:Float, - val hdlNormal:Float, + val hdlNormal:Int, val minLdl:Float, val maxTg:Float, - val ldlNormal:Float, - val ldlAbnormal:Float, + val ldlNormal:Int, + val ldlAbnormal:Int, val maxTc:Float, val maxLdl:Float, - val tgAbnormal:Float + val tgAbnormal:Int ) @@ -77,17 +77,17 @@ data class BloodLipidDataBean( var endTime = calendar.time // 如果是时间是今天,endTime为最近的时间 - /* val now = Calendar.getInstance() - val today = now.clone() as Calendar - now.timeInMillis = - if (dataList.isEmpty()) System.currentTimeMillis() else dataList.first().time.toLong() * 1000 - - if (today.get(Calendar.YEAR) == now.get(Calendar.YEAR) && - today.get(Calendar.DAY_OF_YEAR) == now.get(Calendar.DAY_OF_YEAR) - ) { - // If today, use the last time in the range - endTime = now.time - }*/ + /* val now = Calendar.getInstance() + val today = now.clone() as Calendar + now.timeInMillis = + if (dataList.isEmpty()) System.currentTimeMillis() else dataList.first().time.toLong() * 1000 + + if (today.get(Calendar.YEAR) == now.get(Calendar.YEAR) && + today.get(Calendar.DAY_OF_YEAR) == now.get(Calendar.DAY_OF_YEAR) + ) { + // If today, use the last time in the range + endTime = now.time + }*/ // 初始化时间节点和默认值 var currentTime = startTime diff --git a/network/src/main/java/com/xty/network/model/ReportBean.kt b/network/src/main/java/com/xty/network/model/ReportBean.kt index 274f0de..953bb06 100644 --- a/network/src/main/java/com/xty/network/model/ReportBean.kt +++ b/network/src/main/java/com/xty/network/model/ReportBean.kt @@ -5,7 +5,7 @@ import java.io.Serializable import java.text.SimpleDateFormat import java.util.Calendar -data class ReportBean ( +data class ReportBean( val adorn: Adorn,//佩戴信息 val status: String?, val star: String,//星级评分 @@ -18,66 +18,68 @@ data class ReportBean ( var healthTotal: List, //健康统计 var healthTrend: List, //健康趋势 var statistical: List? = null, //统计测量 - var signData:SingData,//基础信息 - var notifyMsg:String,//预警消息 - override var itemType: Int) - : MultiItemEntity, Serializable { - data class SingData ( - var temp:HrInfo,//体温 - var dbp:HrInfo,//血压 - var hr:HrInfo,//心率 - var so:HrInfo,//血氧 - var uricAcid:UricAcid,//尿酸 - var step:HrInfo,//步数 - var stepData:HrInfo,//步数 - var respiratory:HrInfo,//呼吸率 - var bloodSugar:HrInfo,//血糖 - var sleep:HrInfo,//睡眠 - var bloodFat:BloodFatInfo //血脂 - ): Serializable - - data class UricAcid(val min: String,val max:String,val avg:String,val count: String):Serializable + var signData: SingData,//基础信息 + var notifyMsg: String,//预警消息 + override var itemType: Int +) : MultiItemEntity, Serializable { + data class SingData( + var temp: HrInfo,//体温 + var dbp: HrInfo,//血压 + var hr: HrInfo,//心率 + var so: HrInfo,//血氧 + var uricAcid: UricAcid,//尿酸 + var step: HrInfo,//步数 + var stepData: HrInfo,//步数 + var respiratory: HrInfo,//呼吸率 + var bloodSugar: HrInfo,//血糖 + var sleep: HrInfo,//睡眠 + var bloodFat: BloodFatInfo //血脂 + ) : Serializable + + data class UricAcid( + val min: String, + val max: String, + val avg: String, + val count: String + ) : Serializable data class HrInfo( - var name:String, //名字 - var avg:String, //平均 - var min:String,//最小 - var max:String,//最大 - var count:String,//次数 - var step:String,//步数 - var srcId:Int,//图片ID - var avgLight:String? = null,//平均浅睡 - var maxTime:String?= null,//最大睡眠时间 - var avgTime:String?=null,//平均睡眠时间 - var minTime:String?=null,//最少睡眠时间 - var avgDeep:String?=null,//平均深睡 - var sleepDuration:Int?=null//(周,月,年,近7天,近30天)睡眠时长 - - ): Serializable + var name: String, //名字 + var avg: String, //平均 + var min: String,//最小 + var max: String,//最大 + var count: String,//次数 + var step: String,//步数 + var srcId: Int,//图片ID + var avgLight: String? = null,//平均浅睡 + var maxTime: String? = null,//最大睡眠时间 + var avgTime: String? = null,//平均睡眠时间 + var minTime: String? = null,//最少睡眠时间 + var avgDeep: String? = null,//平均深睡 + var sleepDuration: Int? = null//(周,月,年,近7天,近30天)睡眠时长 + ) : Serializable data class BloodFatInfo( - val ldlMin:Float, - val ldlAvg:Float, - val tgMax:Float, - val tcMax:Float, - val count:Int, - val hdlMin:Float, - val hdlAvg:Float, - val tgMin:Float, - - val tgAvg:String, - val ldlMax:Float, - val tcMin:Float, - - val tcAvg:Float, - val hdlMax:Float - - ):Serializable + val ldlMin: Float, + val ldlAvg: String, + val tgMax: Float, + val tcMax: Float, + val count: Int, + val hdlMin: Float, + val hdlAvg: String, + val tgMin: Float, + val tgAvg: String, + val ldlMax: Float, + val tcMin: Float, + val tcAvg: String, + val hdlMax: Float + + ) : Serializable data class totalBean( - var result : Int, - var count : Int, - ):Serializable + var result: Int, + var count: Int, + ) : Serializable data class Organ( var kidney: OrganChild,//肾脏 @@ -90,9 +92,9 @@ data class ReportBean ( var cholecystListData: List, var liver: OrganChild, //肝脏 var liverListData: List, - var spleen:OrganChild,//脾脏 + var spleen: OrganChild,//脾脏 var spleenListData: List, - var largeIntestine:OrganChild, //大肠 + var largeIntestine: OrganChild, //大肠 var largeIntestineListData: List, var bladder: OrganChild, //膀胱 var bladderListData: List, @@ -104,12 +106,12 @@ data class ReportBean ( var smallIntestineListData: List, var heart: OrganChild, //心脏 var heartListData: List, - ): Serializable + ) : Serializable data class OrganChild( - var model:ChildStatus, - var value:List, - ): Serializable + var model: ChildStatus, + var value: List, + ) : Serializable data class Analysis( var sleep: List? = null, //睡眠方案建议 @@ -120,20 +122,21 @@ data class ReportBean ( var exercise: List? = null,//运动指导 var tcm: List? = null,//中医养生指导 var diet: List? = null,//饮食指导 - ): Serializable - - data class Healthy( - var healthyId:String, - var userId:String, - var createTime:String, - var result:Int,// -1 建模中 0数据不足 1健康 2亚健康 3疾病 - ): Serializable + ) : Serializable + + data class Healthy( + var healthyId: String, + var userId: String, + var createTime: String, + var result: Int,// -1 建模中 0数据不足 1健康 2亚健康 3疾病 + ) : Serializable + data class Content( var name: String, var dictName: String, var content: String - ): Serializable + ) : Serializable data class Analyse( val sleep: String, @@ -144,14 +147,20 @@ data class ReportBean ( val so: String, val respiratory: String, val status: String,//-1 建模中 0数据不足 1健康 2亚健康 3疾病 - val hr: String - ): Serializable + val hr: String, + val bloodsugar: String, + val uricAcid: String,//尿酸 + val tc: String,//总胆固醇 + val tg: String,//甘油三酯 + val hdl: String,//高密度脂蛋白 + val ldl: String//低密度脂蛋白 + ) : Serializable data class Adorn( val activeWear: Int, val dormancy: Int, val wearCount: Int - ): Serializable + ) : Serializable data class User( val actCity: Any, @@ -207,12 +216,14 @@ data class ReportBean ( var historyName: String, var tumour: String, var diseaseList: MutableList - ): Serializable + ) : Serializable + data class Operation( - var name:String, - var time:String, - var type:Int - ): Serializable + var name: String, + var time: String, + var type: Int + ) : Serializable + data class StatisTical( var start_time: Long, var min: Int, @@ -221,7 +232,7 @@ data class ReportBean ( var minStartTime: Long, var count: Int, var validCount: Int, - ): Serializable + ) : Serializable data class ChildStatus( var id: Int, @@ -230,8 +241,8 @@ data class ReportBean ( var sumNoEnough: Int,//-1,建模中,>=0,完成了经络分析 var userId: Int, var createTime: String, - ): Serializable{ - constructor():this(0,0 ,0 ,0,0,"") + ) : Serializable { + constructor() : this(0, 0, 0, 0, 0, "") } //演示模式逻辑 diff --git a/network/src/main/java/com/xty/network/model/ShopGoodsOrderBean.kt b/network/src/main/java/com/xty/network/model/ShopGoodsOrderBean.kt new file mode 100644 index 0000000..09391b7 --- /dev/null +++ b/network/src/main/java/com/xty/network/model/ShopGoodsOrderBean.kt @@ -0,0 +1,7 @@ +package com.xty.network.model + +data class ShopGoodsOrderBean( + var order_no:String, + var pay_price:Double +) { +} \ No newline at end of file