aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-15 20:41:55 -0700
committerAllan Wang <me@allanwang.ca>2017-06-15 20:41:55 -0700
commitf84a05f8aeb73ce63f77b7cc779845c31427b2b2 (patch)
treeb11309b4649c5e7e1f4666e9a07e60da56b1c307 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt
parentc8f76b5aa406f84f49789a50871c68a1a95a232d (diff)
downloadfrost-f84a05f8aeb73ce63f77b7cc779845c31427b2b2.tar.gz
frost-f84a05f8aeb73ce63f77b7cc779845c31427b2b2.tar.bz2
frost-f84a05f8aeb73ce63f77b7cc779845c31427b2b2.zip
Reorganize observables and clean up
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt28
1 files changed, 13 insertions, 15 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt
index f299b840..9a00c563 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClientMenu.kt
@@ -9,10 +9,10 @@ import io.reactivex.subjects.Subject
/**
* Created by Allan Wang on 2017-05-31.
*/
-class FrostWebViewClientMenu(refreshObservable: Subject<Boolean>) : FrostWebViewClient(refreshObservable) {
+class FrostWebViewClientMenu(webCore: FrostWebViewCore) : FrostWebViewClient(webCore) {
var content: String? = null
- var view: FrostWebViewCore? = null
+ val progressObservable: Subject<Int> = webCore.progressObservable
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
@@ -31,32 +31,30 @@ class FrostWebViewClientMenu(refreshObservable: Subject<Boolean>) : FrostWebView
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
- with(view as FrostWebViewCore) {
- if (url == view.baseUrl) {
- this@FrostWebViewClientMenu.view = view
- inject(JsAssets.MENU, view, {
- inject(JsAssets.MENU_CLICK, view) //menu injection must be after or we will have a loop from the click listener
- })
- } else {
- inject(JsAssets.MENU_CLICK, view)
- }
+ if (url == webCore.baseUrl) {
+ progressObservable.onNext(99)
+ inject(JsAssets.MENU, webCore, {
+ inject(JsAssets.MENU_CLICK, webCore) //menu injection must be after or we will have a loop from the click listener
+ })
+ } else {
+ inject(JsAssets.MENU_CLICK, webCore)
}
}
override fun emit(flag: Int) {
super.emit(flag)
- if (view != null) super.onPageFinishedActions(view!!)
- view = null
+ progressObservable.onNext(100)
+ super.injectAndFinish()
}
- override fun onPageFinishedActions(view: FrostWebViewCore, url: String?) {
+ override fun onPageFinishedActions(url: String?) {
when (url) {
"https://m.facebook.com/settings",
"https://m.facebook.com/settings#",
"https://m.facebook.com/settings#!/settings?soft=bookmarks" -> {
//do nothing; we will further inject before revealing
}
- else -> super.onPageFinishedActions(view)
+ else -> injectAndFinish()
}
}