Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.thefinestartist.finestwebview.listeners.BroadCastManager
import com.thefinestartist.finestwebview.listeners.WebViewListener
import java.io.Serializable
import java.util.*
import kotlin.collections.HashMap

/** Created by Leonardo on 11/21/15. */
data class FinestWebView(
Expand Down Expand Up @@ -154,6 +155,7 @@ data class FinestWebView(
var encoding: String? = null,
var data: String? = null,
var url: String? = null,
var headers: HashMap<String,String>? = null
) : Serializable {

constructor(ctx: Context) : this(context = ctx)
Expand Down Expand Up @@ -428,9 +430,12 @@ data class FinestWebView(
load(context.getString(dataRes))
}

fun load(data: String?, mimeType: String? = "text/html", encoding: String? = "UTF-8") {
fun load(data: String?, mimeType: String? = "text/html", encoding: String? = "UTF-8", headers: HashMap<String, String>? = null) {
this.mimeType = mimeType
this.encoding = encoding
headers?.let {
this.headers = headers
}
show(null, data)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class FinestWebViewActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedL
protected var encoding: String? = null
protected var data: String? = null
protected var url: String? = null
protected var headers: HashMap<String,String>? = null
protected var coordinatorLayout: CoordinatorLayout? = null
protected var appBar: AppBarLayout? = null
protected var toolbar: Toolbar? = null
Expand Down Expand Up @@ -352,6 +353,10 @@ class FinestWebViewActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedL
encoding = finestWebView.encoding
data = finestWebView.data
url = finestWebView.url
finestWebView.headers?.let { headerMap ->
headers = headerMap
}

}

protected fun bindViews() {
Expand Down Expand Up @@ -645,7 +650,12 @@ class FinestWebViewActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedL
if (data != null) {
webView!!.loadData(data!!, mimeType, encoding)
} else if (url != null) {
webView!!.loadUrl(url!!)
headers?.let { headers ->
webView!!.loadUrl(url!!,headers)
}?.run {
webView!!.loadUrl(url!!)
}

}
}
run { // SwipeRefreshLayout
Expand Down