List of usage examples for android.webkit WebView stopLoading
public void stopLoading()
From source file:com.benefit.buy.library.http.query.AbstractAQuery.java
/** * Clear a view. Applies to ImageView, WebView, and TextView. * @return self/* ww w .j a v a2 s. co m*/ */ public T clear() { if (view != null) { if (view instanceof ImageView) { ImageView iv = ((ImageView) view); iv.setImageBitmap(null); iv.setTag(Constants.TAG_URL, null); } else if (view instanceof WebView) { WebView wv = ((WebView) view); wv.stopLoading(); wv.clearView(); wv.setTag(Constants.TAG_URL, null); } else if (view instanceof TextView) { TextView tv = ((TextView) view); tv.setText(""); } } return self(); }
From source file:com.androidquery.AQuery.java
/** * Clear a view. Applies to ImageView, WebView, and TextView. * * @return self/*from www. j ava 2 s . c o m*/ */ public AQuery clear() { if (view != null) { if (view instanceof ImageView) { ImageView iv = ((ImageView) view); iv.setImageBitmap(null); iv.setTag(AQuery.TAG_URL, null); } else if (view instanceof WebView) { WebView wv = ((WebView) view); wv.stopLoading(); wv.clearView(); wv.setTag(AQuery.TAG_URL, null); } else if (view instanceof TextView) { TextView tv = ((TextView) view); tv.setText(""); } } return self(); }
From source file:com.androidquery.AbstractAQuery.java
/** * Clear a view. Applies to ImageView, WebView, and TextView. * * @return self//w ww. j a v a2 s .co m */ public T clear() { if (view != null) { if (view instanceof ImageView) { ImageView iv = ((ImageView) view); iv.setImageBitmap(null); iv.setTag(AQuery.TAG_URL, null); } else if (view instanceof WebView) { WebView wv = ((WebView) view); wv.stopLoading(); wv.clearView(); wv.setTag(AQuery.TAG_URL, null); } else if (view instanceof TextView) { TextView tv = ((TextView) view); tv.setText(""); } } return self(); }
From source file:nya.miku.wishmaster.http.cloudflare.CloudflareChecker.java
private Cookie checkAntiDDOS(final CloudflareException exception, final HttpHost proxy, CancellableTask task, final Activity activity) { synchronized (lock) { if (processing) return null; processing = true;/*from w w w . j a va2 s. c o m*/ } processing2 = true; currentCookie = null; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { CookieSyncManager.createInstance(activity); CookieManager.getInstance().removeAllCookie(); } else { CompatibilityImpl.clearCookies(CookieManager.getInstance()); } final ViewGroup layout = (ViewGroup) activity.getWindow().getDecorView().getRootView(); final WebViewClient client = new WebViewClient() { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } @Override public void onPageFinished(WebView webView, String url) { super.onPageFinished(webView, url); Logger.d(TAG, "Got Page: " + url); String value = null; try { String[] cookies = CookieManager.getInstance().getCookie(url).split("[;]"); for (String cookie : cookies) { if ((cookie != null) && (!cookie.trim().equals("")) && (cookie.startsWith(" " + exception.getRequiredCookieName() + "="))) { value = cookie.substring(exception.getRequiredCookieName().length() + 2); } } } catch (NullPointerException e) { Logger.e(TAG, e); } if (value != null) { BasicClientCookieHC4 cf_cookie = new BasicClientCookieHC4(exception.getRequiredCookieName(), value); cf_cookie.setDomain("." + Uri.parse(url).getHost()); cf_cookie.setPath("/"); currentCookie = cf_cookie; Logger.d(TAG, "Cookie found: " + value); processing2 = false; } else { Logger.d(TAG, "Cookie is not found"); } } }; activity.runOnUiThread(new Runnable() { @SuppressLint("SetJavaScriptEnabled") @Override public void run() { webView = new WebView(activity); webView.setVisibility(View.GONE); layout.addView(webView); webView.setWebViewClient(client); webView.getSettings().setUserAgentString(HttpConstants.USER_AGENT_STRING); webView.getSettings().setJavaScriptEnabled(true); webViewContext = webView.getContext(); if (proxy != null) WebViewProxy.setProxy(webViewContext, proxy.getHostName(), proxy.getPort()); webView.loadUrl(exception.getCheckUrl()); } }); long startTime = System.currentTimeMillis(); while (processing2) { long time = System.currentTimeMillis() - startTime; if ((task != null && task.isCancelled()) || time > TIMEOUT) { processing2 = false; } } activity.runOnUiThread(new Runnable() { @Override public void run() { try { layout.removeView(webView); webView.stopLoading(); webView.clearCache(true); webView.destroy(); webView = null; } finally { if (proxy != null) WebViewProxy.setProxy(webViewContext, null, 0); processing = false; } } }); return currentCookie; }