better synchronize graph rendering
This commit is contained in:
parent
4d32b65aab
commit
7282f460fc
1 changed files with 78 additions and 73 deletions
|
@ -159,6 +159,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
private var carbAnimation: AnimationDrawable? = null
|
private var carbAnimation: AnimationDrawable? = null
|
||||||
|
|
||||||
|
private val graphLock = Object()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View? {
|
savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
|
@ -478,8 +480,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
private fun prepareGraphs() {
|
private fun prepareGraphs() {
|
||||||
|
synchronized(graphLock) {
|
||||||
val numOfGraphs = overviewMenus.setting.size
|
val numOfGraphs = overviewMenus.setting.size
|
||||||
|
|
||||||
if (numOfGraphs != secondaryGraphs.size - 1) {
|
if (numOfGraphs != secondaryGraphs.size - 1) {
|
||||||
|
@ -514,7 +516,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
secondaryGraphs.add(graph)
|
secondaryGraphs.add(graph)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scheduleUpdateGUI(from: String) {
|
private fun scheduleUpdateGUI(from: String) {
|
||||||
|
@ -533,7 +535,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
scheduledUpdate = worker.schedule(task, 500, TimeUnit.MILLISECONDS)
|
scheduledUpdate = worker.schedule(task, 500, TimeUnit.MILLISECONDS)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
fun updateGUI(from: String) {
|
fun updateGUI(from: String) {
|
||||||
aapsLogger.debug("UpdateGUI from $from")
|
aapsLogger.debug("UpdateGUI from $from")
|
||||||
|
@ -857,6 +858,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
graphData.addNowLine(now)
|
graphData.addNowLine(now)
|
||||||
|
|
||||||
// ------------------ 2nd graph
|
// ------------------ 2nd graph
|
||||||
|
synchronized(graphLock) {
|
||||||
for (g in 0 until min(secondaryGraphs.size, overviewMenus.setting.size + 1)) {
|
for (g in 0 until min(secondaryGraphs.size, overviewMenus.setting.size + 1)) {
|
||||||
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPlugin, treatmentsPlugin)
|
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPlugin, treatmentsPlugin)
|
||||||
var useABSForScale = false
|
var useABSForScale = false
|
||||||
|
@ -890,8 +892,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
secondaryGraphsData.add(secondGraphData)
|
secondaryGraphsData.add(secondGraphData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// finally enforce drawing of graphs in UI thread
|
// finally enforce drawing of graphs in UI thread
|
||||||
graphData.performUpdate()
|
graphData.performUpdate()
|
||||||
|
synchronized(graphLock) {
|
||||||
for (g in 0 until min(secondaryGraphs.size, overviewMenus.setting.size + 1)) {
|
for (g in 0 until min(secondaryGraphs.size, overviewMenus.setting.size + 1)) {
|
||||||
secondaryGraphsLabel[g].text = overviewMenus.enabledTypes(g + 1)
|
secondaryGraphsLabel[g].text = overviewMenus.enabledTypes(g + 1)
|
||||||
secondaryGraphs[g].visibility = (
|
secondaryGraphs[g].visibility = (
|
||||||
|
@ -908,3 +912,4 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue