Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added support for onReceivedHttpError and onReceivedError callbacks #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -5,14 +5,19 @@
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build.VERSION_CODES;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewStub;
import android.webkit.GeolocationPermissions;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
Expand Down Expand Up @@ -248,6 +253,22 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (callback != null) callback.onPageStarted(view, url, favicon);
}

@RequiresApi(api = VERSION_CODES.M)
@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse)
{
super.onReceivedHttpError(view, request, errorResponse);
if (callback != null) callback.onReceivedHttpError(view, request, errorResponse);
}

@RequiresApi(api = VERSION_CODES.M)
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
{
super.onReceivedError(view, request, error);
if (callback != null) callback.onReceivedError(view, request, error);
}

@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Expand Down Expand Up @@ -310,6 +331,10 @@ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermiss
public interface WebViewSuiteCallback {
void onPageStarted(WebView view, String url, Bitmap favicon);
void onPageFinished(WebView view, String url);
@RequiresApi(api = VERSION_CODES.M)
void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse);
@RequiresApi(api = VERSION_CODES.M)
void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error);
boolean shouldOverrideUrlLoading (WebView view, String url);
}

Expand Down