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