package com.marshalchen.common.commonUtils.moduleUtils;

import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.marshalchen.common.commonUtils.logUtils.Logs;

/**
 * A webview which can open itself and add some error info instead of the url
 * User: cym
 *
 *
 */

public  class SampleWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);    //To change body of overridden methods use File | Settings | File Templates.
    }
    @Override
    public void onReceivedError(WebView view, int errorCode,
                                String description, String failingUrl) {
        super.onReceivedError(view, errorCode, description, failingUrl);

        Logs.i("-MyWebViewClient->onReceivedError()--\n errorCode=" + errorCode + " \ndescription=" + description + " \nfailingUrl=" + failingUrl);

        view.loadDataWithBaseURL("","<html><body><h1>"+"Network error"+"</h1></body></html>", "text/html", "utf-8", null);

    }

}

@@ -118,16 +118,17 @@
 Client;%0A
+%0A
 import c
@@ -209,16 +209,23 @@
 an open 
+url by 
 itself a
@@ -231,11 +231,16 @@
 and 
-add
+can show
  som
@@ -251,50 +251,34 @@
 ror 
-info instead of the url%0A * User: cym%0A *%0A *
+message when receive error
 %0A */
@@ -286,17 +286,16 @@
 %0Apublic 
- 
 class Sa
@@ -336,16 +336,112 @@
 lient %7B%0A
+%0A%0A%0A    String showErrorString = %22%3Chtml%3E%3Cbody%3E%3Ch1%3E%22 + %22Network error%22 + %22%3C/h1%3E%3C/body%3E%3C/html%3E%22;%0A%0A%0A
     @Ove
@@ -773,16 +773,17 @@
 .%0A    %7D%0A
+%0A
     @Ove
@@ -1185,95 +1185,251 @@
 (%22%22,
-%22%3Chtml%3E%3Cbody%3E%3Ch1%3E%22+%22Network error%22+%22%3C/h1%3E%3C/body%3E%3C/html%3E%22, %22text/html%22, %22utf-8%22, null);%0A
+ showErrorString, %22text/html%22, %22utf-8%22, null);%0A%0A    %7D%0A%0A    public String getShowErrorString() %7B%0A        return showErrorString;%0A    %7D%0A%0A    public void setShowErrorString(String showErrorString) %7B%0A        this.showErrorString = showErrorString;
 %0A   

Update SampleWebView