List of usage examples for android.webkit URLUtil isHttpsUrl
public static boolean isHttpsUrl(String url)
From source file:Main.java
public static boolean isHttpUrl(String text) { return URLUtil.isHttpUrl(text) || URLUtil.isHttpsUrl(text); }
From source file:com.github.dfa.diaspora_android.web.WebHelper.java
public static String replaceUrlWithMarkdown(String url) { if (url != null && URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) { return "<" + url + ">"; }//from w w w . ja va 2 s .com return url; }
From source file:com.mobileacuity.android.cloudmvsdemo.Result.java
public Result(String raw, String result, float score, float cx, float cy) { this.raw = raw; this.result = result; if (URLUtil.isHttpUrl(result) || URLUtil.isHttpsUrl(result)) uri = Uri.parse(result);/*from w ww. j av a 2 s. c o m*/ this.score = score; this.cx = cx; this.cy = cy; }
From source file:com.tfc.webviewer.presenter.WebViewPresenterImpl.java
@Override public void validateUrl(final String url) { if (URLUtil.isValidUrl(url)) { mView.loadUrl(url);//w w w . j a v a2 s . co m } else { if (!TextUtils.isEmpty(url)) { String tempUrl = url; if (!URLUtil.isHttpUrl(url) && !URLUtil.isHttpsUrl(url)) { tempUrl = "http://" + url; } String host = ""; try { host = UrlUtils.getHost(tempUrl); } catch (MalformedURLException e) { mView.setToolbarUrl(mContext.getString(R.string.loading)); } if (URLUtil.isValidUrl(tempUrl)) { mView.loadUrl(tempUrl); mView.setToolbarTitle(host); } else try { tempUrl = "http://www.google.com/search?q=" + URLEncoder.encode(url, "UTF-8"); tempUrl = UrlUtils.getHost(tempUrl); mView.loadUrl(tempUrl); mView.setToolbarTitle(tempUrl); } catch (UnsupportedEncodingException e) { e.printStackTrace(); mView.showToast(makeToast(mContext.getString(R.string.message_invalid_url))); mView.close(); } catch (MalformedURLException e) { mView.setToolbarUrl(mContext.getString(R.string.loading)); } } else { mView.showToast(makeToast(mContext.getString(R.string.message_invalid_url))); mView.close(); } } }
From source file:com.jbirdvegas.mgerrit.GerritSwitcher.java
@Contract("null -> false") private boolean isUrlValid(String url) { return (url != null) && (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url) && url.contains(".")); }
From source file:com.shinymayhem.radiopresets.ServiceAudioFormat.java
private String getUrlFromM3u(String url) throws IOException, StreamHttpException { if (LOCAL_LOGD) log("Get URL from M3U", "d"); if (mStream == null) { getInputStream(url);/*from ww w . j a va2s . c om*/ } String newUrl = url; BufferedReader reader = new BufferedReader(new InputStreamReader(mStream)); String line; while ((line = reader.readLine()) != null) { if (LOCAL_LOGV) log("read line:" + line, "v"); if (!line.startsWith("#") && URLUtil.isHttpUrl(line) || URLUtil.isHttpsUrl(line)) { newUrl = line; break; } } return newUrl; }
From source file:org.traccar.client.MainFragment.java
private boolean validateServerURL(String userUrl) { int port = Uri.parse(userUrl).getPort(); if (URLUtil.isValidUrl(userUrl) && (port == -1 || (port > 0 && port <= 65535)) && (URLUtil.isHttpUrl(userUrl) || URLUtil.isHttpsUrl(userUrl))) { return true; }//w w w.j a v a 2 s .co m Toast.makeText(getActivity(), R.string.error_msg_invalid_url, Toast.LENGTH_LONG).show(); return false; }
From source file:com.ardnezar.lookapp.ConnectActivity.java
private boolean validateUrl(String url) { if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) { return true; }// w ww. j a va 2s . com new AlertDialog.Builder(this).setTitle(getText(R.string.invalid_url_title)) .setMessage(getString(R.string.invalid_url_text, url)).setCancelable(false) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).create().show(); return false; }
From source file:org.ohmage.authenticator.AuthenticatorActivity.java
/** * Ensures that the server url provided is valid. Once it is made valid, it * is set as the server url./*from ww w.j a v a 2 s . com*/ * * @return */ private boolean ensureServerUrl() { String text = mServerEdit.getText().toString(); if (TextUtils.isEmpty(text)) return false; // Assume they want https by default URI uri = URI.create(text.split(" ")[0]); if (uri.getScheme() == null) { text = "https://" + text; } text = URLUtil.guessUrl(text); if (URLUtil.isHttpsUrl(text) || URLUtil.isHttpUrl(text)) { mServerEdit.setText(text); return true; } return false; }
From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java
public static boolean validateUrl(String url) { if (!URLUtil.isHttpUrl(url) && !URLUtil.isHttpsUrl(url)) { //if (LOCAL_LOGV) log("not a valid http or https url", "v"); return false; }/*from w w w. j a v a 2 s .c om*/ //check for empty after prefix if (url.equals("http://") || url.equals("https://")) { return false; } MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); mediaPlayer.release(); } catch (IOException e) { return false; } return true; }