aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-05-31 17:11:46 -0700
committerAllan Wang <me@allanwang.ca>2017-05-31 17:11:46 -0700
commit8618670b82641d5fbaec9c333f1290bab429ce27 (patch)
tree737c9a04f108ea68547eef2db1ae6e96caa64df6 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
parent9a41937a33539dbfaae4d072361caaec79865c29 (diff)
downloadfrost-8618670b82641d5fbaec9c333f1290bab429ce27.tar.gz
frost-8618670b82641d5fbaec9c333f1290bab429ce27.tar.bz2
frost-8618670b82641d5fbaec9c333f1290bab429ce27.zip
add more cookie handling
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
new file mode 100644
index 00000000..14fcc22a
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
@@ -0,0 +1,48 @@
+package com.pitchedapps.frost.web
+
+import android.graphics.Bitmap
+import android.webkit.*
+import com.pitchedapps.frost.facebook.FbCookie
+import com.pitchedapps.frost.utils.L
+import io.reactivex.subjects.Subject
+
+/**
+ * Created by Allan Wang on 2017-05-31.
+ */
+class FrostWebViewClient(val observable: Subject<WebStatus>) : WebViewClient() {
+
+ private var injectionCount: Int = 0
+
+ companion object {
+ //Collections of jewels mapped with url match -> id
+ val jewelMap: Map<String, String> = mapOf("a" to "b")
+ fun test() {
+
+ }
+ }
+
+ override fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?) {
+ super.onReceivedError(view, request, error)
+ observable.onNext(WebStatus.ERROR)
+ L.e("FWV Error ${request}")
+ }
+
+ override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
+ super.onPageStarted(view, url, favicon)
+ injectionCount = 0
+ observable.onNext(WebStatus.LOADING)
+ L.d("FWV Loading $url")
+ if (url.contains("logout.php")) FbCookie.logout()
+ }
+
+ override fun onPageFinished(view: WebView, url: String) {
+ super.onPageFinished(view, url)
+ observable.onNext(WebStatus.LOADED)
+ FbCookie.checkUserId(url, CookieManager.getInstance().getCookie(url))
+ }
+
+ fun logout() {
+
+ }
+
+} \ No newline at end of file