aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web
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
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')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt11
3 files changed, 13 insertions, 9 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
index 1f8118da..f3538ec3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
@@ -31,6 +31,8 @@ import com.pitchedapps.frost.utils.frostSnackbar
import com.pitchedapps.frost.views.FrostWebView
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.Subject
+import kotlinx.coroutines.channels.ReceiveChannel
+import kotlinx.coroutines.channels.SendChannel
/**
* Created by Allan Wang on 2017-05-31.
@@ -43,8 +45,8 @@ import io.reactivex.subjects.Subject
*/
class FrostChromeClient(web: FrostWebView) : WebChromeClient() {
- private val progress = web.parent.progressChannel
- private val title = web.parent.titleChannel
+ private val progress: SendChannel<Int> = web.parent.progressChannel
+ private val title: SendChannel<String> = web.parent.titleChannel
private var prevTitle: String? = null
private val activity = (web.context as? ActivityContract)
private val context = web.context!!
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
index 2afb28c9..3945a9a0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -30,6 +30,7 @@ import com.pitchedapps.frost.utils.launchImageActivity
import com.pitchedapps.frost.utils.showWebContextMenu
import com.pitchedapps.frost.views.FrostWebView
import io.reactivex.subjects.Subject
+import kotlinx.coroutines.channels.SendChannel
/**
* Created by Allan Wang on 2017-06-01.
@@ -39,7 +40,7 @@ class FrostJSI(val web: FrostWebView) {
private val context = web.context
private val activity = context as? MainActivity
private val header: Subject<String>? = activity?.headerBadgeObservable
- private val refresh: Subject<Boolean> = web.parent.refreshObservable
+ private val refresh: SendChannel<Boolean> = web.parent.refreshChannel
private val cookies = activity?.cookies() ?: arrayListOf()
/**
@@ -120,7 +121,7 @@ class FrostJSI(val web: FrostWebView) {
@JavascriptInterface
fun isReady() {
- refresh.onNext(false)
+ refresh.offer(false)
}
@JavascriptInterface
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,