Ensure rescheduleUpdate is ran on bg thread

This commit is contained in:
Mygod
2020-05-23 06:13:12 +08:00
parent 4336632508
commit 6f94e31f51

View File

@@ -229,7 +229,11 @@ class ClientsFragment : Fragment() {
super.onStart() super.onStart()
// we just put these two thing together as this is the only place we need to use this event for now // we just put these two thing together as this is the only place we need to use this event for now
TrafficRecorder.foregroundListeners[this] = adapter::updateTraffic TrafficRecorder.foregroundListeners[this] = adapter::updateTraffic
TrafficRecorder.rescheduleUpdate() // next schedule time might be 1 min, force reschedule to <= 1s lifecycleScope.launchWhenStarted {
withContext(Dispatchers.Default) {
TrafficRecorder.rescheduleUpdate() // next schedule time might be 1 min, force reschedule to <= 1s
}
}
} }
override fun onStop() { override fun onStop() {