public static Uri getPhotoUri(File file, Context context) { Uri fileUri = Uri.fromFile(file); Uri.Builder builder = new Uri.Builder() .authority(getContentProviderAuthority(context)) .scheme("file") .path(fileUri.getPath()) .query(fileUri.getQuery()) .fragment(fileUri.getFragment()); return builder.build(); }
/** * Returns a bogus Uri used to make each intent unique according to Intent#filterEquals. * Without this, the pending intents derived from the intent may be reused, because extras are * not taken into account for the filterEquals comparison. * * @param persistentNotificationId The persistent id of the notification. * @param origin The origin to whom the notification belongs. * @param actionIndex The zero-based index of the action button, or -1 if not applicable. */ private Uri makeIntentData(long persistentNotificationId, String origin, int actionIndex) { return Uri.parse(origin).buildUpon().fragment( persistentNotificationId + "," + actionIndex).build(); }
@NonNull private Uri createTargetUri(@NonNull final Uri sourceUri, @NonNull final Target target) { final String targetUrl = target.toTargetUrl(); final Uri sessionUri = Uri.parse(targetUrl); final String mergedEncodedQuery = mergeEncodedQuery(sourceUri, sessionUri); return sourceUri.buildUpon() .scheme(sessionUri.getScheme()) .authority(sessionUri.getAuthority()) .path(sessionUri.getPath()) .encodedQuery(mergedEncodedQuery) .fragment(sessionUri.getFragment()) .build(); }
.authority(authority) .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()
.authority(authority) .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()
/** * Returns the URL with all but the last component of its path removed. This serves as a proxy * for scope until the scope manifest member is available. This method assumes that the URL * passed in is a valid URL with a path that contains at least one "/". * @param url The url to convert to a scope. * @return The scope. */ public static String getScopeFromUrl(String url) { Uri uri = Uri.parse(url); List<String> path = uri.getPathSegments(); int endIndex = path.size(); // If there is at least one path element, remove the last one. if (endIndex > 0) { endIndex -= 1; } // Make sure the path starts and ends with a slash (or is only a slash if there is no path). Uri.Builder builder = uri.buildUpon(); String scope_path = "/" + TextUtils.join("/", path.subList(0, endIndex)); if (scope_path.length() > 1) { scope_path += "/"; } builder.path(scope_path); // Clear out the query and fragment. builder.fragment(""); builder.query(""); return builder.build().toString(); }
.scheme(uri.getScheme()) .authority(uri.getAuthority()) .fragment(uri.getFragment()) .query(uri.getQuery());
/** * Constructs a {@link Uri} from a set of {@link SQLOperator} for specific table. * * @param modelClass The class of table, * @param action The action to use. * @param conditions The set of key-value {@link SQLOperator} to construct into a uri. * @return The {@link Uri}. */ public static Uri getNotificationUri(@NonNull Class<?> modelClass, @NonNull Action action, @Nullable SQLOperator[] conditions) { Uri.Builder uriBuilder = new Uri.Builder().scheme("dbflow") .authority(FlowManager.getTableName(modelClass)); if (action != null) { uriBuilder.fragment(action.name()); } if (conditions != null && conditions.length > 0) { for (SQLOperator condition : conditions) { if (condition != null) { uriBuilder.appendQueryParameter(Uri.encode(condition.columnName()), Uri.encode(String.valueOf(condition.value()))); } } } return uriBuilder.build(); }
/** * Constructs a {@link Uri} from a set of {@link SQLOperator} for specific table. * * @param modelClass The class of table, * @param action The action to use. * @param conditions The set of key-value {@link SQLOperator} to construct into a uri. * @return The {@link Uri}. */ public static Uri getNotificationUri(@NonNull Class<?> modelClass, @Nullable Action action, @Nullable Iterable<SQLOperator> conditions) { Uri.Builder uriBuilder = new Uri.Builder().scheme("dbflow") .authority(FlowManager.getTableName(modelClass)); if (action != null) { uriBuilder.fragment(action.name()); } if (conditions != null) { for (SQLOperator condition : conditions) { uriBuilder.appendQueryParameter(Uri.encode(condition.columnName()), Uri.encode(String.valueOf(condition.value()))); } } return uriBuilder.build(); }
public Builder buildUpon() { if (isHierarchical()) { return new Builder() .scheme(getScheme()) .authority(getAuthorityPart()) .path(getPathPart()) .query(getQueryPart()) .fragment(getFragmentPart()); } else { return new Builder() .scheme(getScheme()) .opaquePart(getSsp()) .fragment(getFragmentPart()); } } }
/** * Encodes and sets the fragment. */ public Builder fragment(String fragment) { return fragment(Part.fromDecoded(fragment)); }
public Builder buildUpon() { return new Builder() .scheme(scheme) .authority(authority) .path(path) .query(query) .fragment(fragment); } }
public Builder buildUpon() { return new Builder() .scheme(this.scheme) .opaquePart(this.ssp) .fragment(this.fragment); } }
/** * Sets the previously encoded fragment. */ public Builder encodedFragment(String fragment) { return fragment(Part.fromEncoded(fragment)); }