|
|
|
@ -83,7 +83,7 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
private var isPermission = false
|
|
|
|
|
private var isCompleteInfo = false
|
|
|
|
|
private var expireTimeStr: String = ""
|
|
|
|
|
var type = 2
|
|
|
|
|
var type = 1
|
|
|
|
|
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 {
|
|
|
|
@ -345,7 +345,7 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
//尿酸头部信息,这里有判断是否绑定了尿酸设备
|
|
|
|
|
mViewModel.getUricAcidHead(id)
|
|
|
|
|
}
|
|
|
|
|
mViewModel.getUricAcidInfo(type, binding.tvShowDate.text.toString(), id, isDemonstrate)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun moveToErrorShow(bundle: Bundle) {
|
|
|
|
@ -510,9 +510,14 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
calendar.time = format.parse(data.time!!)!!
|
|
|
|
|
val myFormat = SimpleDateFormat("yyyy-MM-dd HH:mm")
|
|
|
|
|
|
|
|
|
|
binding.tvTestTime.text = myFormat.format(calendar.time)
|
|
|
|
|
val dateForm = SimpleDateFormat("yyyy-MM-dd")
|
|
|
|
|
|
|
|
|
|
binding.tvTestTime.text = myFormat.format(calendar.time)
|
|
|
|
|
dayDate = dateForm.format(calendar.time)
|
|
|
|
|
binding.tvShowDate.text = dayDate
|
|
|
|
|
mViewModel.getCurrentUricAcidValue(data.timeDay, id, isDemonstrate)
|
|
|
|
|
|
|
|
|
|
mViewModel.getUricAcidInfo(type, binding.tvShowDate.text.toString(), id, isDemonstrate)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -527,6 +532,11 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
|
when (type) {
|
|
|
|
|
|
|
|
|
|
1->{
|
|
|
|
|
it[type]!!.model = it[type]!!.mapDataToTimeNodes(it[type]!!.model)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
2 -> {//周
|
|
|
|
|
val split = binding.tvShowDate.text.toString().split("至")
|
|
|
|
|
val start = split[0]
|
|
|
|
@ -725,7 +735,11 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
val y = it.axisLeft
|
|
|
|
|
// y.axisMaximum=max
|
|
|
|
|
// y.axisMinimum=min
|
|
|
|
|
y.setLabelCountAndMaxMinValue(6, false, min - 10f, max + 10f)
|
|
|
|
|
y.setLabelCountAndMaxMinValue(
|
|
|
|
|
6,
|
|
|
|
|
false,
|
|
|
|
|
if (min - 1f > 0f) min - 1f else min,
|
|
|
|
|
if (max >= 0f) max + 1f else max)
|
|
|
|
|
y.textColor = ContextCompat.getColor(requireContext(), R.color.col_92a)
|
|
|
|
|
y.setDrawAxisLine(false)
|
|
|
|
|
y.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART)
|
|
|
|
@ -750,14 +764,15 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
|
|
|
|
|
val barsetsNew: java.util.ArrayList<ILineDataSet> = java.util.ArrayList()
|
|
|
|
|
var segments = splitDataIntoSegments(list)
|
|
|
|
|
if (segments.size > 0) {
|
|
|
|
|
segments = checkData(segments)
|
|
|
|
|
}
|
|
|
|
|
// if (segments.size > 0) {
|
|
|
|
|
// segments = checkData(segments)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
val dataSets = segments.mapNotNull { segment ->
|
|
|
|
|
if (segment.isEmpty()) return@mapNotNull null
|
|
|
|
|
|
|
|
|
|
val entries = segment.mapIndexed { index, model ->
|
|
|
|
|
|
|
|
|
|
Entry(
|
|
|
|
|
convertTimeToIndex(model.time, index).toFloat(),
|
|
|
|
|
model.uaValue,
|
|
|
|
@ -798,7 +813,7 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
m.postScale(
|
|
|
|
|
when (type) {
|
|
|
|
|
1 -> {
|
|
|
|
|
11.5f
|
|
|
|
|
0.5f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
3 -> {
|
|
|
|
@ -836,7 +851,8 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val y = it.axisLeft
|
|
|
|
|
y.setLabelCountAndMaxMinValue(6, false, min - 10, max + 10)
|
|
|
|
|
y.setLabelCountAndMaxMinValue(6, false, if (min - 1f > 0f) min - 1f else min,
|
|
|
|
|
if (max >= 0f) max + 1f else max)
|
|
|
|
|
y.textColor = ContextCompat.getColor(requireContext(), R.color.col_92a)
|
|
|
|
|
y.setDrawAxisLine(false)
|
|
|
|
|
y.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART)
|
|
|
|
@ -880,7 +896,12 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val bard = BarData(dataBarSets)
|
|
|
|
|
bard.barWidth = calculateBarWidth(bard.dataSetCount)
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
bard.barWidth = calculateBarWidth(bard.dataSetCount) / 4
|
|
|
|
|
} else {
|
|
|
|
|
bard.barWidth = calculateBarWidth(bard.dataSetCount)
|
|
|
|
|
}
|
|
|
|
|
// bard.barWidth = calculateBarWidth(bard.dataSetCount)
|
|
|
|
|
binding.mBarChart.data = bard
|
|
|
|
|
binding.mBarChart.invalidate()
|
|
|
|
|
}
|
|
|
|
@ -922,16 +943,17 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
var currentSegment = mutableListOf<UricAcidInfoBean.Model>()
|
|
|
|
|
|
|
|
|
|
for (model in dataList) {
|
|
|
|
|
if (model.uaValue.toFloat().isNaN()) {
|
|
|
|
|
// 遇到 Float.NaN,如果当前线段不为空,则添加到结果中,并开始新的线段
|
|
|
|
|
if (currentSegment.isNotEmpty()) {
|
|
|
|
|
segments.add(currentSegment)
|
|
|
|
|
currentSegment = mutableListOf()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 遇到有效数据,将其添加到当前线段中
|
|
|
|
|
currentSegment.add(model)
|
|
|
|
|
}
|
|
|
|
|
// if (model.uaValue.toFloat().isNaN()) {
|
|
|
|
|
// // 遇到 Float.NaN,如果当前线段不为空,则添加到结果中,并开始新的线段
|
|
|
|
|
// if (currentSegment.isNotEmpty()) {
|
|
|
|
|
// segments.add(currentSegment)
|
|
|
|
|
// currentSegment = mutableListOf()
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // 遇到有效数据,将其添加到当前线段中
|
|
|
|
|
// currentSegment.add(model)
|
|
|
|
|
// }
|
|
|
|
|
currentSegment.add(model)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将最后一个线段添加到结果中
|
|
|
|
@ -1060,10 +1082,10 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
val minutes = parts[1].toInt()
|
|
|
|
|
|
|
|
|
|
// 计算对应的分钟数
|
|
|
|
|
val totalMinutes = hours * 60 + minutes
|
|
|
|
|
val totalMinutes = hours * 60
|
|
|
|
|
|
|
|
|
|
// 计算对应的索引值
|
|
|
|
|
index = totalMinutes / 10
|
|
|
|
|
index = hours - 5
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
2 -> {
|
|
|
|
@ -1180,13 +1202,14 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
private val mTabEntities: ArrayList<CustomTabEntity> = ArrayList()
|
|
|
|
|
private val mFragments: SparseArray<Fragment> = SparseArray()
|
|
|
|
|
private val mTitles = arrayOf(
|
|
|
|
|
"周", "月", "年"
|
|
|
|
|
"日", "周", "月", "年"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
private fun initTab() {
|
|
|
|
|
|
|
|
|
|
val currentDay = Date()
|
|
|
|
|
val day = TimeUtils.date2String(currentDay, "yyyy-MM-dd")
|
|
|
|
|
dayDate = day
|
|
|
|
|
weekDate = "${TimeUtils.date2String(getDateAdd(6), "yyyy-MM-dd")}至$day"
|
|
|
|
|
mouthDate = TimeUtils.date2String(currentDay, "yyyy-MM")
|
|
|
|
|
yearDate = TimeUtils.date2String(currentDay, "yyyy")
|
|
|
|
@ -1206,17 +1229,21 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
binding.commonTabLayout.currentTab = position
|
|
|
|
|
|
|
|
|
|
when (position) {
|
|
|
|
|
0 -> { //周
|
|
|
|
|
0->{
|
|
|
|
|
binding.tvShowDate.text = dayDate
|
|
|
|
|
type = 1
|
|
|
|
|
}
|
|
|
|
|
1 -> { //周
|
|
|
|
|
binding.tvShowDate.text = weekDate
|
|
|
|
|
type = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
1 -> { //月
|
|
|
|
|
2 -> { //月
|
|
|
|
|
binding.tvShowDate.text = mouthDate
|
|
|
|
|
type = 3
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
2 -> { //年
|
|
|
|
|
3 -> { //年
|
|
|
|
|
binding.tvShowDate.text = yearDate
|
|
|
|
|
type = 4
|
|
|
|
|
}
|
|
|
|
@ -1237,14 +1264,28 @@ class UricAcidFrag : BaseVmFrag<UricAcidVm>() {
|
|
|
|
|
|
|
|
|
|
private fun initTimeSelect() {
|
|
|
|
|
|
|
|
|
|
val currentDay = Date()
|
|
|
|
|
val day = TimeUtils.date2String(currentDay, "yyyy-MM-dd")
|
|
|
|
|
weekDate = "${TimeUtils.date2String(getDateAdd(6), "yyyy-MM-dd")}至$day"
|
|
|
|
|
binding.tvShowDate.text = weekDate
|
|
|
|
|
// val currentDay = Date()
|
|
|
|
|
// val day = TimeUtils.date2String(currentDay, "yyyy-MM-dd")
|
|
|
|
|
// weekDate = "${TimeUtils.date2String(getDateAdd(6), "yyyy-MM-dd")}至$day"
|
|
|
|
|
// binding.tvShowDate.text = weekDate
|
|
|
|
|
|
|
|
|
|
//日筛选
|
|
|
|
|
val calendar = Calendar.getInstance()
|
|
|
|
|
timeSelect.startDate.set(1922, 1, 1)
|
|
|
|
|
timeSelect.endDate.set(
|
|
|
|
|
calendar[Calendar.YEAR], calendar[Calendar.MONTH], if (calendar[Calendar.HOUR] >= 11) {
|
|
|
|
|
calendar[Calendar.DATE]
|
|
|
|
|
} else {
|
|
|
|
|
calendar[Calendar.DATE]
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
binding.tvShowDate.text = RxTimeTool.getCurTimeString(SimpleDateFormat("yyyy-MM-dd"))
|
|
|
|
|
|
|
|
|
|
binding.tvShowDate.setOnClickListener {
|
|
|
|
|
when (type) {
|
|
|
|
|
|
|
|
|
|
0,1->{
|
|
|
|
|
timeSelect.selectTime(it, "yyyy-MM-dd")
|
|
|
|
|
}
|
|
|
|
|
2 -> {
|
|
|
|
|
bottomSheetDialog?.show()
|
|
|
|
|
}
|
|
|
|
|