Java Code Examples for android.net.Uri#isAbsolute()

The following examples show how to use android.net.Uri#isAbsolute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomMatchers.java    From OpenYOLO-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean matchesSafely(Uri item) {
    if (!item.isAbsolute()
            || !item.isHierarchical()
            || TextUtils.isEmpty(item.getScheme())
            || TextUtils.isEmpty(item.getAuthority())) {
        return false;
    }

    if (!mPermittedSchemes.isEmpty() && !mPermittedSchemes.contains(item.getScheme())) {
        return false;
    }

    if (mAllowPathQueryOrFragment) {
        return true;
    }

    return TextUtils.isEmpty(item.getPath())
            && item.getQuery() == null
            && item.getFragment() == null;
}
 
Example 2
Source File: ParamCheckUtil.java    From FrescoPlus with Apache License 2.0 6 votes vote down vote up
private static void validate(Uri uri) {
    if (UriUtil.isLocalResourceUri(uri)) {
        if (!uri.isAbsolute()) {
            throw new FPRuntimeException("Resource URI path must be absolute.");
        }
        if (uri.getPath().isEmpty()) {
            throw new FPRuntimeException("Resource URI must not be empty");
        }
        try {
            Integer.parseInt(uri.getPath().substring(1));
        } catch (NumberFormatException ignored) {
            throw new FPRuntimeException("Resource URI path must be a resource id.",ignored.getCause());
        }
    }
    if (UriUtil.isLocalAssetUri(uri) && !uri.isAbsolute()) {
        throw new FPRuntimeException("Asset URI path must be absolute.");
    }
}
 
Example 3
Source File: AddRepoIntentService.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
public static String normalizeUrl(Uri uri) throws URISyntaxException {
    if (!uri.isAbsolute()) {
        throw new URISyntaxException(uri.toString(), "Must provide an absolute URI for repositories");
    }
    if (!uri.isHierarchical()) {
        throw new URISyntaxException(uri.toString(), "Must provide an hierarchical URI for repositories");
    }
    if ("content".equals(uri.getScheme())) {
        return uri.toString();
    }
    String path = uri.getPath();
    if (path != null) {
        path = path.replaceAll("//*/", "/"); // Collapse multiple forward slashes into 1.
        if (path.length() > 0 && path.charAt(path.length() - 1) == '/') {
            path = path.substring(0, path.length() - 1);
        }
    }
    String scheme = uri.getScheme();
    String host = uri.getHost();
    if (TextUtils.isEmpty(scheme) || TextUtils.isEmpty(host)) {
        return uri.toString();
    }
    return new URI(scheme.toLowerCase(Locale.ENGLISH),
            uri.getUserInfo(),
            host.toLowerCase(Locale.ENGLISH),
            uri.getPort(),
            path,
            uri.getQuery(),
            uri.getFragment()).normalize().toString();
}
 
Example 4
Source File: CordovaResourceApi.java    From countly-sdk-cordova with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 5
Source File: CordovaResourceApi.java    From CordovaYoutubeVideoPlayer with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 6
Source File: CordovaResourceApi.java    From phonegap-plugin-loading-spinner with Apache License 2.0 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 7
Source File: CordovaResourceApi.java    From reader with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 8
Source File: LocalImageProvider.java    From TLint with Apache License 2.0 4 votes vote down vote up
public static String constructUri(String url) {
    Uri uri = Uri.parse(url);
    return uri.isAbsolute() ? url : URI_PREFIX + url;
}
 
Example 9
Source File: CordovaResourceApi.java    From a2cardboard with Apache License 2.0 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 10
Source File: CordovaResourceApi.java    From pychat with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 11
Source File: CordovaResourceApi.java    From L.TileLayer.Cordova with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 12
Source File: CordovaResourceApi.java    From cordova-plugin-app-update-demo with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 13
Source File: CordovaResourceApi.java    From BigDataPlatform with GNU General Public License v3.0 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 14
Source File: CordovaResourceApi.java    From app-icon with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 15
Source File: CordovaResourceApi.java    From react-native-cordova with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 16
Source File: CordovaResourceApi.java    From phonegapbootcampsite with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 17
Source File: CordovaResourceApi.java    From keemob with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 18
Source File: CordovaResourceApi.java    From keemob with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 19
Source File: CordovaResourceApi.java    From reader with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}
 
Example 20
Source File: CordovaResourceApi.java    From xmall with MIT License 4 votes vote down vote up
private static void assertNonRelative(Uri uri) {
    if (!uri.isAbsolute()) {
        throw new IllegalArgumentException("Relative URIs are not supported.");
    }
}