List of usage examples for android.webkit WebView setWebViewClient
public void setWebViewClient(WebViewClient client)
From source file:io.github.hidroh.materialistic.OfflineWebActivity.java
@SuppressWarnings("ConstantConditions") @Override/* w w w . j a v a 2 s . co m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String url = getIntent().getStringExtra(EXTRA_URL); if (TextUtils.isEmpty(url)) { finish(); return; } setTitle(url); setContentView(R.layout.activity_offline_web); final NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.nested_scroll_view); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setOnClickListener(v -> scrollView.smoothScrollTo(0, 0)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayOptions( ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE); getSupportActionBar().setSubtitle(R.string.offline); final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress); final WebView webView = (WebView) findViewById(R.id.web_view); webView.setBackgroundColor(Color.TRANSPARENT); webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this)) { @Override public void onPageFinished(WebView view, String url) { setTitle(view.getTitle()); } }); webView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); if (newProgress == 100) { progressBar.setVisibility(View.GONE); webView.setBackgroundColor(Color.WHITE); webView.setVisibility(View.VISIBLE); } } }); AppUtils.toggleWebViewZoom(webView.getSettings(), true); webView.loadUrl(url); }
From source file:com.microsoft.azure.engagement.fragment.AboutFragment.java
@Nullable @Override//from w ww . j a v a 2s . c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_about, container, false); final WebView webView = (WebView) view.findViewById(R.id.webView); webView.loadUrl("file:///android_asset/html/about.html"); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { final String eventName; switch (url) { case "file:///android_asset/html/smartnsoft": eventName = null; url = getString(R.string.smartnsoft_url); break; case "file:///android_asset/html/github": eventName = "click_source_link"; url = getString(R.string.github_url); break; case "file:///android_asset/html/application_license": eventName = "click_application_license_link"; url = getString(R.string.application_license_url); break; case "file:///android_asset/html/third_party_notices": eventName = "click_3rd_party_notices_link"; url = getString(R.string.third_party_notices_url); break; default: eventName = null; break; } Log.d(AboutFragment.TAG, "String url clicked on: " + url); CustomTabActivityHelper.openCustomTab(getActivity(), Uri.parse(url), eventName, null, null); return true; } }); AzmeTracker.startActivity(getActivity(), "about"); return view; }
From source file:jp.mydns.sys1yagi.android.printingframeworksample.html.HtmlPrintActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_html_print); final WebView webView = (WebView) findViewById(R.id.webview); webView.getSettings().setSupportZoom(true); webView.getSettings().setBuiltInZoomControls(true); webView.setWebViewClient(new WebViewClient() { @Override// w w w . jav a 2 s . c o m public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } }); webView.loadUrl("http://visible-true.blogspot.jp/"); findViewById(R.id.print_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { printHtml(webView.getTitle() + ".pdf", webView); } }); }
From source file:com.example.health_connect.MySampleFragment3.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.sample_fragment3, container, false); Parse.initialize(mView.getContext(), "e0FVFRBMAWJi5shg4XF8zL3SIuRwDIufww3338so", "toTJmlHTEF43u7PoAFT4fedwqfhoWiSajj1Se7FT"); ParseUser currentUser = ParseUser.getCurrentUser(); Log.d("Check", currentUser.getObjectId()); ImageView birthdaypic = (ImageView) mView.findViewById(R.id.imageView2); TextView wish = (TextView) mView.findViewById(R.id.textView23); TextView hbday = (TextView) mView.findViewById(R.id.textView24); WebView webview = (WebView) mView.findViewById(R.id.pic); webview.setWebViewClient(new WebViewClient() { @Override/* w w w . j a v a2s . com*/ public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.i("WEB_VIEW_TEST", "error code: " + errorCode + " " + description); super.onReceivedError(view, errorCode, description, failingUrl); } }); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setDomStorageEnabled(true); String u_r_l; if (currentUser.getString("image_flag").equalsIgnoreCase("1")) { u_r_l = "http://cdn.filter.to/100x100/http://s3-ap-southeast-1.amazonaws.com/hconnect/" + currentUser.getObjectId(); } else { u_r_l = "http://cdn.filter.to/100x100/cdn1.iconfinder.com/data/icons/PRACTIKA/256/user.png"; } webview.loadUrl(u_r_l); String date_of_birth = currentUser.getString("Dob"); Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); String formattedDate = df.format(c.getTime()); //Log.d("Check",formattedDate); String str[] = { "Every patient carries her or his own doctor inside.", "Laughter is the best medicine", "The art of medicine consists in amusing the patient while nature cures the disease.", "Health is wealth", "My health is good,it's my age that's bad.", "A healthy body is a guest-chamber for the soul; a sick body is a prison.", "Fitness:If it came in a bottle,everybody would have a good body.", "Ypu don't get ulcers form what you eat,but from what's eating you.", "Those who don't find time for exercise will have to find time for illness.", "Sickness comes on horseback and departs on foot.", "Health and appetite impart the sweetness to sugar,bread and meat.", "Health is not valued till sickness comes.", "Health is not simply the absence of sickness.", "To eat is a necessity,but to eat intelligently is an art.", "Let food be the medicine,thy medicine shall be thy food.", "Food is fuel,choose wisely.", "Health and intellect are the two blessings of life.", "The greatest wealth is health.", "Think positive and focus on gratitude.", "Get a good night's sleep.", "Use food over supplements.", "Eat 5 servings of fruits and veggies a day.", "Big idea: Be happy :)", "Drink water instead of surgery drinks.", "Swap big serves for smaller ones.", "Park the car and walk the rest of the way.", "No disease that can be treated by diet should be treated with any other means.", "Your body hears everything your mind says/", "Take care of your body. It's the only place you have to live.", "Every human being is the author of his own health or disease." }; Random r = new Random(); int High = 30; // 30 excluded int Low = 0; int random_number = r.nextInt(High - Low) + Low; if ((formattedDate.substring(0, 2).equalsIgnoreCase(date_of_birth.substring(0, 2))) && (formattedDate.substring(3, 5).equalsIgnoreCase(date_of_birth.substring(3, 5)))) // if(d1==d2 && m1==m2) { } else { // Log.d("Check", d1); birthdaypic.setImageDrawable(null); wish.setText(null); hbday.setText(null); wish.setText(str[random_number]); //wish.setVisibility(View.GONE); hbday.setVisibility(View.GONE); } TextView a_name = (TextView) mView.findViewById(R.id.pdob); TextView a_eid = (TextView) mView.findViewById(R.id.textView8); TextView a_add = (TextView) mView.findViewById(R.id.textView10); TextView a_dob = (TextView) mView.findViewById(R.id.textView12); TextView a_lno = (TextView) mView.findViewById(R.id.textView14); TextView a_year = (TextView) mView.findViewById(R.id.textView16); TextView a_mschool = (TextView) mView.findViewById(R.id.textView18); TextView a_spec = (TextView) mView.findViewById(R.id.textView20); TextView a_deg = (TextView) mView.findViewById(R.id.textView22); a_name.setText(currentUser.getUsername()); a_deg.setText(currentUser.getString("Degree")); a_dob.setText(currentUser.getString("Dob")); a_spec.setText(currentUser.getString("Primary_speciality")); a_mschool.setText(currentUser.getString("Medical_School")); a_add.setText(currentUser.getString("Address")); a_year.setText(currentUser.getString("Start_Practice")); a_eid.setText(currentUser.getEmail()); a_lno.setText(currentUser.getString("LicenseNo")); return mView; }
From source file:org.quizreader.android.PageReadActivity.java
/** Called when the activity is first created. */ @SuppressLint("SetJavaScriptEnabled") @Override/* w w w. ja v a2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.page_read); // immediately pop up loading dialog dialog = new ProgressDialog(this); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setMessage("loading page"); dialog.show(); // set up webview WebView webview = (WebView) findViewById(R.id.webView); webview.setWebViewClient(new QRWebViewClient()); webview.setWebChromeClient(new WebChromeClient() { public boolean onConsoleMessage(ConsoleMessage cm) { Log.d("QuizReader", cm.message() + ", line " + cm.lineNumber() + " " + cm.sourceId()); return true; } }); WebSettings webSettings = webview.getSettings(); webSettings.setJavaScriptEnabled(true); webview.addJavascriptInterface(new QuizReaderInterface(), "qr"); try { random = new Random(); wordDao = new WordDao(this); qzzFile = new QzzFile(title.getFilepath(), this); URL htmlURL = qzzFile.getHTML(title.getId(), title.getSection()); if (htmlURL == null) { // beyond the last section setResult(RESULT_END_TITLE); finish(); } String externalForm = htmlURL.toExternalForm(); webview.loadUrl(externalForm + "?paragraph=" + title.getParagraph()); } catch (Exception ex) { webview.loadData(ex.toString(), "text/plain", null); } }
From source file:com.salesforce.marketingcloud.android.demoapp.ui.OriginalDocsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); WebView markdownView = (WebView) findViewById(R.id.markdownView); markdownView.getSettings().setJavaScriptEnabled(true); markdownView.loadUrl(getResources().getString(R.string.official_remote_url)); markdownView.setWebViewClient(new WebViewClient() { @Override/*from ww w . ja v a 2 s. c o m*/ public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false; } }); MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() { @Override public void ready(MarketingCloudSdk marketingCloudSdk) { marketingCloudSdk.getAnalyticsManager().trackPageView("data://OriginalDocsActivity", getResources().getString(R.string.official_remote_url), null, null); } }); }
From source file:meizhi.meizhi.malin.utils.DestroyCleanUtil.java
@SuppressLint("ObsoleteSdkInt") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void unBindView(View view) { if (view == null) return;//from w w w . j a va 2 s. c o m Drawable drawable; int i; //1. try { view.setOnClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //2. try { view.setOnCreateContextMenuListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //3. try { view.setOnFocusChangeListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //4. try { view.setOnKeyListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //5. try { view.setOnLongClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //6. try { view.setOnTouchListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //7. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { view.setOnApplyWindowInsetsListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //8. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.setOnContextClickListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //9. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.setOnScrollChangeListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //10. try { view.setOnDragListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //11. try { view.setOnGenericMotionListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //12. try { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {//13 view.setOnHoverListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //13. try { view.setOnSystemUiVisibilityChangeListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } /** * @see SwipeRefreshLayout#onDetachedFromWindow() */ if (view.getBackground() != null && !view.getClass().getName().equals(CIRCLE_CLASS)) { try { view.getBackground().setCallback(null); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {//16 view.setBackgroundDrawable(null); } else { view.setBackground(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ImageView if (view instanceof ImageView) { try { ImageView imageView = (ImageView) view; drawable = imageView.getDrawable(); if (drawable != null) { drawable.setCallback(null); } imageView.setImageDrawable(null); imageView.setImageBitmap(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //TextView if (view instanceof TextView) { try { TextView textView = (TextView) view; textView.setCompoundDrawables(null, null, null, null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { textView.setCompoundDrawablesRelative(null, null, null, null); } textView.setCursorVisible(false); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ImageButton if (view instanceof ImageButton) { try { ImageButton imageButton = (ImageButton) view; drawable = imageButton.getDrawable(); if (drawable != null) { drawable.setCallback(null); } imageButton.setImageDrawable(null); imageButton.setImageBitmap(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ListView if (view instanceof ListView) { ListView listView = (ListView) view; try { listView.setAdapter(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnScrollListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemLongClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemSelectedListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //RecyclerView if (view instanceof RecyclerView) { try { RecyclerView recyclerView = (RecyclerView) view; recyclerView.setAdapter(null); recyclerView.setChildDrawingOrderCallback(null); recyclerView.setOnScrollListener(null); recyclerView.addOnScrollListener(null); recyclerView.removeOnScrollListener(null); recyclerView.setRecyclerListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //WebView if (view instanceof WebView) { WebView webView = (WebView) view; try { webView.stopLoading(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.removeAllViews(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.setWebChromeClient(null); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.setWebViewClient(null); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.destroy(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { if (null != view.getParent() && view.getParent() instanceof ViewGroup) { ((ViewGroup) view.getParent()).removeView(view); } } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } } //SurfaceView if (view instanceof SurfaceView) { try { SurfaceView surfaceView = (SurfaceView) view; SurfaceHolder holder = surfaceView.getHolder(); if (holder != null) { Surface surface = holder.getSurface(); if (surface != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { surface.release(); } } } } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } } view.destroyDrawingCache(); view.clearAnimation(); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; int childCount = (viewGroup).getChildCount(); for (i = 0; i < childCount; i++) { unBindView((viewGroup).getChildAt(i)); } } }
From source file:com.tomeokin.lspush.biz.home.CollectionWebViewActivity.java
@Override protected void onPrepareWebView(WebView webView) { super.onPrepareWebView(webView); webView.setWebViewClient(new WebViewClient() { @Override//from w w w . j a v a2 s .c o m public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { return false; // let the web view handle the url } @Override public void onPageFinished(WebView view, String url) { boolean canGoBack = view.canGoBack(); mBottomBar.backButton.setEnabled(canGoBack); mBottomBar.backButton .setImageResource(canGoBack ? R.drawable.ic_action_back_deep : R.drawable.ic_action_back); boolean canGoForward = view.canGoForward(); mBottomBar.forwardButton.setEnabled(canGoForward); mBottomBar.forwardButton.setImageResource( canGoForward ? R.drawable.ic_action_forward_deep : R.drawable.ic_action_forward); } }); }
From source file:com.battlelancer.seriesguide.getglueapi.GetGlueAuthActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_webview); setupActionBar();/* www . ja v a 2 s . co m*/ WebView webview = (WebView) findViewById(R.id.webView); final FragmentActivity activity = this; webview.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast.makeText(activity, getString(R.string.getglue_authfailed) + " " + description, Toast.LENGTH_LONG).show(); finish(); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith(GetGlueCheckin.OAUTH_CALLBACK_URL)) { Uri uri = Uri.parse(url); new RetrieveAccessTokenTask(getApplicationContext()).execute(uri); finish(); return true; } return false; } }); // mWebview.getSettings().setJavaScriptEnabled(true); // make sure we start fresh webview.clearCache(true); Timber.d("Initiating authorization request..."); Resources res = getResources(); try { OAuthClientRequest request = com.uwetrottmann.getglue.GetGlue .getAuthorizationRequest(BuildConfig.TVTAG_CLIENT_ID, GetGlueCheckin.OAUTH_CALLBACK_URL); webview.loadUrl(request.getLocationUri()); } catch (OAuthSystemException e) { Timber.e(e, "Auth request failed"); } }
From source file:it.gaiacri.mobile.AboutAttivita.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout v = (LinearLayout) inflater.inflate(R.layout.activity_about, container, false); ((TextView) v.findViewById(R.id.about_title)).setText("Gaia Mobile v " + getString(R.string.app_version)); GaiaGoogleAnalytics.notifyScreen(getActivity().getApplicationContext(), "About"); //licenza/*from w w w .j a v a 2 s. c o m*/ ((TextView) v.findViewById(R.id.about_licenza)) .setText(Html.fromHtml("Questa applicazione rilasciata con licenza <a href=\"\">GPL v3</a>")); ((TextView) v.findViewById(R.id.about_licenza)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(AboutAttivita.this.getActivity()); WebView wv = new WebView(AboutAttivita.this.getActivity()); wv.loadUrl("https://raw.githubusercontent.com/CroceRossaItaliana/gaia-android/master/LICENSE.txt"); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); alert.setView(wv); alert.setNegativeButton("Chiudi", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alert.show(); } }); //portale gaia ((TextView) v.findViewById(R.id.about_portale_gaia)) .setText(Html.fromHtml("<a href=\"\">Portale Gaia</a>")); ((TextView) v.findViewById(R.id.about_portale_gaia)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Internet("https://gaia.cri.it"); } }); //informazioni gaia ((TextView) v.findViewById(R.id.about_gaia)).setText(Html.fromHtml("<a href=\"\">Informazioni GAIA</a>")); ((TextView) v.findViewById(R.id.about_gaia)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Internet("https://gaia.cri.it/?p=public.about"); } }); //portale sviluppo mobile ((TextView) v.findViewById(R.id.about_gaia_mobile)) .setText(Html.fromHtml("<a href=\"\">Codice Sorgente Gaia Mobile</a>")); ((TextView) v.findViewById(R.id.about_gaia_mobile)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Internet("https://github.com/CroceRossaItaliana/gaia-android"); } }); //infomrazione dati ((TextView) v.findViewById(R.id.about_gaia_privacy)) .setText(Html.fromHtml("<a href=\"\">Informazioni Gestione Dati</a>")); ((TextView) v.findViewById(R.id.about_gaia_privacy)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Internet("https://gaia.cri.it/?p=public.privacy"); } }); //((WebView)v.findViewById(R.id.about_info))//.setClickable(true);; return v; }