aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/events/WebEvent.kt
blob: 64c919553289baab54b00522bdb3e64771682179 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.pitchedapps.frost.events

import com.pitchedapps.frost.web.FrostWebView

/**
 * Created by Allan Wang on 2017-05-31.
 */
class WebEvent(val key: Int, val urlMatch: String? = null) {

    companion object {
        const val REFRESH = 0
        const val REFRESH_BASE = 1
    }

    fun execute(webView: FrostWebView) {
        if (urlMatch != null && !webView.url.contains(urlMatch)) return
        when (key) {
            REFRESH -> webView.reload()
            REFRESH_BASE -> webView.loadUrl(webView.baseUrl)
        }
    }
}