From 8618670b82641d5fbaec9c333f1290bab429ce27 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 31 May 2017 17:11:46 -0700 Subject: add more cookie handling --- .../pitchedapps/frost/web/FrostWebViewClient.kt | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt') 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) : WebViewClient() { + + private var injectionCount: Int = 0 + + companion object { + //Collections of jewels mapped with url match -> id + val jewelMap: Map = 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 -- cgit v1.2.3