mirror of
https://github.com/dzeiocom/OpenHealth.git
synced 2025-06-12 17:19:18 +00:00
fix: Value higher than max being slow
WIP: Better scrolling
This commit is contained in:
@ -1,11 +1,15 @@
|
||||
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.openhealth.Application
|
||||
import com.dzeio.openhealth.R
|
||||
import com.dzeio.openhealth.adapters.StepsAdapter
|
||||
import com.dzeio.openhealth.core.BaseFragment
|
||||
import com.dzeio.openhealth.databinding.FragmentStepsHomeBinding
|
||||
@ -19,6 +23,10 @@ import java.util.Locale
|
||||
class StepsHomeFragment :
|
||||
BaseFragment<StepsHomeViewModel, FragmentStepsHomeBinding>(StepsHomeViewModel::class.java) {
|
||||
|
||||
companion object {
|
||||
const val TAG = "${Application.TAG}/SHFragment"
|
||||
}
|
||||
|
||||
override val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> FragmentStepsHomeBinding =
|
||||
FragmentStepsHomeBinding::inflate
|
||||
|
||||
@ -46,7 +54,7 @@ class StepsHomeFragment :
|
||||
|
||||
viewModel.items.observe(viewLifecycleOwner) { list ->
|
||||
adapter.set(list)
|
||||
// chart.numberOfEntries = list.size / 2
|
||||
chart.xAxis.entriesDisplayed = 30
|
||||
chart.numberOfLabels = 2
|
||||
|
||||
// chart.animation.enabled = false
|
||||
@ -80,5 +88,21 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/scrollView"
|
||||
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
|
Reference in New Issue
Block a user