本文整理匯總了Java中android.net.Uri.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.Builder方法的具體用法?Java Uri.Builder怎麽用?Java Uri.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.net.Uri
的用法示例。
在下文中一共展示了Uri.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: appendParams
import android.net.Uri; //導入方法依賴的package包/類
protected String appendParams(String url, Map<String, String> params)
{
if (url == null || params == null || params.isEmpty())
{
return url;
}
Uri.Builder builder = Uri.parse(url).buildUpon();
Set<String> keys = params.keySet();
Iterator<String> iterator = keys.iterator();
while (iterator.hasNext())
{
String key = iterator.next();
builder.appendQueryParameter(key, params.get(key));
}
return builder.build().toString();
}
示例2: toLocalUri
import android.net.Uri; //導入方法依賴的package包/類
@Override
public LocalFilesystemURL toLocalUri(Uri inputURL) {
if (!"content".equals(inputURL.getScheme())) {
return null;
}
String subPath = inputURL.getEncodedPath();
if (subPath.length() > 0) {
subPath = subPath.substring(1);
}
Uri.Builder b = new Uri.Builder()
.scheme(LocalFilesystemURL.FILESYSTEM_PROTOCOL)
.authority("localhost")
.path(name)
.appendPath(inputURL.getAuthority());
if (subPath.length() > 0) {
b.appendEncodedPath(subPath);
}
Uri localUri = b.encodedQuery(inputURL.getEncodedQuery())
.encodedFragment(inputURL.getEncodedFragment())
.build();
return LocalFilesystemURL.parse(localUri);
}
示例3: wrapPageName
import android.net.Uri; //導入方法依賴的package包/類
private String wrapPageName(String pageName, String url) {
if(TextUtils.equals(pageName, WXPerformance.DEFAULT)){
pageName=url;
try {
Uri uri=Uri.parse(url);
if(uri!=null){
Uri.Builder builder=new Uri.Builder();
builder.scheme(uri.getScheme());
builder.authority(uri.getAuthority());
builder.path(uri.getPath());
pageName=builder.toString();
}
} catch (Exception e) {
}
}
return pageName;
}
示例4: playMovieSeriesItem
import android.net.Uri; //導入方法依賴的package包/類
private void playMovieSeriesItem(String url, String playtoken, String netResVideoId) {
if (TextUtils.isEmpty(url))
return;
Uri.Builder builder = Uri.parse(url).buildUpon();
builder.appendQueryParameter("playtype", "demand");
builder.appendQueryParameter("protocol", "http");
builder.appendQueryParameter("accesstoken", MobileDataManager.getAccessToken());
builder.appendQueryParameter("programid", netResVideoId);
builder.appendQueryParameter("playtoken", playtoken);
builder.appendQueryParameter("verifycode", "" + 33); // 33
// verifycode
builder.appendQueryParameter("rate", "normal");
String playUrl = builder.build().toString();
this.mPlayUrl = playUrl;
Logger.d("playurl: " + playUrl);
mVideoPlayer.stopPlayback();
mVideoPlayer.setVideoPath(playUrl);
}
示例5: playMovieSeriesItem
import android.net.Uri; //導入方法依賴的package包/類
private void playMovieSeriesItem(String url, String playtoken, String netResVideoId) {
if (TextUtils.isEmpty(url))
return;
Uri.Builder builder = Uri.parse(url).buildUpon();
builder.appendQueryParameter("playtype", "demand");
builder.appendQueryParameter("protocol", "http");
builder.appendQueryParameter("accesstoken", MobileDataManager.getAccessToken());
builder.appendQueryParameter("programid", netResVideoId);
builder.appendQueryParameter("playtoken", playtoken);
builder.appendQueryParameter("verifycode", "" + 33); // 33
// verifycode
builder.appendQueryParameter("rate", "normal");
String playUrl = builder.build().toString();
this.mPlayUrl = playUrl;
Logger.d("playurl: " + playUrl);
mVideoPlayer.setVideoPath(playUrl);
mVideoPlayer.requestFocus();
}
示例6: buildUrl
import android.net.Uri; //導入方法依賴的package包/類
private String buildUrl(String method, String query) {
Uri.Builder uriBuilder = ENDPOINT.buildUpon()
.appendQueryParameter("method", method);
if (method.equals(SEARCH_METHOD)) {
uriBuilder.appendQueryParameter("text", query);
}
return uriBuilder.build().toString();
}
示例7: buildUri
import android.net.Uri; //導入方法依賴的package包/類
public static Uri buildUri(String authority, String path, Bundle parameters) {
Uri.Builder builder = new Uri.Builder();
builder.scheme(URL_SCHEME);
builder.authority(authority);
builder.path(path);
for (String key : parameters.keySet()) {
Object parameter = parameters.get(key);
if (parameter instanceof String) {
builder.appendQueryParameter(key, (String) parameter);
}
}
return builder.build();
}
示例8: getEncodedQuery
import android.net.Uri; //導入方法依賴的package包/類
public String getEncodedQuery() {
Uri.Builder builder = new Uri.Builder();
for (Entry<String,String> param : mParams.entrySet()) {
builder.appendQueryParameter(param.getKey(), param.getValue());
}
return builder.build().getEncodedQuery();
}
示例9: JSPackagerClient
import android.net.Uri; //導入方法依賴的package包/類
public JSPackagerClient(String clientId, PackagerConnectionSettings settings, Map<String, RequestHandler> requestHandlers) {
super();
Uri.Builder builder = new Uri.Builder();
builder.scheme("ws")
.encodedAuthority(settings.getDebugServerHost())
.appendPath("message")
.appendQueryParameter("device", AndroidInfoHelpers.getFriendlyDeviceName())
.appendQueryParameter("app", settings.getPackageName())
.appendQueryParameter("clientid", clientId);
String url = builder.build().toString();
mWebSocket = new ReconnectingWebSocket(url, this);
mRequestHandlers = requestHandlers;
}
示例10: getProfilePictureUri
import android.net.Uri; //導入方法依賴的package包/類
public static Uri getProfilePictureUri(
String userId,
int width,
int height) {
Validate.notNullOrEmpty(userId, "userId");
width = Math.max(width, UNSPECIFIED_DIMENSION);
height = Math.max(height, UNSPECIFIED_DIMENSION);
if (width == UNSPECIFIED_DIMENSION && height == UNSPECIFIED_DIMENSION) {
throw new IllegalArgumentException("Either width or height must be greater than 0");
}
Uri.Builder builder =
new Uri.Builder()
.scheme(SCHEME)
.authority(AUTHORITY)
.path(String.format(Locale.US, PATH, userId));
if (height != UNSPECIFIED_DIMENSION) {
builder.appendQueryParameter(HEIGHT_PARAM, String.valueOf(height));
}
if (width != UNSPECIFIED_DIMENSION) {
builder.appendQueryParameter(WIDTH_PARAM, String.valueOf(width));
}
builder.appendQueryParameter(MIGRATION_PARAM, MIGRATION_VALUE);
return builder.build();
}
示例11: buildPath
import android.net.Uri; //導入方法依賴的package包/類
/**
* Create API endpoint with given params (optional)
* @param path
* @param params
* @return
*/
private static String buildPath(String path, Map<String, String> params) {
Uri.Builder builder = Uri.parse(BuildConfig.HOST + path).buildUpon();
if (params != null) {
for (Map.Entry<String, String> entry : params.entrySet()) {
builder.appendQueryParameter(entry.getKey(), entry.getValue());
}
}
return builder.build().toString();
}
示例12: toLocalUri
import android.net.Uri; //導入方法依賴的package包/類
@Override
public LocalFilesystemURL toLocalUri(Uri inputURL) {
if (!"file".equals(inputURL.getScheme())) {
return null;
}
File f = new File(inputURL.getPath());
// Removes and duplicate /s (e.g. file:///a//b/c)
Uri resolvedUri = Uri.fromFile(f);
String rootUriNoTrailingSlash = rootUri.getEncodedPath();
rootUriNoTrailingSlash = rootUriNoTrailingSlash.substring(0, rootUriNoTrailingSlash.length() - 1);
if (!resolvedUri.getEncodedPath().startsWith(rootUriNoTrailingSlash)) {
return null;
}
String subPath = resolvedUri.getEncodedPath().substring(rootUriNoTrailingSlash.length());
// Strip leading slash
if (!subPath.isEmpty()) {
subPath = subPath.substring(1);
}
Uri.Builder b = new Uri.Builder()
.scheme(LocalFilesystemURL.FILESYSTEM_PROTOCOL)
.authority("localhost")
.path(name);
if (!subPath.isEmpty()) {
b.appendEncodedPath(subPath);
}
if (f.isDirectory()) {
// Add trailing / for directories.
b.appendEncodedPath("");
}
return LocalFilesystemURL.parse(b.build());
}
示例13: attachGetParameters
import android.net.Uri; //導入方法依賴的package包/類
/**
* Converts and attaches GET parameters to specified path.
*
* @param path Path on which to attach parameters.
* @param params Params to convert and attach.
* @return Path with attached parameters.
*/
private static String attachGetParameters(String path, Map<String, Object> params) {
if (params == null) {
return path;
}
Uri.Builder builder = Uri.parse(path).buildUpon();
for (Map.Entry<String, Object> pair : params.entrySet()) {
if (pair.getValue() == null) {
continue;
}
builder.appendQueryParameter(pair.getKey(), pair.getValue().toString());
}
return builder.build().toString();
}
示例14: withParam
import android.net.Uri; //導入方法依賴的package包/類
@NonNull
@Override
public Uri.Builder withParam(@NonNull Uri.Builder uriBuilder)
{
return mDelegate.withParam(uriBuilder).appendQueryParameter("caller_is_syncadapter", "true");
}
示例15: testAppendQueryParameterIfNotNullForNullValue
import android.net.Uri; //導入方法依賴的package包/類
@Test
public void testAppendQueryParameterIfNotNullForNullValue() {
Uri.Builder builder = new Uri.Builder();
LiUriUtils.appendQueryParameterIfNotNull(builder, "test", null);
Assert.assertEquals("", builder.toString());
}