Example usage for android.net Uri getPathSegments

List of usage examples for android.net Uri getPathSegments

Introduction

In this page you can find the example usage for android.net Uri getPathSegments.

Prototype

public abstract List<String> getPathSegments();

Source Link

Document

Gets the decoded path segments.

Usage

From source file:Main.java

private static boolean isGameUri(Uri uri) {
    if (uri.getPathSegments().isEmpty()) {
        return false;
    }/*from w  w  w  .j a  va 2s  . co m*/
    String option = uri.getPathSegments().get(URI_INDEX_OPTION);
    return PLAY.equals(option);
}

From source file:Main.java

private static boolean isBrowseUri(Uri uri) {
    if (uri.getPathSegments().isEmpty())
        return false;

    String option = uri.getPathSegments().get(URI_INDEX_OPTION);
    return BROWSE.equals(option);
}

From source file:Main.java

public static String getIdFromUri(Uri uri) {
    String rowID = uri.getPathSegments().get(1);
    return rowID;
}

From source file:Main.java

private static boolean isVideoUri(Uri uri) {
    return uri.getPathSegments().contains("video");
}

From source file:Main.java

public static boolean isJoinUri(Uri uri) {
    return JOIN.equals(uri.getPathSegments().get(0));
}

From source file:Main.java

private static boolean isDocumentUri(Context context, Uri uri) {
    final List<String> paths = uri.getPathSegments();
    if (paths.size() < 2) {
        return false;
    }//ww  w  .  j a va  2  s .co m
    if (!PATH_DOCUMENT.equals(paths.get(0))) {
        return false;
    }

    return true;
}

From source file:Main.java

private static String extract(Uri uri, int index) {
    List<String> pathSegments = uri.getPathSegments();
    if (pathSegments.isEmpty() || pathSegments.size() < index)
        return null;
    return pathSegments.get(index);
}

From source file:Main.java

public static String getSoundCloudStream(String baseUrl, String clientId) {
    //196567484/*  www. j a  v  a  2 s .  c  o  m*/
    final Uri uri = Uri.parse(baseUrl);
    final List<String> segments = uri.getPathSegments();
    String id = null;
    for (int index = segments.size() - 1; index >= 0; index--) {

        if (TextUtils.isDigitsOnly(segments.get(index))) {
            id = segments.get(index);
            break;
        }
    }

    return getSoundCloudStreamFromTrackId(id, clientId);
}

From source file:Main.java

/**
 *
 * @param baseURL/*w ww  .  ja  va 2  s. c o  m*/
 * @param key
 * @return the soundcloud track id
 */
public static String parseSoundCloud(String baseURL) {

    Uri parsed = Uri.parse(baseURL);
    String authority = parsed.getAuthority();
    String trackURL = null;
    if (TextUtils.isEmpty(authority)) {
        return null;
    }
    if (authority.indexOf("api.soundcloud") >= 0) {
        trackURL = baseURL;
    } else if (authority.indexOf("soundcloud") >= 0) {
        Uri parsedURI = Uri.parse(baseURL);
        try {
            trackURL = parsedURI.getQueryParameter("url");
        } catch (Exception exc) {

        }
    }

    if (TextUtils.isEmpty(trackURL) == true) {
        return null;
    }

    Uri base = Uri.parse(trackURL);

    List<String> segments = base.getPathSegments();
    for (String segment : segments) {
        if (TextUtils.isDigitsOnly(segment) == true) {
            return segment;// String.format("https://api.soundcloud.com/tracks/%1$s/stream?consumer_key=%2$s",segment,key);
        }
    }

    return "";
}

From source file:org.peterbaldwin.vlcremote.fragment.ArtFragment.java

private static boolean isJamendoImage(Uri uri) {
    return "imgjam.com".equals(uri.getAuthority()) && uri.getPathSegments().size() != 0
            && uri.getLastPathSegment().matches("1\\.\\d+\\.jpg");
}