List of usage examples for android.webkit WebViewClient WebViewClient
WebViewClient
From source file:stack.com.stackapi.ui.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.auth_dialog); progressWheel = (ProgressWheel) findViewById(R.id.progress_wheel); progressWheel.stopSpinning();/*ww w .j a v a 2 s .c o m*/ if (AppConstants.isInternetAvailable(this)) { web = (WebView) findViewById(R.id.webv); web.getSettings().setJavaScriptEnabled(true); web.loadUrl(OAUTH_URL + "?redirect_uri=" + REDIRECT_URI + "&client_id=" + CLIENT_ID); web.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); progressWheel.spin(); } String authCode; @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (url.contains("access_token=")) { getAccessToken(url); String strAccessToken = AppConstants.readPreferences(LoginActivity.this, "AcessToken", "0"); Log.d("Acess Token", strAccessToken); if (!strAccessToken.equals("0")) { Toast.makeText(getApplicationContext(), "Authenticated Successfully", Toast.LENGTH_SHORT).show(); progressWheel.stopSpinning(); Intent intent = new Intent(LoginActivity.this, StackBaseActivity.class); intent.putExtra("Profile", "Create"); startActivity(intent); finish(); } } else if (url.contains("error=access_denied")) { Toast.makeText(getApplicationContext(), "Error Occured", Toast.LENGTH_SHORT).show(); progressWheel.stopSpinning(); } else { progressWheel.stopSpinning(); } } }); } else { Toast.makeText(this, getString(R.string.internet), Toast.LENGTH_SHORT).show(); } }
From source file:jupiter.broadcasting.live.holo.ShowNotesView.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle b = getArguments();//from w ww.java 2 s .c om link = b.getString("Notes"); v = inflater.inflate(R.layout.shownotes_fragment, null); wv = (WebView) v.findViewById(R.id.notesview); loadingProgressBar = (ProgressBar) v.findViewById(R.id.progressbar_Horizontal); wv.getSettings().setJavaScriptEnabled(true); wv.setVisibility(View.INVISIBLE); wv.setWebChromeClient(new WebChromeClient() { // this will be called on page loading progress @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); loadingProgressBar.setProgress(newProgress); // hide the progress bar if the loading is complete if (newProgress == 100) { loadingProgressBar.setVisibility(View.GONE); } else { loadingProgressBar.setVisibility(View.VISIBLE); } } }); wv.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { wv.loadUrl("javascript:(function() {var mon = document.getElementsByTagName('div');" + "for (var i = 0; i < mon.length; i++) {" + "if (mon[i].id == 'footer'){mon[i].style.display = 'none';}" + "if (mon[i].id == 'header'){mon[i].style.display = 'none';}" + "if (mon[i].id == 'thevideo'){mon[i].style.display = 'none';}" + "if (mon[i].id == 'sidebar'){mon[i].style.display = 'none';}" + "if (mon[i].id == 'menubar'){mon[i].style.display = 'none';}" + "if (mon[i].id == 'videodets'){mon[i].style.display = 'none';}" + "if (mon[i].id == 'postcomments'){mon[i].style.display = 'none';}" + "}})()"); wv.loadUrl("javascript: window.CallToAnAndroidFunction.setVisible()"); } }); wv.addJavascriptInterface(new myJavaScriptInterface(), "CallToAnAndroidFunction"); wv.loadUrl(link); return v; }
From source file:com.microsoft.azure.engagement.fragment.FeaturesFragment.java
@SuppressLint("SetJavaScriptEnabled") @Nullable/*from ww w.java2s . co m*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_features, container, false); progressBar = view.findViewById(R.id.progressBar); errorContainer = view.findViewById(R.id.errorContainer); retryButton = view.findViewById(R.id.retryButton); retryButton.setOnClickListener(this); webView = (WebView) view.findViewById(R.id.webView); webView.setWebViewClient(new WebViewClient() { @TargetApi(android.os.Build.VERSION_CODES.M) @Override public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError err) { onReceivedError(view, err.getErrorCode(), err.getDescription().toString(), req.getUrl().toString()); } @SuppressWarnings("deprecation") @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { webViewError = true; } @Override public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { super.onReceivedHttpError(view, request, errorResponse); webViewError = true; } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); progressBar.setVisibility(View.GONE); webView.setVisibility(webViewError ? View.GONE : View.VISIBLE); errorContainer.setVisibility(webViewError ? View.VISIBLE : View.GONE); } }); webView.getSettings().setJavaScriptEnabled(true); displayLoadingView(); webView.loadUrl(getString(R.string.drawer_features_url)); AzmeTracker.startActivity(getActivity(), "features"); return view; }
From source file:me.jvdv.bancwear.MainActivity.java
protected void blaat(final String x) { mWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { mWebView.loadUrl("javascript:(function(){" + "document.getElementById('Id').innerHTML='" + x + "';" + "})()"); }/* w w w . j av a 2 s.com*/ }); }
From source file:io.vit.vitio.Fragments.CampusMapFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.campusmap_fragment, container, false); setTransitions();/*ww w. ja v a 2 s .c om*/ WebView view = (WebView) rootView.findViewById(R.id.img_map); view.setVisibility(View.GONE); view.getSettings().setBuiltInZoomControls(true); view.getSettings().setDisplayZoomControls(false); view.getSettings().setLoadWithOverviewMode(true); view.getSettings().setUseWideViewPort(true); view.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); try { view.setVisibility(View.VISIBLE); } catch (Exception ignore) { } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { try { } catch (Exception ignore) { } } }); view.loadUrl("file:///android_asset/vit_map.jpg"); return rootView; }
From source file:com.chatwing.whitelabel.fragments.ProfileInfoFragment.java
private void configWebView(WebView webView) { WebSettings webSettings = webView.getSettings(); webSettings.setAppCacheEnabled(false); webSettings.setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient()); }
From source file:com.anxpp.blog.fragment.WebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from w w w . j a v a 2 s .c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.webview, container, false); final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress); viewContentWebView = (WebView) v.findViewById(R.id.webview); viewContentWebView.getSettings().setJavaScriptEnabled(true); viewContentWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return super.shouldOverrideUrlLoading(view, url); } }); viewContentWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { viewContentProgress.setProgress(newProgress); viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE); if (newProgress == 100 && resetHistory) { viewContentWebView.clearHistory(); resetHistory = false; } } }); return v; }
From source file:de.madvertise.android.sdk.MadvertiseImageView.java
public MadvertiseImageView(final Context context, final int newWidth, final int newHeight, final MadvertiseAd ad, final Handler loadingCompletedHandler, final AnimationEndListener animationListener) { super(context); mAnimationListener = animationListener; mImageAd = ad;/* w w w. j a v a 2 s . co m*/ // Remove the ScrollBar so that we have no padding. setVerticalScrollBarEnabled(false); setHorizontalScrollBarEnabled(false); setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); // No visible background setBackgroundColor(Color.TRANSPARENT); WebViewClient webViewClient = new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { if (loadingCompletedHandler != null) { loadingCompletedHandler.sendEmptyMessage(MadvertiseView.MAKE_VISIBLE); } } }; setWebViewClient(webViewClient); StringBuilder content = new StringBuilder(); content.append("<html><head><style>* {margin:0;padding:0;}</style></head><body>") .append("<img src=\"" + mImageAd.getBannerUrl() + "\" height=\"" + newHeight + "\" width=\"" + newWidth + "\"/>" + getImpressionTrackingTag()) .append("</body></html>"); MadvertiseUtil.logMessage(null, Log.DEBUG, "Loading ad : " + content.toString()); loadDataWithBaseURL(null, content.toString(), "text/html", "UTF-8", null); }
From source file:com.balch.mocktrade.YourContentHereFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TradeApplication tradeApplication = TradeApplication.getInstance(); tradeApplication.getActivity().showProgress(); View view = inflater.inflate(R.layout.your_content_here_view, container, false); this.webView = (WebView) view.findViewById(R.id.content_here_webview); this.webView.setWebViewClient(new WebViewClient() { @Override/*w w w . j a v a 2 s . c o m*/ public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false; } @Override public void onPageFinished(WebView view, String url) { TradeApplication tradeApplication = TradeApplication.getInstance(); tradeApplication.getActivity().hideProgress(); } }); this.webView.loadUrl(this.getArguments().getString(ARG_URL)); return view; }
From source file:com.autoparts.buyers.action_content.fragment.WebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override// www .ja v a 2s .c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.webview_fragment, container, false); final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress); viewContentWebView = (WebView) v.findViewById(R.id.webview); viewContentWebView.getSettings().setJavaScriptEnabled(true); viewContentWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return super.shouldOverrideUrlLoading(view, url); } }); viewContentWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { viewContentProgress.setProgress(newProgress); viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE); if (newProgress == 100 && resetHistory) { viewContentWebView.clearHistory(); resetHistory = false; } } }); return v; }