Show progress bar on computation

This commit is contained in:
Milos Kozak 2022-03-29 21:18:20 +02:00
parent 6b01c933a7
commit 3f7b7e0d21
9 changed files with 23 additions and 19 deletions

View file

@ -242,7 +242,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
.observeOn(aapsSchedulers.main)
.subscribe({
if (it.cause is EventCustomCalculationFinished)
binding.overviewIobcalculationprogess.text = it.progress
binding.overviewIobcalculationprogess.text = it.progressPct.toString() + "%"
}, fabricPrivacy::logException)
disposable += rxBus
.toObservable(EventRefreshOverview::class.java)

View file

@ -63,7 +63,7 @@ class OverviewData @Inject constructor(
fun reset() {
pumpStatus = ""
calcProgress = ""
calcProgressPct = 100
lastBg = null
bolusIob = null
basalIob = null
@ -121,7 +121,7 @@ class OverviewData @Inject constructor(
* CALC PROGRESS
*/
var calcProgress: String = ""
var calcProgressPct: Int = 100
/*
* BG

View file

@ -1029,7 +1029,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
@Suppress("UNUSED_PARAMETER")
fun updateCalcProgress(from: String) {
binding.graphsLayout.iobCalculationProgress.text = overviewData.calcProgress
binding.progressBar.progress = overviewData.calcProgressPct
binding.progressBar.visibility = (overviewData.calcProgressPct != 100).toVisibility()
}
@Suppress("UNUSED_PARAMETER")

View file

@ -89,7 +89,7 @@ class OverviewPlugin @Inject constructor(
disposable += rxBus
.toObservable(EventIobCalculationProgress::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ overviewData.calcProgress = it.progress; overviewBus.send(EventUpdateOverviewCalcProgress("EventIobCalculationProgress")) }, fabricPrivacy::logException)
.subscribe({ overviewData.calcProgressPct = it.progressPct; overviewBus.send(EventUpdateOverviewCalcProgress("EventIobCalculationProgress")) }, fabricPrivacy::logException)
disposable += rxBus
.toObservable(EventTempBasalChange::class.java)
.observeOn(aapsSchedulers.io)

View file

@ -109,7 +109,7 @@ class IobCobOref1Worker(
// start from oldest to be able sub cob
for (i in bucketedData.size - 4 downTo 0) {
val progress = i.toString() + if (buildHelper.isDev()) " (${data.from})" else ""
rxBus.send(EventIobCalculationProgress(progress, data.cause))
rxBus.send(EventIobCalculationProgress(100 - (100.0 * i / bucketedData.size).toInt(), data.cause))
if (isStopped) {
aapsLogger.debug(LTag.AUTOSENS, "Aborting calculation thread (trigger): ${data.from}")
return Result.failure(workDataOf("Error" to "Aborting calculation thread (trigger): ${data.from}"))
@ -338,7 +338,7 @@ class IobCobOref1Worker(
rxBus.send(EventAutosensCalculationFinished(data.cause))
}.start()
} finally {
rxBus.send(EventIobCalculationProgress("", data.cause))
rxBus.send(EventIobCalculationProgress(100, data.cause))
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA thread ended: ${data.from}")
profiler.log(LTag.AUTOSENS, "IobCobOref1Thread", start)
}

View file

@ -105,7 +105,7 @@ class IobCobOrefWorker @Inject internal constructor(
// start from oldest to be able sub cob
for (i in bucketedData.size - 4 downTo 0) {
val progress = i.toString() + if (buildHelper.isDev()) " (${data.from})" else ""
rxBus.send(EventIobCalculationProgress(progress, data.cause))
rxBus.send(EventIobCalculationProgress(100 - (100.0 * i / bucketedData.size).toInt(), data.cause))
if (isStopped) {
aapsLogger.debug(LTag.AUTOSENS, "Aborting calculation thread (trigger): ${data.from}")
return Result.failure(workDataOf("Error" to "Aborting calculation thread (trigger): ${data.from}"))
@ -282,7 +282,7 @@ class IobCobOrefWorker @Inject internal constructor(
rxBus.send(EventAutosensCalculationFinished(data.cause))
}.start()
} finally {
rxBus.send(EventIobCalculationProgress("", data.cause))
rxBus.send(EventIobCalculationProgress(100, data.cause))
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA thread ended: ${data.from}")
profiler.log(LTag.AUTOSENS, "IobCobThread", start)
}

View file

@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.iob.iobCobCalculator.events
import info.nightscout.androidaps.events.Event
class EventIobCalculationProgress(val progress: String, val cause: Event?) : Event()
class EventIobCalculationProgress(val progressPct: Int, val cause: Event?) : Event()

View file

@ -144,6 +144,17 @@
</LinearLayout>
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:indeterminate="false"
android:max="100"
android:progress="100" />
<include
android:id="@+id/buttons_layout"
layout="@layout/overview_buttons_layout" />

View file

@ -15,7 +15,7 @@
android:id="@+id/bg_graph"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:contentDescription="@string/a11y_graph"/>
android:contentDescription="@string/a11y_graph" />
<ImageButton
android:id="@+id/chart_menu_button"
@ -27,14 +27,6 @@
android:paddingTop="5dp"
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
<TextView
android:id="@+id/iob_calculation_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
tools:ignore="RelativeOverlap" />
</RelativeLayout>
<LinearLayout