public class

WebResourceRequestCompat

extends java.lang.Object

 java.lang.Object

↳androidx.webkit.WebResourceRequestCompat

Gradle dependencies

compile group: 'androidx.webkit', name: 'webkit', version: '1.5.0-alpha01'

  • groupId: androidx.webkit
  • artifactId: webkit
  • version: 1.5.0-alpha01

Artifact androidx.webkit:webkit:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.webkit:webkit com.android.support:webkit

Overview

Compatibility version of .

Summary

Methods
public static booleanisRedirect(WebResourceRequest request)

Gets whether the request was a result of a server-side redirect.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public static boolean isRedirect(WebResourceRequest request)

Gets whether the request was a result of a server-side redirect.

This method should only be called if WebViewFeature.isFeatureSupported(String) returns true for WebViewFeature.WEB_RESOURCE_REQUEST_IS_REDIRECT.

Returns:

whether the request was a result of a server-side redirect.

Source

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.webkit;

import android.webkit.WebResourceRequest;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.webkit.internal.ApiFeature;
import androidx.webkit.internal.ApiHelperForN;
import androidx.webkit.internal.WebResourceRequestAdapter;
import androidx.webkit.internal.WebViewFeatureInternal;
import androidx.webkit.internal.WebViewGlueCommunicator;

/**
 * Compatibility version of {@link WebResourceRequest}.
 */
public class WebResourceRequestCompat {

    // Developers should not be able to instantiate this class.
    private WebResourceRequestCompat() {}

    /**
     * Gets whether the request was a result of a server-side redirect.
     *
     * <p>
     * This method should only be called if
     * {@link WebViewFeature#isFeatureSupported(String)}
     * returns true for {@link WebViewFeature#WEB_RESOURCE_REQUEST_IS_REDIRECT}.
     *
     * @return whether the request was a result of a server-side redirect.
     */
    @RequiresFeature(name = WebViewFeature.WEB_RESOURCE_REQUEST_IS_REDIRECT,
            enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
    public static boolean isRedirect(@NonNull WebResourceRequest request) {
        ApiFeature.N feature = WebViewFeatureInternal.WEB_RESOURCE_REQUEST_IS_REDIRECT;
        if (feature.isSupportedByFramework()) {
            return ApiHelperForN.isRedirect(request);
        } else if (feature.isSupportedByWebView()) {
            return getAdapter(request).isRedirect();
        } else {
            throw WebViewFeatureInternal.getUnsupportedOperationException();
        }
    }

    private static WebResourceRequestAdapter getAdapter(WebResourceRequest request) {
        return WebViewGlueCommunicator.getCompatConverter().convertWebResourceRequest(request);
    }
}