aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-13 17:07:09 -0700
committerAllan Wang <me@allanwang.ca>2017-06-13 17:07:09 -0700
commit0ac9d2181536b79a6057c3b526f32a1cc8ac4704 (patch)
treeb561acf7fc94a79e8a48b548489e0f544d402b8c /app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
parente4377fed20ce1e3f4a0b236271eecdb1fe573b7a (diff)
downloadfrost-0ac9d2181536b79a6057c3b526f32a1cc8ac4704.tar.gz
frost-0ac9d2181536b79a6057c3b526f32a1cc8ac4704.tar.bz2
frost-0ac9d2181536b79a6057c3b526f32a1cc8ac4704.zip
Created working workaround for menu item
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt24
1 files changed, 22 insertions, 2 deletions
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 66f638af..14ea4df8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -6,15 +6,16 @@ import com.pitchedapps.frost.LoginActivity
import com.pitchedapps.frost.MainActivity
import com.pitchedapps.frost.SelectorActivity
import com.pitchedapps.frost.dbflow.CookieModel
+import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.cookies
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.launchWebOverlay
+
/**
* Created by Allan Wang on 2017-06-01.
*/
-class FrostJSI(val context: Context) {
-
+class FrostJSI(val context: Context, val webView: FrostWebViewCore) {
val cookies: ArrayList<CookieModel>
get() = (context as? MainActivity)?.cookies() ?: arrayListOf()
@@ -22,6 +23,15 @@ class FrostJSI(val context: Context) {
fun loadUrl(url: String) = context.launchWebOverlay(url)
@JavascriptInterface
+ fun reloadBaseUrl() {
+ L.d("FrostJSI reload")
+ webView.post {
+ webView.stopLoading()
+ webView.loadBaseUrl()
+ }
+ }
+
+ @JavascriptInterface
fun loadLogin() {
if (cookies.isNotEmpty())
context.launchNewTask(SelectorActivity::class.java, cookies)
@@ -29,4 +39,14 @@ class FrostJSI(val context: Context) {
context.launchNewTask(LoginActivity::class.java)
}
+ @JavascriptInterface
+ fun emit(flag: Int) {
+ webView.post { webView.frostWebClient!!.emit(flag) }
+ }
+
+ @JavascriptInterface
+ fun handleHtml(html: String) {
+ webView.post { webView.frostWebClient!!.handleHtml(html) }
+ }
+
} \ No newline at end of file