Builder

class Builder
kotlin.Any
   ↳ androidx.webkit.WebViewAssetLoader.Builder

A builder class for constructing WebViewAssetLoader objects.

Summary

Public constructors

<init>(@NonNull context: Context)

Public methods

WebViewAssetLoader.Builder

Allow using the HTTP scheme in addition to HTTPS.

WebViewAssetLoader

Build and return a WebViewAssetLoader object.

WebViewAssetLoader.Builder
setAssetsHostingPath(@NonNull path: String)

Set the prefix path under which app assets should be hosted.

WebViewAssetLoader.Builder
setDomain(@NonNull domain: String)

Set the domain under which app assets and resources can be accessed.

WebViewAssetLoader.Builder

Set the prefix path under which app resources should be hosted.

Public constructors

<init>

Builder(@NonNull context: Context)
Parameters
context Context: Context used to resolve resources/assets.

Public methods

allowHttp

@NonNull fun allowHttp(): WebViewAssetLoader.Builder

Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP.

Return
WebViewAssetLoader.Builder: Builder object.

build

@NonNull fun build(): WebViewAssetLoader

Build and return a WebViewAssetLoader object.

Return
WebViewAssetLoader: immutable WebViewAssetLoader object.
Exceptions
IllegalArgumentException if the Builder received conflicting inputs.

setAssetsHostingPath

@NonNull fun setAssetsHostingPath(@NonNull path: String): WebViewAssetLoader.Builder

Set the prefix path under which app assets should be hosted. The default path for assets is "/assets/". The path must start and end with "/".

A custom prefix path can be used in conjunction with a custom domain, to avoid conflicts with real paths which may be hosted at that domain.

Parameters
path String: the path under which app assets should be hosted.
Return
WebViewAssetLoader.Builder: Builder object.
Exceptions
IllegalArgumentException if the path is invalid.

setDomain

@NonNull fun setDomain(@NonNull domain: String): WebViewAssetLoader.Builder

Set the domain under which app assets and resources can be accessed. The default domain is "appassets.androidplatform.net"

Parameters
domain String: the domain on which app assets should be hosted.
Return
WebViewAssetLoader.Builder: Builder object.

setResourcesHostingPath

@NonNull fun setResourcesHostingPath(@NonNull path: String): WebViewAssetLoader.Builder

Set the prefix path under which app resources should be hosted. The default path for resources is "/res/". The path must start and end with "/". A custom prefix path can be used in conjunction with a custom domain, to avoid conflicts with real paths which may be hosted at that domain.

Parameters
path String: the path under which app resources should be hosted.
Return
WebViewAssetLoader.Builder: Builder object.
Exceptions
IllegalArgumentException if the path is invalid.