aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
blob: 045c180f93f23c584afe435fcec36c4e258662ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.pitchedapps.frost.web

import android.content.Context
import android.webkit.JavascriptInterface
import com.pitchedapps.frost.LoginActivity
import com.pitchedapps.frost.SelectorActivity
import com.pitchedapps.frost.dbflow.CookieModel
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, val cookies: ArrayList<CookieModel>) {
    @JavascriptInterface
    fun loadUrl(url: String) = context.launchWebOverlay(url)

    @JavascriptInterface
    fun loadLogin() {
        if (cookies.isNotEmpty())
            context.launchNewTask(SelectorActivity::class.java, cookies)
        else
            context.launchNewTask(LoginActivity::class.java, clearStack = false)
    }

}