prepare graphs with settings size used for ui updates
This commit is contained in:
parent
d0b6e09250
commit
aedc2cb352
2 changed files with 25 additions and 24 deletions
|
@ -44,6 +44,7 @@ import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
@ -144,7 +145,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
historybrowse_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
|
historybrowse_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
|
||||||
|
|
||||||
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
||||||
prepareGraphs()
|
prepareGraphsIfNeeded(overviewMenus.setting.size)
|
||||||
savedInstanceState?.let { bundle ->
|
savedInstanceState?.let { bundle ->
|
||||||
rangeToDisplay = bundle.getInt("rangeToDisplay", 0)
|
rangeToDisplay = bundle.getInt("rangeToDisplay", 0)
|
||||||
start = bundle.getLong("start", 0)
|
start = bundle.getLong("start", 0)
|
||||||
|
@ -168,7 +169,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
if (it.cause is EventCustomCalculationFinished) {
|
if (it.cause is EventCustomCalculationFinished) {
|
||||||
updateGUI("EventAutosensCalculationFinished", bgOnly = false)
|
updateGUI("EventAutosensCalculationFinished", bgOnly = false)
|
||||||
}
|
}
|
||||||
}, fabricPrivacy::logException )
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensBgLoaded::class.java)
|
.toObservable(EventAutosensBgLoaded::class.java)
|
||||||
|
@ -178,22 +179,21 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
if (it.cause is EventCustomCalculationFinished) {
|
if (it.cause is EventCustomCalculationFinished) {
|
||||||
updateGUI("EventAutosensCalculationFinished", bgOnly = true)
|
updateGUI("EventAutosensCalculationFinished", bgOnly = true)
|
||||||
}
|
}
|
||||||
}, fabricPrivacy::logException )
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventIobCalculationProgress::class.java)
|
.toObservable(EventIobCalculationProgress::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ overview_iobcalculationprogess?.text = it.progress }, fabricPrivacy::logException )
|
.subscribe({ overview_iobcalculationprogess?.text = it.progress }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({
|
.subscribe({
|
||||||
if (it.now) {
|
if (it.now) {
|
||||||
prepareGraphs()
|
|
||||||
updateGUI("EventRefreshOverview", bgOnly = false)
|
updateGUI("EventRefreshOverview", bgOnly = false)
|
||||||
}
|
}
|
||||||
}, fabricPrivacy::logException )
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
if (start == 0L) {
|
if (start == 0L) {
|
||||||
// set start of current day
|
// set start of current day
|
||||||
|
@ -217,8 +217,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareGraphs() {
|
private fun prepareGraphsIfNeeded(numOfGraphs: Int) {
|
||||||
val numOfGraphs = overviewMenus.setting.size
|
|
||||||
|
|
||||||
if (numOfGraphs != secondaryGraphs.size - 1) {
|
if (numOfGraphs != secondaryGraphs.size - 1) {
|
||||||
//aapsLogger.debug("New secondary graph count ${numOfGraphs-1}")
|
//aapsLogger.debug("New secondary graph count ${numOfGraphs-1}")
|
||||||
|
@ -267,6 +266,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
fun updateGUI(from: String, bgOnly: Boolean) {
|
fun updateGUI(from: String, bgOnly: Boolean) {
|
||||||
val menuChartSettings = overviewMenus.setting
|
val menuChartSettings = overviewMenus.setting
|
||||||
|
prepareGraphsIfNeeded(menuChartSettings.size)
|
||||||
aapsLogger.debug(LTag.UI, "updateGUI from: $from")
|
aapsLogger.debug(LTag.UI, "updateGUI from: $from")
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
val profile = profileFunction.getProfile()
|
val profile = profileFunction.getProfile()
|
||||||
|
|
|
@ -177,8 +177,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
sp.putBoolean(R.string.key_objectiveusescale, true)
|
sp.putBoolean(R.string.key_objectiveusescale, true)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
prepareGraphsIfNeeded(overviewMenus.setting.size)
|
||||||
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
||||||
prepareGraphs()
|
|
||||||
|
|
||||||
overview_activeprofile?.setOnClickListener(this)
|
overview_activeprofile?.setOnClickListener(this)
|
||||||
overview_activeprofile?.setOnLongClickListener(this)
|
overview_activeprofile?.setOnLongClickListener(this)
|
||||||
|
@ -210,7 +210,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({
|
.subscribe({
|
||||||
prepareGraphs()
|
|
||||||
if (it.now) updateGUI(it.from)
|
if (it.now) updateGUI(it.from)
|
||||||
else scheduleUpdateGUI(it.from)
|
else scheduleUpdateGUI(it.from)
|
||||||
}) { fabricPrivacy.logException(it) })
|
}) { fabricPrivacy.logException(it) })
|
||||||
|
@ -276,7 +275,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
updateGUI("onResume")
|
updateGUI("onResume")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
||||||
// https://stackoverflow.com/questions/14860239/checking-if-state-is-saved-before-committing-a-fragmenttransaction
|
// https://stackoverflow.com/questions/14860239/checking-if-state-is-saved-before-committing-a-fragmenttransaction
|
||||||
|
@ -289,6 +287,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { onClickQuickWizard() })
|
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { onClickQuickWizard() })
|
||||||
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { CarbsDialog().show(childFragmentManager, "Overview") })
|
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { CarbsDialog().show(childFragmentManager, "Overview") })
|
||||||
R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TempTargetDialog().show(childFragmentManager, "Overview") })
|
R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TempTargetDialog().show(childFragmentManager, "Overview") })
|
||||||
|
|
||||||
R.id.overview_activeprofile -> {
|
R.id.overview_activeprofile -> {
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
args.putLong("time", DateUtil.now())
|
args.putLong("time", DateUtil.now())
|
||||||
|
@ -297,6 +296,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
pvd.arguments = args
|
pvd.arguments = args
|
||||||
pvd.show(childFragmentManager, "ProfileViewDialog")
|
pvd.show(childFragmentManager, "ProfileViewDialog")
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_cgmbutton -> {
|
R.id.overview_cgmbutton -> {
|
||||||
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
|
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
|
||||||
openCgmApp("com.eveningoutpost.dexdrip")
|
openCgmApp("com.eveningoutpost.dexdrip")
|
||||||
|
@ -372,6 +372,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
startActivity(Intent(v.context, QuickWizardListActivity::class.java))
|
startActivity(Intent(v.context, QuickWizardListActivity::class.java))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_apsmode -> {
|
R.id.overview_apsmode -> {
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
args.putInt("showOkCancel", 0) // 0-> false
|
args.putInt("showOkCancel", 0) // 0-> false
|
||||||
|
@ -379,8 +380,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
pvd.arguments = args
|
pvd.arguments = args
|
||||||
pvd.show(childFragmentManager, "Overview")
|
pvd.show(childFragmentManager, "Overview")
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_temptarget -> v.performClick()
|
R.id.overview_temptarget -> v.performClick()
|
||||||
R.id.overview_activeprofile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") })}
|
R.id.overview_activeprofile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") }) }
|
||||||
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -468,10 +470,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareGraphs() {
|
private fun prepareGraphsIfNeeded(numOfGraphs: Int) {
|
||||||
synchronized(graphLock) {
|
synchronized(graphLock) {
|
||||||
val numOfGraphs = overviewMenus.setting.size
|
|
||||||
|
|
||||||
if (numOfGraphs != secondaryGraphs.size - 1) {
|
if (numOfGraphs != secondaryGraphs.size - 1) {
|
||||||
//aapsLogger.debug("New secondary graph count ${numOfGraphs-1}")
|
//aapsLogger.debug("New secondary graph count ${numOfGraphs-1}")
|
||||||
// rebuild needed
|
// rebuild needed
|
||||||
|
@ -798,6 +798,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {
|
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {
|
||||||
overview_bggraph ?: return@launch
|
overview_bggraph ?: return@launch
|
||||||
val menuChartSettings = overviewMenus.setting
|
val menuChartSettings = overviewMenus.setting
|
||||||
|
prepareGraphsIfNeeded(menuChartSettings.size)
|
||||||
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin, treatmentsPlugin)
|
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin, treatmentsPlugin)
|
||||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue