Android WebResourceResponse - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android WebResourceResponse class.

This code example shows how to use the following methods:getData, getEncoding, getMimeType
  @Override 
  public InterceptedRequestData shouldInterceptRequest(String url) {
    if (viewClient_ != null) {
      WebResourceResponse response =
          viewClient_.shouldInterceptRequest(view_, url);
      return new InterceptedRequestData(response.getMimeType(),
          response.getEncoding(), response.getData());
    } else { 
      return null; 
    } 
  } 
  @Override 
  public void onReceivedError(int errorCode, String description,
      String failingUrl) {
    if (viewClient_ != null) {
      viewClient_.onReceivedError(view_, errorCode, description,
          failingUrl);
    } 
  }   
  @Override 
6
CodeRank
This code example shows how to use the following methods:
 
            try { 
                AssetManager assets = cordova.getActivity().getAssets();
                Uri uri = Uri.parse(niceUrl);
                InputStream stream = assets.open(uri.getPath(), AssetManager.ACCESS_STREAMING);
                WebResourceResponse response = new WebResourceResponse(mimetype, "UTF-8", stream);
                return response;
            } catch (IOException e) {
                LOG.e("generateWebResourceResponse", e.getMessage(), e);
            } 
        } 
        return null; 
    } 
     
} 
6
CodeRank
This code example shows how to use the following methods:getData, getEncoding, getMimeType
    public InterceptedRequestData shouldInterceptRequest(String url) {
        if (mWebViewClient != null) {
            WebResourceResponse response =
                    mWebViewClient.shouldInterceptRequest(mWebView, url);
            if (response != null) {
                return new InterceptedRequestData(response.getMimeType(),
                        response.getEncoding(), response.getData());
            } 
        } 
        return null; 
    } 
 
    @Override 
    public void onReceivedError(int errorCode, String description,
            String failingUrl) {
        if (mWebViewClient != null) {
            mWebViewClient.onReceivedError(mWebView, errorCode, description, failingUrl);
        } 
    } 
 
6
CodeRank
This code example shows how to use the following methods:
                || url.contains("/css/style_mobile.css")
                || url.contains("/css/portalrender.css")
                || url.contains("/css/portalrender_mobile.css")
                || url.contains("js/analytics.js")
                || url.contains("google-analytics.com/ga.js")) {
            return new WebResourceResponse("text/plain", "UTF-8", EMPTY);
        } else { 
            return super.shouldInterceptRequest(view, url);
        } 
    } 
 
    // start non-ingress-intel-urls in another app... 
    @Override 
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.contains("ingress.com") || url.contains("appengine.google.com")) {
            // reload iitc if a poslink is clicked inside the app 
            if (url.contains("intel?ll=")
                    || (url.contains("latE6") && url.contains("lngE6"))) {
                Log.d("iitcm",
                        "should be an internal clicked position link...reload script for: " 
6
CodeRank
This code example shows how to use the following methods:getData, getEncoding, getMimeType
  public InterceptedRequestData shouldInterceptRequest(String url) {
    if (viewClient_ != null) {
      WebResourceResponse response =
          viewClient_.shouldInterceptRequest(view_, url);
      if (response != null) {
        return new InterceptedRequestData(response.getMimeType(),
            response.getEncoding(), response.getData());
      } 
    } 
    return null; 
  } 
  @Override 
  public void onReceivedError(int errorCode, String description,
      String failingUrl) {
    if (viewClient_ != null) {
      viewClient_.onReceivedError(view_, errorCode, description, failingUrl);
    } 
  } 
  @Override 
  public void onFormResubmission(Message dontResend, Message resend) {
5
CodeRank
This code example shows how to use the following methods:
 
            try { 
                AssetManager assets = cordova.getActivity().getAssets();
                Uri uri = Uri.parse(niceUrl);
                InputStream stream = assets.open(uri.getPath(), AssetManager.ACCESS_STREAMING);
                WebResourceResponse response = new WebResourceResponse(mimetype, "UTF-8", stream);
                return response;
            } catch (IOException e) {
                LOG.e("generateWebResourceResponse", e.getMessage(), e);
            } 
        } 
        return null; 
    } 
     
} 
5
CodeRank
This code example shows how to use the following methods:
		 
		if (r != null) {
			WebResourceResponse response = null;
			 
			try { 
				response = new WebResourceResponse(r.getMediaType().toString(),
						r.getInputEncoding(), r.getInputStream());
			} catch (IOException e) {
				Log.i("epublib", "Problem loading resource: " + url);
			} 
			 
			return response;
		} 
		 
		return super.shouldInterceptRequest(view, url);
	} 
	 
	@Override 
	public void onPageFinished(WebView view, String url) {
		super.onPageFinished(view, url);
5
CodeRank
This code example shows how to use the following methods:
            	return getUtf8EncodedCssWebResourceResponse(ArtBookUtils.changeWidthAndHeight(BookRootLayout.this.getContext(),"book.css",width,height));
    			//return getUtf8EncodedCssWebResourceResponse(ArtBookUtils.getNativeFile(Environment.getExternalStorageDirectory() + File.separator+"book.css",width,height)); 
    		} 
             
    		 private WebResourceResponse getUtf8EncodedCssWebResourceResponse(InputStream data) {
    	        return new WebResourceResponse("text/css", "UTF-8", data);
    	     } 
 
        }); 
        Log.e("ArtBook", "display.getWidth()"+display.getWidth()+":display.getHeight()"+display.getHeight());
         
        webView.addJavascriptInterface(new PageCountJavaScriptInterface(), "artbook");
 
        webView.setHorizontalScrollBarEnabled(false);
 
        webView.loadUrl("file:///android_asset/1900-1901.html");
         
      
        this.webViewLayout.addView(webView);
        this.addView(this.webViewLayout);
4
CodeRank
This code example shows how to use the following methods:
					|| (keyString.contains("scorecardresearch"))
					|| (keyString.contains("googletagservices"))
					|| (keyString.contains("googlesynd"))
					|| (keyString.contains("adsense"))
					|| (keyString.contains("liftdna")))
				localWebResourceResponse = new WebResourceResponse("text",
						"utf-8", null); 
			return localWebResourceResponse;
		} 
 
		@Override 
		public void onPageFinished(WebView view, String url) {
 
			Handler handler = new Handler();
			handler.postDelayed(new Runnable() {
				public void run() { 
					loadingIndicator.setVisibility(View.GONE);
				} 
			}, 2000); 
			// loadingIndicator.setVisibility(View.GONE); 
3
CodeRank
This code example shows how to use the following methods:
				|| url.contains("/css/style_full.css")
				|| url.contains("/css/style_mobile.css")
				|| url.contains("/css/portalrender.css")
				|| url.contains("js/analytics.js")
				|| url.contains("google-analytics.com/ga.js")) {
			return new WebResourceResponse("text/plain", "UTF-8", empty);
		} else { 
			return super.shouldInterceptRequest(view, url);
		} 
	} 
} 
4
CodeRank

Related Android WebResourceResponse Questions & Answers:

See Code Examples for Android WebResourceResponse Methods: