List of usage examples for android.net Uri getHost
@Nullable public abstract String getHost();
From source file:Main.java
public static boolean isSimilarUri(Uri one, Uri two) { return one.getHost().equals(two.getHost()) && one.getPath().equals(two.getPath()); }
From source file:Main.java
/** * Test whether a {@link Uri} is a Tor Hidden Service host name, also known * as an ".onion address"./* w w w . java2s .co m*/ * * @return whether the host name is a Tor .onion address */ public static boolean isOnionAddress(Uri uri) { return uri.getHost().endsWith(".onion"); }
From source file:Main.java
@Nullable static Uri safeUri(@NonNull String url) { if (TextUtils.isEmpty(url)) { return null; }//from w w w. ja va 2 s. c om Uri uri = Uri.parse(url); if (uri.getHost() == null || uri.getScheme() == null) { return null; } return uri; }
From source file:Main.java
/** * Get an account name/* w w w . j a v a 2 s. c o m*/ * * @param blogUrl * @param email * @return */ public static String getName(String blogUrl, String email) { Uri uri = Uri.parse(blogUrl); return email + " (" + uri.getHost() + ")"; }
From source file:Main.java
/** * Return the position of the host in MASK_HOSTS, or -1 if it isn't a known URL masker *///from w w w . j a v a2 s . c om public static int getMaskedId(Uri uri) { String host = uri.getHost(); for (int i = 0; i < MASK_HOSTS.length; i++) { if (host.endsWith(MASK_HOSTS[i])) { if (MASK_HOSTS_SEG[i] == null) { return i; } else { List pathSegments = uri.getPathSegments(); if (pathSegments == null) return -1; if (pathSegments.size() > 0 && MASK_HOSTS_SEG[i].equals(pathSegments.get(0))) return i; } } } return -1; }
From source file:Main.java
/** * Returns a title suitable for display for a link. If |title| is non-empty, this simply returns * it. Otherwise, returns a shortened form of the URL. *///from w w w . ja va 2 s.co m static String getTitleForDisplay(@Nullable String title, @Nullable String url) { if (!TextUtils.isEmpty(title) || TextUtils.isEmpty(url)) { return title; } Uri uri = Uri.parse(url); String host = uri.getHost(); if (host == null) host = ""; String path = uri.getPath(); if (path == null || path.equals("/")) path = ""; title = host + path; return title; }
From source file:Main.java
public static String getInstagramId(String in) { Uri uri = Uri.parse(in); final String host = uri.getHost(); if (TextUtils.isEmpty(host) == false && host.indexOf("instagram") >= 0) { return in; }//from ww w . j a v a 2 s . co m return null; }
From source file:Main.java
public static String getVineId(String in) { Uri uri = Uri.parse(in); final String host = uri.getHost(); if (TextUtils.isEmpty(host) == false && host.indexOf("vine") >= 0) { return in; }/*w ww.j a va 2 s . c o m*/ return null; }
From source file:Main.java
public static String getVimeoId(String in) { Uri uri = Uri.parse(in); final String host = uri.getHost(); if (TextUtils.isEmpty(host) == false && host.indexOf("vimeo") >= 0) { return in; }/*from w ww.j a v a2 s. c o m*/ return null; }
From source file:Main.java
public static String getGfycatId(String in) { Uri uri = Uri.parse(in); final String host = uri.getHost(); if (TextUtils.isEmpty(host) == false && host.endsWith("gfycat.com") == true) { List<String> paths = uri.getPathSegments(); if (paths.size() == 1) { return paths.get(0); } else if (paths.size() == 2) { return paths.get(1); }// ww w. j av a 2s . c o m } return null; }