Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/src/main/kotlin/info/appdev/chartexample/TimeLineActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ class TimeLineActivity : DemoBase() {
true
}.isCheckable = true
}
menuItemMove = menu?.add("Move X-Axis")?.apply {
setOnMenuItemClickListener { menuItem ->
menuItem.isChecked = !menuItem.isChecked
lifecycleScope.launch {
moveXAxis()
}
true
}.isCheckable = true
}
return true
}

Expand All @@ -155,6 +164,22 @@ class TimeLineActivity : DemoBase() {
add(first)
}

private suspend fun moveXAxis() {
withContext(Dispatchers.Default) {
while (menuItemMove!!.isChecked) {
withContext(Dispatchers.Main) {
binding.chart1.xAxis.apply {
this.axisMinimum += 1000f
this.axisMaximum += 1000f
binding.chart1.notifyDataSetChanged()
binding.chart1.invalidate()
}
}
delay(100)
}
}
}

private suspend fun moveChart() {
withContext(Dispatchers.Default) {
while (menuItemMove!!.isChecked) {
Expand Down
Loading