HistoryBrowser improvement
This commit is contained in:
parent
24bcc4ecfe
commit
0a66ed307a
1 changed files with 18 additions and 9 deletions
|
@ -93,11 +93,11 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
overviewData = OverviewData(injector, aapsLogger, resourceHelper, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, config, loopPlugin, nsDeviceStatus, repository, overviewMenus, iobCobCalculator, translator)
|
overviewData = OverviewData(injector, aapsLogger, resourceHelper, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, config, loopPlugin, nsDeviceStatus, repository, overviewMenus, iobCobCalculator, translator)
|
||||||
|
|
||||||
binding.left.setOnClickListener {
|
binding.left.setOnClickListener {
|
||||||
setTime(overviewData.fromTime - T.hours(rangeToDisplay.toLong()).msecs())
|
adjustTimeRange(overviewData.fromTime - T.hours(rangeToDisplay.toLong()).msecs())
|
||||||
loadAll("onClickLeft")
|
loadAll("onClickLeft")
|
||||||
}
|
}
|
||||||
binding.right.setOnClickListener {
|
binding.right.setOnClickListener {
|
||||||
setTime(overviewData.fromTime + T.hours(rangeToDisplay.toLong()).msecs())
|
adjustTimeRange(overviewData.fromTime + T.hours(rangeToDisplay.toLong()).msecs())
|
||||||
loadAll("onClickRight")
|
loadAll("onClickRight")
|
||||||
}
|
}
|
||||||
binding.end.setOnClickListener {
|
binding.end.setOnClickListener {
|
||||||
|
@ -266,6 +266,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
@Suppress("SameParameterValue")
|
@Suppress("SameParameterValue")
|
||||||
private fun loadAll(from: String) {
|
private fun loadAll(from: String) {
|
||||||
|
updateDate()
|
||||||
Thread {
|
Thread {
|
||||||
overviewData.prepareBasalData(from)
|
overviewData.prepareBasalData(from)
|
||||||
overviewData.prepareTemporaryTargetData(from)
|
overviewData.prepareTemporaryTargetData(from)
|
||||||
|
@ -277,17 +278,21 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTime(start: Long) {
|
private fun setTime(start: Long) {
|
||||||
Calendar.getInstance().also { calendar ->
|
GregorianCalendar().also { calendar ->
|
||||||
calendar.timeInMillis = start
|
calendar.timeInMillis = start
|
||||||
calendar[Calendar.MILLISECOND] = 0
|
calendar[Calendar.MILLISECOND] = 0
|
||||||
calendar[Calendar.SECOND] = 0
|
calendar[Calendar.SECOND] = 0
|
||||||
calendar[Calendar.MINUTE] = 0
|
calendar[Calendar.MINUTE] = 0
|
||||||
calendar[Calendar.HOUR_OF_DAY] = 0
|
calendar[Calendar.HOUR_OF_DAY] -= (calendar[Calendar.HOUR_OF_DAY] % rangeToDisplay)
|
||||||
overviewData.fromTime = calendar.timeInMillis
|
adjustTimeRange(calendar.timeInMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun adjustTimeRange(start: Long) {
|
||||||
|
overviewData.fromTime = start
|
||||||
overviewData.toTime = overviewData.fromTime + T.hours(rangeToDisplay.toLong()).msecs()
|
overviewData.toTime = overviewData.fromTime + T.hours(rangeToDisplay.toLong()).msecs()
|
||||||
overviewData.endTime = overviewData.toTime
|
overviewData.endTime = overviewData.toTime
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun runCalculation(from: String) {
|
private fun runCalculation(from: String) {
|
||||||
Thread {
|
Thread {
|
||||||
|
@ -308,13 +313,17 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
runningRefresh = false
|
runningRefresh = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateDate() {
|
||||||
|
binding.date.text = dateUtil.dateAndTimeString(overviewData.fromTime)
|
||||||
|
binding.zoom.text = rangeToDisplay.toString()
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
fun updateGUI(from: String) {
|
fun updateGUI(from: String) {
|
||||||
aapsLogger.debug(LTag.UI, "updateGui $from")
|
aapsLogger.debug(LTag.UI, "updateGui $from")
|
||||||
|
|
||||||
binding.date.text = dateUtil.dateAndTimeString(overviewData.fromTime)
|
updateDate()
|
||||||
binding.zoom.text = rangeToDisplay.toString()
|
|
||||||
|
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
val graphData = GraphData(injector, binding.bgGraph, overviewData)
|
val graphData = GraphData(injector, binding.bgGraph, overviewData)
|
||||||
|
|
Loading…
Reference in a new issue