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
|
||||
|
||||
class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
|
@ -144,7 +145,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
historybrowse_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
|
||||
|
||||
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
||||
prepareGraphs()
|
||||
prepareGraphsIfNeeded(overviewMenus.setting.size)
|
||||
savedInstanceState?.let { bundle ->
|
||||
rangeToDisplay = bundle.getInt("rangeToDisplay", 0)
|
||||
start = bundle.getLong("start", 0)
|
||||
|
@ -190,7 +191,6 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
if (it.now) {
|
||||
prepareGraphs()
|
||||
updateGUI("EventRefreshOverview", bgOnly = false)
|
||||
}
|
||||
}, fabricPrivacy::logException)
|
||||
|
@ -217,8 +217,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
}
|
||||
|
||||
private fun prepareGraphs() {
|
||||
val numOfGraphs = overviewMenus.setting.size
|
||||
private fun prepareGraphsIfNeeded(numOfGraphs: Int) {
|
||||
|
||||
if (numOfGraphs != secondaryGraphs.size - 1) {
|
||||
//aapsLogger.debug("New secondary graph count ${numOfGraphs-1}")
|
||||
|
@ -267,6 +266,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
fun updateGUI(from: String, bgOnly: Boolean) {
|
||||
val menuChartSettings = overviewMenus.setting
|
||||
prepareGraphsIfNeeded(menuChartSettings.size)
|
||||
aapsLogger.debug(LTag.UI, "updateGUI from: $from")
|
||||
val pump = activePlugin.activePump
|
||||
val profile = profileFunction.getProfile()
|
||||
|
|
|
@ -177,8 +177,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
sp.putBoolean(R.string.key_objectiveusescale, true)
|
||||
false
|
||||
}
|
||||
prepareGraphsIfNeeded(overviewMenus.setting.size)
|
||||
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
||||
prepareGraphs()
|
||||
|
||||
overview_activeprofile?.setOnClickListener(this)
|
||||
overview_activeprofile?.setOnLongClickListener(this)
|
||||
|
@ -210,7 +210,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
.toObservable(EventRefreshOverview::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
prepareGraphs()
|
||||
if (it.now) updateGUI(it.from)
|
||||
else scheduleUpdateGUI(it.from)
|
||||
}) { fabricPrivacy.logException(it) })
|
||||
|
@ -276,7 +275,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
updateGUI("onResume")
|
||||
}
|
||||
|
||||
|
||||
override fun onClick(v: View) {
|
||||
// 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
|
||||
|
@ -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_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_activeprofile -> {
|
||||
val args = Bundle()
|
||||
args.putLong("time", DateUtil.now())
|
||||
|
@ -297,6 +296,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
pvd.arguments = args
|
||||
pvd.show(childFragmentManager, "ProfileViewDialog")
|
||||
}
|
||||
|
||||
R.id.overview_cgmbutton -> {
|
||||
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
|
||||
openCgmApp("com.eveningoutpost.dexdrip")
|
||||
|
@ -372,6 +372,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
startActivity(Intent(v.context, QuickWizardListActivity::class.java))
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.overview_apsmode -> {
|
||||
val args = Bundle()
|
||||
args.putInt("showOkCancel", 0) // 0-> false
|
||||
|
@ -379,6 +380,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
pvd.arguments = args
|
||||
pvd.show(childFragmentManager, "Overview")
|
||||
}
|
||||
|
||||
R.id.overview_temptarget -> v.performClick()
|
||||
R.id.overview_activeprofile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") }) }
|
||||
|
||||
|
@ -468,10 +470,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
}
|
||||
|
||||
private fun prepareGraphs() {
|
||||
private fun prepareGraphsIfNeeded(numOfGraphs: Int) {
|
||||
synchronized(graphLock) {
|
||||
val numOfGraphs = overviewMenus.setting.size
|
||||
|
||||
if (numOfGraphs != secondaryGraphs.size - 1) {
|
||||
//aapsLogger.debug("New secondary graph count ${numOfGraphs-1}")
|
||||
// rebuild needed
|
||||
|
@ -798,6 +798,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {
|
||||
overview_bggraph ?: return@launch
|
||||
val menuChartSettings = overviewMenus.setting
|
||||
prepareGraphsIfNeeded(menuChartSettings.size)
|
||||
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin, treatmentsPlugin)
|
||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||
|
||||
|
|
Loading…
Reference in a new issue