diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-27 14:34:29 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2018-12-27 14:34:29 -0500 |
commit | f9e3a324e47a81a30aade003cf6f829d03c81414 (patch) | |
tree | 655a7fc8894170716986a0cab1c784822d750f6f /app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt | |
parent | e6dcbd7b32dc49b11184b6beca598819c3f071fd (diff) | |
download | frost-f9e3a324e47a81a30aade003cf6f829d03c81414.tar.gz frost-f9e3a324e47a81a30aade003cf6f829d03c81414.tar.bz2 frost-f9e3a324e47a81a30aade003cf6f829d03c81414.zip |
Convert remaining view observables
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt index bf04c524..816524ba 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -73,6 +73,9 @@ import com.pitchedapps.frost.views.FrostWebView import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import okhttp3.HttpUrl /** @@ -99,12 +102,15 @@ class FrostWebActivity : WebOverlayActivityBase(false) { * We will subscribe to the load cycle once, * and pop a dialog giving the user the option to copy the shared text */ - var disposable: Disposable? = null - disposable = content.refreshObservable.subscribe { - disposable?.dispose() - materialDialogThemed { - title(R.string.invalid_share_url) - content(R.string.invalid_share_url_desc) + val refreshReceiver = content.refreshChannel.openSubscription() + content.scope.launch(Dispatchers.IO) { + refreshReceiver.receive() + refreshReceiver.cancel() + withContext(Dispatchers.Main) { + materialDialogThemed { + title(R.string.invalid_share_url) + content(R.string.invalid_share_url_desc) + } } } } @@ -197,10 +203,13 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc content.bind(this) - content.titleObservable - .observeOn(AndroidSchedulers.mainThread()) - .subscribe { toolbar.title = it } - .disposeOnDestroy() + val titleReceiver = content.titleChannel.openSubscription() + + launch { + for (t in titleReceiver) { + toolbar.title = t + } + } with(web) { if (forceBasicAgent) //todo check; the webview already adds it dynamically |