Fix queue size view
This commit is contained in:
parent
71b13917c4
commit
45fd5264b0
1 changed files with 15 additions and 14 deletions
|
@ -18,6 +18,8 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import io.reactivex.BackpressureStrategy
|
||||||
|
import io.reactivex.Single
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
@ -46,23 +48,18 @@ class OpenHumansFragment : DaggerFragment() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
compositeDisposable += rxBus.toObservable(UpdateQueueEvent::class.java)
|
compositeDisposable += Single.fromCallable { MainApp.getDbHelper().ohQueueSize }
|
||||||
.throttleLatest(5, TimeUnit.SECONDS)
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.io())
|
.repeatWhen { rxBus.toObservable(UpdateViewEvent::class.java)
|
||||||
.map { MainApp.getDbHelper().ohQueueSize }
|
.cast(Any::class.java)
|
||||||
|
.mergeWith(rxBus.toObservable(UpdateQueueEvent::class.java)
|
||||||
|
.throttleLatest(5, TimeUnit.SECONDS))
|
||||||
|
.toFlowable(BackpressureStrategy.LATEST) }
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe {
|
.subscribe({
|
||||||
queueSizeValue = it
|
queueSizeValue = it
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}, {})
|
||||||
compositeDisposable += rxBus.toObservable(UpdateViewEvent::class.java)
|
|
||||||
.observeOn(Schedulers.io())
|
|
||||||
.map { MainApp.getDbHelper().ohQueueSize }
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe {
|
|
||||||
queueSizeValue = it
|
|
||||||
updateGUI()
|
|
||||||
}
|
|
||||||
context?.applicationContext?.let { appContext ->
|
context?.applicationContext?.let { appContext ->
|
||||||
WorkManager.getInstance(appContext).getWorkInfosForUniqueWorkLiveData(OpenHumansUploader.WORK_NAME).observe(this, Observer<List<WorkInfo>> {
|
WorkManager.getInstance(appContext).getWorkInfosForUniqueWorkLiveData(OpenHumansUploader.WORK_NAME).observe(this, Observer<List<WorkInfo>> {
|
||||||
val workInfo = it.lastOrNull()
|
val workInfo = it.lastOrNull()
|
||||||
|
@ -74,6 +71,10 @@ class OpenHumansFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openHumansUploader.uploadDataSegmentally()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
|
Loading…
Reference in a new issue