PrefetchParameters.Builder
public final class PrefetchParameters.Builder
A builder class for constructing PrefetchParameters instances.
Summary
Public constructors |
|---|
Builder()Construct a new Builder. |
Public constructors
Public methods
addAdditionalHeader
@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.Builder addAdditionalHeader(@NonNull String key, @NonNull String value)
Sets the header value for the given key. If called multiple times for the same key, the last value will be used.
Header keys must be RFC 2616 compliant.
The logic for handling additional header isn't guaranteed to match the loadUrl's logic and is subject to change in the future.
| Returns | |
|---|---|
@NonNull PrefetchParameters.Builder |
This builder instance for chaining. |
addAdditionalHeaders
@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.Builder addAdditionalHeaders(@NonNull Map<String, String> additionalHeaders)
Sets multiple headers at once. The headers passed in here will be merged with any that have been previously set (duplicate keys will be overridden).
Header keys must be RFC 2616 -compliant.
| Returns | |
|---|---|
@NonNull PrefetchParameters.Builder |
This builder instance for chaining. |
build
@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters build()
Build the PrefetchParameters.
setExpectedNoVarySearchData
@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.BuildersetExpectedNoVarySearchData(
@NonNull NoVarySearchHeader expectedNoVarySearchHeader
)
Sets the No-Vary-Search data that's expected to be returned via the header in the prefetch's response.
This is used to help determine if WebView#loadUrl should either use an in-flight prefetch response to render the web contents or handle the URL as it typically does (i.e. start a network request).
| Parameters | |
|---|---|
@NonNull NoVarySearchHeader expectedNoVarySearchHeader |
The No-Vary-Search data expected to be returned in the prefetch's response. |
| Returns | |
|---|---|
@NonNull PrefetchParameters.Builder |
This builder instance for chaining. |
setExpectedNoVarySearchHeader
@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.Builder setExpectedNoVarySearchHeader(
@NonNull NoVarySearchHeader expectedNoVarySearchHeader
)
Sets the No-Vary-Search data that's expected to be returned via the header in the prefetch's response.
This is used to help determine if WebView#loadUrl should either use an in-flight prefetch response to render the web contents or handle the URL as it typically does (i.e. start a network request).
| Parameters | |
|---|---|
@NonNull NoVarySearchHeader expectedNoVarySearchHeader |
The No-Vary-Search data expected to be returned in the prefetch's response. |
| Returns | |
|---|---|
@NonNull PrefetchParameters.Builder |
This builder instance for chaining. |
setJavaScriptEnabled
@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.Builder setJavaScriptEnabled(boolean javaScriptEnabled)
Set whether the page that is loaded will have JavaScript enabled. true if the WebView's that will be loading the prefetched response will have javascript enabled. This affects whether client hints header is sent with the prefetch request.
| Parameters | |
|---|---|
boolean javaScriptEnabled |
|
| Returns | |
|---|---|
@NonNull PrefetchParameters.Builder |
This builder instance for chaining. |
setVariationsId
@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.Builder setVariationsId(@Nullable Integer variationsId)
Sets an optional variations ID to associate with this prefetch request.
| Parameters | |
|---|---|
@Nullable Integer variationsId |
An Integer ID for this prefetch configuration, or |
| Returns | |
|---|---|
@NonNull PrefetchParameters.Builder |
This builder instance for chaining. |