Minor cleanup
This commit is contained in:
parent
6bc484617e
commit
d2f4c43526
@ -104,6 +104,7 @@ class SourceManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
return StubSource(SourceData(id, "", ""))
|
return StubSource(SourceData(id, "", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("OverridingDeprecatedMember")
|
@Suppress("OverridingDeprecatedMember")
|
||||||
open inner class StubSource(val sourceData: SourceData) : Source {
|
open inner class StubSource(val sourceData: SourceData) : Source {
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import nucleus.presenter.RxPresenter
|
import nucleus.presenter.RxPresenter
|
||||||
import nucleus.presenter.delivery.Delivery
|
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
|
|
||||||
open class BasePresenter<V> : RxPresenter<V>() {
|
open class BasePresenter<V> : RxPresenter<V>() {
|
||||||
@ -67,28 +66,4 @@ open class BasePresenter<V> : RxPresenter<V>() {
|
|||||||
* @param onError function to execute when the observable throws an error.
|
* @param onError function to execute when the observable throws an error.
|
||||||
*/
|
*/
|
||||||
fun <T> Observable<T>.subscribeReplay(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit) = { _, _ -> }) = compose(deliverReplay<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
fun <T> Observable<T>.subscribeReplay(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit) = { _, _ -> }) = compose(deliverReplay<T>()).subscribe(split(onNext, onError)).apply { add(this) }
|
||||||
|
|
||||||
/**
|
|
||||||
* Subscribes an observable with [DeliverWithView] and adds it to the presenter's lifecycle
|
|
||||||
* subscription list.
|
|
||||||
*
|
|
||||||
* @param onNext function to execute when the observable emits an item.
|
|
||||||
* @param onError function to execute when the observable throws an error.
|
|
||||||
*/
|
|
||||||
fun <T> Observable<T>.subscribeWithView(onNext: (V, T) -> Unit, onError: ((V, Throwable) -> Unit) = { _, _ -> }) = compose(DeliverWithView<V, T>(view())).subscribe(split(onNext, onError)).apply { add(this) }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A deliverable that only emits to the view if attached, otherwise the event is ignored.
|
|
||||||
*/
|
|
||||||
class DeliverWithView<View, T>(private val view: Observable<View>) : Observable.Transformer<T, Delivery<View, T>> {
|
|
||||||
|
|
||||||
override fun call(observable: Observable<T>): Observable<Delivery<View, T>> {
|
|
||||||
return observable
|
|
||||||
.materialize()
|
|
||||||
.filter { notification -> !notification.isOnCompleted }
|
|
||||||
.flatMap { notification ->
|
|
||||||
view.take(1).filter { it != null }.map { Delivery(it, notification) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ class MainActivity : BaseActivity() {
|
|||||||
try {
|
try {
|
||||||
ExtensionGithubApi().checkForUpdates(
|
ExtensionGithubApi().checkForUpdates(
|
||||||
this@MainActivity,
|
this@MainActivity,
|
||||||
fromAvailableExtensionList = true
|
fromAvailableExtensionList = true,
|
||||||
)?.let { pendingUpdates ->
|
)?.let { pendingUpdates ->
|
||||||
preferences.extensionUpdatesCount().set(pendingUpdates.size)
|
preferences.extensionUpdatesCount().set(pendingUpdates.size)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user