本文整理汇总了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());
}