List of usage examples for android.webkit WebView WebView
public WebView(Context context)
From source file:com.twtstudio.bbs.bdpqchen.bbs.mdeditor.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; // setOrientation(VERTICAL); if (VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }/*w w w .ja va2 s. co m*/ this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); // this.mWebView.loadUrl("file:///android_asset/markdown.html"); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:com.robopupu.feature.about.view.LicensesInfoFragment.java
@Override protected void onCreateBindings() { super.onCreateBindings(); webView = new WebView(getActivity()); webViewRelativeLayout = getView(R.id.relative_layout_web_view); webViewClient = new DelegatedWebViewClient(presenter); webView.setWebViewClient(webViewClient); final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); webViewRelativeLayout.addView(webView, params); new ClickBinding(this, R.id.button_ok) { @Override/* w w w. j ava 2s . c o m*/ protected void clicked() { // REMOVE presenter.onOkButtonClick(); } }; }
From source file:de.schildbach.litecoinwallet.ui.HelpDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final String page = args.getString(KEY_PAGE); final WebView webView = new WebView(activity); webView.loadUrl("file:///android_asset/" + page + languagePrefix() + ".html"); final Dialog dialog = new Dialog(activity); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(webView);/*from w w w . ja va 2s. co m*/ dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:com.zion.htf.ui.InfoDetailsActivity.java
@Override public void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); this.context = this; String resourceName = this.getIntent().getStringExtra(InfoDetailsActivity.name); if (null == resourceName) { throw new RuntimeException("This requires a 'name' parameter in its starting intent."); }/*from www. j ava 2 s .com*/ this.setTitle(this.getString(this.getResources().getIdentifier(resourceName, "string", "com.zion.htf"))); this.webView = new WebView(this); this.webView.loadDataWithBaseURL("file:///android_res/raw/", this.readTextFromResource(resourceName), "text/html", "utf-8", null); this.webView.setBackgroundColor(0x00000000); if ("info_about".equals(resourceName) || "info_open_source".equals(resourceName)) this.webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.v(InfoDetailsActivity.TAG, url); boolean ret = false; if (url.contains("github.com/nstCactus")) { InfoDetailsActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/nstCactus/Hadra-Trance-Festival"))); ret = true; } else if (url.contains("donate.me")) { InfoDetailsActivity.this .startActivity(new Intent(InfoDetailsActivity.this, DonateActivity.class)); ret = true; } else if (url.contains("mailto:")) { Log.v(url, url); InfoDetailsActivity.this.startActivity(new Intent(Intent.ACTION_SENDTO, Uri.parse(url))); ret = true; } return ret; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { Log.v(InfoDetailsActivity.TAG, "onPageStarted called"); if (shouldOverrideUrlLoading(view, url)) { view.stopLoading(); } } }); this.setContentView(this.webView); }
From source file:com.gc.markdown.widget.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; // setOrientation(VERTICAL); if (VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }/* w ww. j ava2s. c o m*/ this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); loadUrl(); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:com.barcamppenang2014.tabfragment.Agenda.java
/** * Called to instantiate the view. Creates and returns the WebView. *//*from w w w. j ava2 s. com*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mWebView != null) { mWebView.destroy(); } mWebView = new WebView(getActivity()); mWebView.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) { mWebView.goBack(); return true; } return false; } }); mWebView.setWebViewClient(new InnerWebViewClient()); // forces it to // open in app // mUrl = "file:///android_asset/agenda/about.html"; // mUrl = this.getActivity().getFilesDir()+"/agenda.html"; // mUrl = "file:///data/about.html"; // mWebView.loadUrl("http://barcamppenang.org/agenda.html"); // mWebView.loadUrl("http://barcamppenang.org/schedule/"); mWebView.loadData(readFromFile("leaderboard.php"), "text/html", "utf-8"); // Log.d("ddw", "outside!!"); mIsWebViewAvailable = true; WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); // if (isNetworkAvailable() == true){ // settings.setCacheMode(WebSettings.LOAD_NO_CACHE); // } // else{ // settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY); // } return mWebView; }
From source file:com.barcamppenang2013.tabfragment.AgendaFragment.java
/** * Called to instantiate the view. Creates and returns the WebView. *//*from w w w . j ava 2 s. co m*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mWebView != null) { mWebView.destroy(); } mWebView = new WebView(getActivity()); mWebView.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) { mWebView.goBack(); return true; } return false; } }); mWebView.setWebViewClient(new InnerWebViewClient()); // forces it to // open in app // mUrl = "file:///android_asset/agenda/about.html"; // mUrl = this.getActivity().getFilesDir()+"/agenda.html"; // mUrl = "file:///data/about.html"; // mWebView.loadUrl("http://barcamppenang.org/agenda.html"); // mWebView.loadUrl("http://barcamppenang.org/schedule/"); mWebView.loadData(readFromFile("agenda.html"), "text/html", "utf-8"); // Log.d("ddw", "outside!!"); mIsWebViewAvailable = true; WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); // if (isNetworkAvailable() == true){ // settings.setCacheMode(WebSettings.LOAD_NO_CACHE); // } // else{ // settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY); // } return mWebView; }
From source file:org.catnut.fragment.OAuthFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set actionbar mActionBar = getActivity().getActionBar(); setHasOptionsMenu(true);/*ww w . j a v a2 s . c o m*/ // set the auth webview mWebView = new WebView(getActivity()); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mWebView.setLayoutParams(params); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!url.startsWith(Manifest.AUTH_REDIRECT_URI)) { return false; } String code = Uri.parse(url).getQueryParameter("code"); Log.d(TAG, "the auth code is " + code); String accessTokenUri = Manifest.getAccessTokenUri(code); mProgressDialog = ProgressDialog.show(getActivity(), null, getString(R.string.authing_hint), true, false); mRequestQueue.add(new JsonObjectRequest(Request.Method.POST, accessTokenUri, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.i(TAG, "auth success with result: " + response.toString()); mApp.saveAccessToken(response); Toast.makeText(getActivity(), getString(R.string.auth_success), Toast.LENGTH_SHORT) .show(); // fetch user' s profile mRequestQueue.add( new CatnutRequest(getActivity(), UserAPI.profile(mApp.getAccessToken().uid), new UserProcessor.UserProfileProcessor(), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { mProgressDialog.dismiss(); mApp.getPreferences().edit() .putString(User.screen_name, response.optString(User.screen_name)) .commit(); Intent intent = new Intent(getActivity(), MainActivity.class); startActivity(intent); } }, null // should not happen! )); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.wtf(TAG, "auth fail!", error); WeiboAPIError e = WeiboAPIError.fromVolleyError(error); new AlertDialog.Builder(getActivity()) .setMessage(getString(R.string.auth_fail_with_reason, e.error)) .setNegativeButton(android.R.string.ok, null).show(); } })).setTag(TAG); return true; } }); }
From source file:com.tsy.leanote.widget.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; // setOrientation(VERTICAL); if (VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }/* ww w . j av a 2 s. co m*/ this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); this.mWebView.loadUrl("file:///android_asset/markdown.html"); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:com.paypal.example.android.ppaccess.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webView = new WebView(this); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new PPWebViewClient()); setContentView(webView);//from ww w .jav a2s . c o m helper = AccessHelperConnect.init(CLIENT_ID, CLIENT_SECRET); progress = ProgressDialog.show(LoginActivity.this, getString(R.string.progress_loading_title), getString(R.string.progress_loading_msg)); webView.loadUrl(helper.getAuthUrl()); }