aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-27 14:34:29 -0500
committerAllan Wang <me@allanwang.ca>2018-12-27 14:34:29 -0500
commitf9e3a324e47a81a30aade003cf6f829d03c81414 (patch)
tree655a7fc8894170716986a0cab1c784822d750f6f /app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
parente6dcbd7b32dc49b11184b6beca598819c3f071fd (diff)
downloadfrost-f9e3a324e47a81a30aade003cf6f829d03c81414.tar.gz
frost-f9e3a324e47a81a30aade003cf6f829d03c81414.tar.bz2
frost-f9e3a324e47a81a30aade003cf6f829d03c81414.zip
Convert remaining view observables
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
index d75f03bb..5a137c44 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -41,6 +41,7 @@ import com.pitchedapps.frost.utils.launchImageActivity
import com.pitchedapps.frost.utils.resolveActivityForUri
import com.pitchedapps.frost.views.FrostWebView
import io.reactivex.subjects.Subject
+import kotlinx.coroutines.channels.SendChannel
import org.jetbrains.anko.withAlpha
/**
@@ -64,7 +65,7 @@ open class BaseWebViewClient : WebViewClient() {
*/
open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
- private val refresh: Subject<Boolean> = web.parent.refreshObservable
+ private val refresh: SendChannel<Boolean> = web.parent.refreshChannel
private val isMain = web.parent.baseEnum != null
protected inline fun v(crossinline message: () -> Any?) = L.v { "web client: ${message()}" }
@@ -73,7 +74,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
super.onPageStarted(view, url, favicon)
if (url == null) return
v { "loading $url" }
- refresh.onNext(true)
+ refresh.offer(true)
}
private fun injectBackgroundColor() {
@@ -110,14 +111,14 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
JsAssets.MEDIA
)
else
- refresh.onNext(false)
+ refresh.offer(false)
}
override fun onPageFinished(view: WebView, url: String?) {
url ?: return
v { "finished $url" }
if (!url.isFacebookUrl) {
- refresh.onNext(false)
+ refresh.offer(false)
return
}
onPageFinishedActions(url)
@@ -131,7 +132,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
internal fun injectAndFinish() {
v { "page finished reveal" }
- refresh.onNext(false)
+ refresh.offer(false)
injectBackgroundColor()
web.jsInject(
JsActions.LOGIN_CHECK,