fix progress bar #2
This commit is contained in:
parent
7da84536eb
commit
14a329d178
7 changed files with 24 additions and 17 deletions
|
@ -367,7 +367,7 @@ class HistoryBrowseActivity : DaggerAppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun updateCalcProgress(percent: Int) {
|
||||
binding.progressBar.progress = percent
|
||||
binding.progressBar.visibility = (percent != 100).toVisibilityKeepSpace()
|
||||
binding.progressBar.progress = percent
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.core.utils.worker.then
|
|||
import info.nightscout.core.workflow.CalculationWorkflow
|
||||
import info.nightscout.core.workflow.CalculationWorkflow.Companion.JOB
|
||||
import info.nightscout.core.workflow.CalculationWorkflow.Companion.MAIN_CALCULATION
|
||||
import info.nightscout.core.workflow.CalculationWorkflow.Companion.PASS
|
||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
|
@ -157,7 +158,7 @@ class CalculationWorkflowImpl @Inject constructor(
|
|||
)
|
||||
.then(
|
||||
OneTimeWorkRequest.Builder(UpdateGraphWorker::class.java)
|
||||
.setInputData(Data.Builder().putString(JOB, job).build())
|
||||
.setInputData(Data.Builder().putString(JOB, job).putInt(PASS, CalculationWorkflow.ProgressData.DRAW_BG.pass).build())
|
||||
.build()
|
||||
)
|
||||
.then(
|
||||
|
@ -177,7 +178,7 @@ class CalculationWorkflowImpl @Inject constructor(
|
|||
)
|
||||
.then(
|
||||
OneTimeWorkRequest.Builder(UpdateGraphWorker::class.java)
|
||||
.setInputData(Data.Builder().putString(JOB, job).build())
|
||||
.setInputData(Data.Builder().putString(JOB, job).putInt(PASS, CalculationWorkflow.ProgressData.DRAW_TT.pass).build())
|
||||
.build()
|
||||
)
|
||||
.then(
|
||||
|
@ -197,8 +198,9 @@ class CalculationWorkflowImpl @Inject constructor(
|
|||
.build()
|
||||
)
|
||||
.then(
|
||||
job == MAIN_CALCULATION,
|
||||
OneTimeWorkRequest.Builder(UpdateGraphWorker::class.java)
|
||||
.setInputData(Data.Builder().putString(JOB, job).build())
|
||||
.setInputData(Data.Builder().putString(JOB, job).putInt(PASS, CalculationWorkflow.ProgressData.DRAW_IOB.pass).build())
|
||||
.build()
|
||||
)
|
||||
.then(
|
||||
|
@ -214,9 +216,8 @@ class CalculationWorkflowImpl @Inject constructor(
|
|||
.build()
|
||||
)
|
||||
.then(
|
||||
job == MAIN_CALCULATION,
|
||||
OneTimeWorkRequest.Builder(UpdateGraphWorker::class.java)
|
||||
.setInputData(Data.Builder().putString(JOB, job).build())
|
||||
.setInputData(Data.Builder().putString(JOB, job).putInt(PASS, CalculationWorkflow.ProgressData.DRAW_FINAL.pass).build())
|
||||
.build()
|
||||
)
|
||||
.enqueue()
|
||||
|
|
|
@ -10,15 +10,19 @@ interface CalculationWorkflow {
|
|||
const val MAIN_CALCULATION = "calculation"
|
||||
const val HISTORY_CALCULATION = "history_calculation"
|
||||
const val JOB = "job"
|
||||
const val PASS = "pass"
|
||||
}
|
||||
|
||||
enum class ProgressData(private val pass: Int, val percentOfTotal: Int) {
|
||||
PREPARE_BASAL_DATA(0, 5),
|
||||
PREPARE_TEMPORARY_TARGET_DATA(1, 5),
|
||||
PREPARE_TREATMENTS_DATA(2, 5),
|
||||
IOB_COB_OREF(3, 74),
|
||||
PREPARE_IOB_AUTOSENS_DATA(4, 10),
|
||||
DRAW(5, 1);
|
||||
enum class ProgressData(val pass: Int, val percentOfTotal: Int) {
|
||||
DRAW_BG(0, 1),
|
||||
PREPARE_TREATMENTS_DATA(1, 2),
|
||||
PREPARE_BASAL_DATA(2, 6),
|
||||
PREPARE_TEMPORARY_TARGET_DATA(3, 6),
|
||||
DRAW_TT(4, 1),
|
||||
IOB_COB_OREF(5, 77),
|
||||
PREPARE_IOB_AUTOSENS_DATA(6, 5),
|
||||
DRAW_IOB(7, 1),
|
||||
DRAW_FINAL(8, 1);
|
||||
|
||||
fun finalPercent(progress: Int): Int {
|
||||
var total = 0
|
||||
|
|
|
@ -1085,8 +1085,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
private fun updateCalcProgress() {
|
||||
_binding ?: return
|
||||
binding.progressBar.progress = overviewData.calcProgressPct
|
||||
binding.progressBar.visibility = (overviewData.calcProgressPct != 100).toVisibility()
|
||||
binding.progressBar.progress = overviewData.calcProgressPct
|
||||
}
|
||||
|
||||
private fun updateSensitivity() {
|
||||
|
|
|
@ -57,7 +57,7 @@ class PrepareBasalDataWorker(
|
|||
val fromTime = data.overviewData.fromTime
|
||||
var time = fromTime
|
||||
while (time < endTime) {
|
||||
val progress = (time - endTime).toDouble() / (endTime - fromTime) * 100.0
|
||||
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_BASAL_DATA, progress.toInt(), null))
|
||||
val profile = profileFunction.getProfile(time)
|
||||
if (profile == null) {
|
||||
|
|
|
@ -158,7 +158,7 @@ class PrepareIobAutosensGraphDataWorker(
|
|||
val adsData = data.iobCobCalculator.ads.clone()
|
||||
|
||||
while (time <= endTime) {
|
||||
val progress = (time - endTime).toDouble() / (endTime - fromTime) * 100.0
|
||||
val progress = (time - fromTime).toDouble() / (endTime - fromTime) * 100.0
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, progress.toInt(), null))
|
||||
val profile = profileFunction.getProfile(time)
|
||||
if (profile == null) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
|
|||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventUpdateOverviewGraph
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import java.security.spec.InvalidParameterSpecException
|
||||
import javax.inject.Inject
|
||||
|
||||
class UpdateGraphWorker(
|
||||
|
@ -20,11 +21,12 @@ class UpdateGraphWorker(
|
|||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
|
||||
override suspend fun doWorkAndLog(): Result {
|
||||
val pass = inputData.getInt(CalculationWorkflow.PASS, -1)
|
||||
if (inputData.getString(CalculationWorkflow.JOB) == CalculationWorkflow.MAIN_CALCULATION)
|
||||
activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewGraph("UpdateGraphWorker"))
|
||||
else
|
||||
rxBus.send(EventUpdateOverviewGraph("UpdateGraphWorker"))
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.DRAW, 100, null))
|
||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.values().find { it.pass == pass } ?: throw InvalidParameterSpecException(), 100, null))
|
||||
return Result.success()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue