Example usage for android.webkit WebViewClient WebViewClient

List of usage examples for android.webkit WebViewClient WebViewClient

Introduction

In this page you can find the example usage for android.webkit WebViewClient WebViewClient.

Prototype

WebViewClient

Source Link

Usage

From source file:com.hhs.hfnavigator.slidingtabs.tools.PortalFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();//from   ww w. ja  v  a2 s .  c  om
    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
            }
        });
        webView.loadUrl("https://harborfieldscsd.esboces.org/campus/portal/harborfields.jsp");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
    }
    return root;
}

From source file:com.hhs.hfnavigator.slidingtabs.schedules.MidRegFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();//  www .ja v a  2 s  .  c o  m
    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
            }
        });
        webView.loadUrl("https://docs.google.com/document/d/1FEFRSCql8AXKBsVoiawX9E087oaPbcQh-f-Ou4yKaIE/pub");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
    }
    return root;
}

From source file:com.prey.activities.PanelWebActivity.java

@Override
public void onResume() {
    super.onResume();
    WebSettings settings = myWebView.getSettings();
    settings.setUseWideViewPort(true);//w ww .java 2  s .  co  m
    settings.setLoadWithOverviewMode(true);
    settings.setJavaScriptEnabled(true);
    myWebView.setVerticalScrollBarEnabled(false);
    myWebView.setHorizontalScrollBarEnabled(false);
    myWebView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            activity.setTitle("Loading...");
            activity.setProgress(progress * 100);

            if (progress == 100)
                activity.setTitle(R.string.app_name);
        }

    });
    myWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            PreyLogger.d("Finished:" + url);
            super.onPageFinished(view, url);
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            PreyLogger.d("Started:" + url);
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            PreyLogger.d("OverrideUrl:" + url);
            return super.shouldOverrideUrlLoading(view, url);
        }
    });

    String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelJwt();

    String postData = "token=" + PreyConfig.getPreyConfig(getApplicationContext()).getTokenJwt();
    ;

    byte[] postByte = EncodingUtils.getBytes(postData, "BASE64");
    myWebView.postUrl(url, postByte);
}

From source file:com.hhs.hfnavigator.slidingtabs.harbinger.LiveStreamFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();//from  w  ww .ja  va2 s  . c om

    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
                webView.setVisibility(View.VISIBLE);
            }
        });
        webView.loadUrl("http://www.harbingernews.net/livestreams");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);

    }
    webView.setVisibility(View.INVISIBLE);
    return root;
}

From source file:com.todoroo.astrid.taskrabbit.TaskRabbitOAuthLoginActivity.java

@SuppressWarnings("nls")
@Override//from   w w  w.  ja va 2  s . co m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DependencyInjectionService.getInstance().inject(this);

    setContentView(R.layout.oauth_login_activity);
    getSupportActionBar().setTitle(R.string.actfm_OLA_prompt);

    final String urlParam = getIntent().getStringExtra(URL_TOKEN);

    final WebView webView = (WebView) findViewById(R.id.browser);

    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setSupportZoom(true);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            System.err.println("hey error. " + errorCode + ": " + description);
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains("?client_id=") && (url.lastIndexOf("?client_id=") != url.indexOf("?client_id="))) {
                String redirectUrl = url.substring(0, url.lastIndexOf("?client_id="));
                webView.loadUrl(redirectUrl);
                return true;
            }
            return super.shouldOverrideUrlLoading(view, url);
        }

        @Override
        public void onLoadResource(WebView view, String url) {
            super.onLoadResource(view, url);
        }

        @Override
        public void onPageFinished(WebView view, final String url) {
            super.onPageFinished(view, url);
            pd.dismiss();
            if (url.contains("access_token=")) {
                String token = url.substring(url.indexOf("access_token="), url.length());
                Intent intent = new Intent();
                intent.putExtra(DATA_RESPONSE, token);
                setResult(RESULT_OK, intent);
                finish();
            }
        }
    });

    pd = DialogUtilities.progressDialog(this, getString(R.string.DLG_wait));
    webView.loadUrl(urlParam);
}

From source file:android.kostalms.fragment.WebViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/* w w  w  . j a v  a  2 s . co  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // xml   .
    final View v = inflater.inflate(R.layout.webview, container, false);

    // viewContentProgress has a
    final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress);

    // viewContentWebView has a
    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);
        }
    });

    // WebChromeClient    .
    viewContentWebView.setWebChromeClient(new WebChromeClient() {

        //    
        @Override
        public void onProgressChanged(WebView view, int newProgress) {

            // viewContentProgress set
            viewContentProgress.setProgress(newProgress);

            // 100   .    .
            viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);

            //      url   ?
            //     .
            if (newProgress == 100 && resetHistory) {
                viewContentWebView.clearHistory();
                resetHistory = false;
            }
        }
    });
    return v;
}

From source file:com.ezac.gliderlogs.FlightEzacActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.ezac_list);/*ww w  . j  a  va 2s .  c o m*/

    // hide soft keyboard
    setMode();

    Button close = (Button) findViewById(R.id.button_close);

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://www.ezac.nl/drupal/");

    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setResult(RESULT_OK);
            finish();
        }
    });
}

From source file:com.sonymobile.androidapp.gridcomputing.fragments.WebviewFragment.java

@Override
public final void onViewCreated(final View view, final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final WebView webView = (WebView) view.findViewById(R.id.webview);
    final View progress = view.findViewById(R.id.webview_progress);

    final String researchUrl = getArguments().getString(URL_KEY);

    progress.setVisibility(View.VISIBLE);

    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.setWebViewClient(new WebViewClient() {

        @Override//w  ww. j  a v  a  2  s .  c  om
        public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            if (TextUtils.isEmpty(researchUrl) || researchUrl.equals(url)) {
                return false;
            } else {
                view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                return true;
            }
        }

        @Override
        public void onPageFinished(final WebView view, final String url) {
            progress.setVisibility(View.GONE);
        }
    });

    webView.loadUrl(researchUrl);
}

From source file:me.jvdv.bancwear.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    WebView.setWebContentsDebuggingEnabled(true);

    mWebView.setWebChromeClient(new WebChromeClient());
    mWebView.setWebViewClient(new WebViewClient());

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override//  w w  w  .  j a v a  2 s  .  com
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false);
            if (sentToken) {
                blaat(getString(R.string.gcm_send_message));
            } else {
                blaat(getString(R.string.token_error_message));
            }
        }
    };

    // Registering BroadcastReceiver
    registerReceiver();

    if (checkPlayServices()) {
        // Start IntentService to register this application with GCM.
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }
}

From source file:com.hhs.hfnavigator.slidingtabs.hhs.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();/*  w ww .  j a  v  a2  s .  c  om*/
    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
            }
        });
        webView.loadUrl("http://www.harborfieldscsd.net/our_schools/harborfields_high_school");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
    }
    return root;
}