1
0
mirror of https://github.com/dzeiocom/OpenHealth.git synced 2025-06-12 17:19:18 +00:00

feat(charts): Moved to modules based charts

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
2022-07-28 10:01:52 +02:00
parent c2bc9eced2
commit f6b5715572
9 changed files with 409 additions and 46 deletions

View File

@ -1,13 +1,13 @@
package com.dzeio.openhealth.ui.steps
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.widget.NestedScrollView
import androidx.recyclerview.widget.LinearLayoutManager
import com.dzeio.charts.Entry
import com.dzeio.charts.series.BarSerie
import com.dzeio.openhealth.Application
import com.dzeio.openhealth.R
import com.dzeio.openhealth.adapters.StepsAdapter
@ -52,10 +52,17 @@ class StepsHomeFragment :
val chart = binding.chart
val serie = BarSerie()
chart.series = arrayListOf(serie)
viewModel.items.observe(viewLifecycleOwner) { list ->
adapter.set(list)
chart.xAxis.entriesDisplayed = 30
chart.numberOfLabels = 2
chart.debug = true
chart.xAxis.entriesDisplayed = 10
// chart.numberOfLabels = 2
// chart.animation.enabled = false
chart.animation.refreshRate = 60
@ -71,7 +78,7 @@ class StepsHomeFragment :
com.google.android.material.R.attr.colorPrimary
)
chart.list = list.reversed().map {
serie.datas = list.reversed().map {
return@map Entry(it.timestamp.toDouble(), it.value.toFloat())
} as ArrayList<Entry>
@ -88,21 +95,5 @@ class StepsHomeFragment :
chart.refresh()
}
val scrollView = requireActivity().findViewById<NestedScrollView>(R.id.scrollView)
var scrollEnabled = false
scrollView.setOnTouchListener { view, _ ->
view.performClick()
if (scrollEnabled) {
} else {
return@setOnTouchListener !scrollEnabled
}
return@setOnTouchListener true
}
binding.chart.setOnToggleScroll {
Log.d(TAG, it.toString())
scrollEnabled = it
}
}
}

View File

@ -22,7 +22,7 @@
android:orientation="vertical">
<view
class="com.dzeio.charts.views.BarChartView"
class="com.dzeio.charts.ChartView"
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="200dp"