当前位置: 首页>>代码示例>>Java>>正文


Java Uri.buildUpon方法代码示例

本文整理汇总了Java中android.net.Uri.buildUpon方法的典型用法代码示例。如果您正苦于以下问题:Java Uri.buildUpon方法的具体用法?Java Uri.buildUpon怎么用?Java Uri.buildUpon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.Uri的用法示例。


在下文中一共展示了Uri.buildUpon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUri

import android.net.Uri; //导入方法依赖的package包/类
public Uri getUri(@Nullable final String module, @Nullable final String key,
        final boolean internal) {
    if (module == null && key != null) {
        throw new IllegalArgumentException(
                "key without module is not valid. Look into the TryProvider for valid Uris");
    }
    final Uri uri = internal ? mContentUriInternal : mContentUri;
    final Uri.Builder builder = uri
            .buildUpon();
    if (module != null) {
        builder.appendPath(module);
    }
    if (key != null) {
        builder.appendPath(key);
    }
    return builder.build();
}
 
开发者ID:sfilmak,项目名称:MakiLite,代码行数:18,代码来源:TrayProviderHelper.java

示例2: getSharingUri

import android.net.Uri; //导入方法依赖的package包/类
public static Uri getSharingUri(Repo repo) {
    if (TextUtils.isEmpty(repo.address)) {
        return Uri.parse("http://wifi-not-enabled");
    }
    Uri localRepoUri = getLocalRepoUri(repo);
    Uri.Builder b = localRepoUri.buildUpon();
    b.scheme(localRepoUri.getScheme().replaceFirst("http", "fdroidrepo"));
    b.appendQueryParameter("swap", "1");
    if (!TextUtils.isEmpty(FDroidApp.bssid)) {
        b.appendQueryParameter("bssid", FDroidApp.bssid);
        if (!TextUtils.isEmpty(FDroidApp.ssid)) {
            b.appendQueryParameter("ssid", FDroidApp.ssid);
        }
    }
    return b.build();
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:17,代码来源:Utils.java

示例3: rewrite

import android.net.Uri; //导入方法依赖的package包/类
@NonNull
@Override
public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
  if (TextUtils.isEmpty(instance.getBundleUrl())) {
    return uri;
  }

  Uri base = Uri.parse(instance.getBundleUrl());
  Uri.Builder resultBuilder = uri.buildUpon();
  
 if (uri.isRelative()) {
    //When uri is empty, means use the base url instead. Web broswer behave this way.
    if(uri.getEncodedPath().length() == 0){
      return base;
    } else {
      resultBuilder = buildRelativeURI(resultBuilder, base, uri);
      return resultBuilder.build();
    }
  }
  return uri;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:22,代码来源:DefaultUriAdapter.java

示例4: buildurl

import android.net.Uri; //导入方法依赖的package包/类
private String buildurl(Uri paramUri) {
    // Uri localUri;
    Uri.Builder localBuilder = new Uri.Builder();
    if (TextUtils.isEmpty(paramUri.getQuery())) {
        localBuilder = paramUri.buildUpon();
    }
    for (String str1 = "0"; ; str1 = "1") {
        localBuilder.appendQueryParameter("countryid", str1).
                appendQueryParameter("belongid", "0");//String.valueOf(q.getUrl().g().id)
        Iterator localIterator = paramUri.getQueryParameterNames().iterator();
        while (localIterator.hasNext()) {
            String str2 = (String) localIterator.next();
            if (("countryid".equals(str2)) || ("belongid".equals(str2)))
                continue;
            localBuilder.appendQueryParameter(str2, paramUri.getQueryParameter(str2));
        }
        // localUri = Uri.parse(paramUri.toString().replace(paramUri.getQuery(), ""));
        break;
    }
    return localBuilder.toString();
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:22,代码来源:CustomerServiceWebActivity.java

示例5: getLocalRepoUri

import android.net.Uri; //导入方法依赖的package包/类
@NonNull
public static Uri getLocalRepoUri(Repo repo) {
    if (TextUtils.isEmpty(repo.address)) {
        return Uri.parse("http://wifi-not-enabled");
    }
    Uri uri = Uri.parse(repo.address);
    Uri.Builder b = uri.buildUpon();
    if (!TextUtils.isEmpty(repo.fingerprint)) {
        b.appendQueryParameter("fingerprint", repo.fingerprint);
    }
    String scheme = Preferences.get().isLocalRepoHttpsEnabled() ? "https" : "http";
    b.scheme(scheme);
    return b.build();
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:15,代码来源:Utils.java

示例6: onQueryByTags

import android.net.Uri; //导入方法依赖的package包/类
@Override
public void onQueryByTags(String query) {

  final String searchParamKey =
      Kolibri.getInstance(kolibriWebView.getContext()).getRuntime().getComponent("search")
          .getSettings().getString("search-param");

  String url = kolibriWebView.getUrl();
  Uri uri = Uri.parse(url);

  Uri.Builder builder = uri.buildUpon();
  builder.clearQuery();

  String searchValue = uri.getQueryParameter(searchParamKey);

  if (searchValue != null) {
    builder.appendQueryParameter(searchParamKey, searchValue);
  }

  url = builder.build().toString();

  String filteredUrl = url;
  if (!url.contains("?")) {
    filteredUrl += "?";
  } else {
    query = "&" + query;
  }

  filteredUrl += query;

  kolibriWebView.loadUrl(filteredUrl);

}
 
开发者ID:azmedien,项目名称:kolibri-android,代码行数:34,代码来源:SearchWebviewCoordinator.java

示例7: onQueryByText

import android.net.Uri; //导入方法依赖的package包/类
@Override
public void onQueryByText(String text) {

  final String searchParamKey =
      Kolibri.getInstance(kolibriWebView.getContext()).getRuntime().getComponent("search")
          .getSettings().getString("search-param");

  String url = kolibriWebView.getUrl();
  Uri uri = Uri.parse(url);

  if (!"".equals(text)) {
    Uri.Builder builder = uri.buildUpon();
    builder.clearQuery();

    if (uri.getQueryParameterNames().size() <= 0
        || uri.getQueryParameter(searchParamKey) == null) {
      builder.appendQueryParameter(searchParamKey, text);
    } else {
      for (String key : uri.getQueryParameterNames()) {
        if (searchParamKey.equals(key)) {
          builder.appendQueryParameter(searchParamKey, text);
        } else {
          builder.appendQueryParameter(key, uri.getQueryParameter(key));
        }
      }
    }

    uri = builder.build();
  }

  kolibriWebView.loadUrl(uri.toString());
}
 
开发者ID:azmedien,项目名称:kolibri-android,代码行数:33,代码来源:SearchWebviewCoordinator.java

示例8: push

import android.net.Uri; //导入方法依赖的package包/类
@JSMethod(uiThread = true)
public void push(String param, JSCallback callback) {

    if (!TextUtils.isEmpty(param)) {
        if (WXSDKEngine.getActivityNavBarSetter() != null) {
            if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
                callback.invoke(MSG_SUCCESS);
                return;
            }
        }

        try {
            JSONObject jsonObject = JSON.parseObject(param);
            String url = jsonObject.getString(URL);
            if (!TextUtils.isEmpty(url)) {
                Uri rawUri = Uri.parse(url);
                String scheme = rawUri.getScheme();
                Uri.Builder builder = rawUri.buildUpon();
                if (TextUtils.isEmpty(scheme)) {
                    builder.scheme(Constants.Scheme.HTTP);
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
                intent.addCategory(WEEX);
                intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
                mWXSDKInstance.getContext().startActivity(intent);
                callback.invoke(MSG_SUCCESS);
            }
        } catch (Exception e) {
            WXLogUtils.eTag(TAG, e);
            callback.invoke(MSG_FAILED);
        }
    }

    callback.invoke(MSG_FAILED);
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:36,代码来源:WXNavigatorModule.java

示例9: push

import android.net.Uri; //导入方法依赖的package包/类
@WXModuleAnno
public void push(String param, final String callbackId) {

    if (!TextUtils.isEmpty(param)) {
        if (WXSDKEngine.getActivityNavBarSetter() != null) {
            if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
                WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
                        MSG_SUCCESS);
                return;
            }
        }

        try {
            JSONObject jsonObject = new JSONObject(param);
            String url = jsonObject.optString(URL, "");
            if (!TextUtils.isEmpty(url)) {
                Uri rawUri = Uri.parse(url);
                String scheme = rawUri.getScheme();
                Uri.Builder builder = rawUri.buildUpon();
                if (TextUtils.isEmpty(scheme)) {
                    builder.scheme("http");
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
                intent.addCategory(WEEX);
                intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
                mWXSDKInstance.getContext().startActivity(intent);
                WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
                        MSG_SUCCESS);
            }
        } catch (Exception e) {
            WXLogUtils.eTag(TAG, e);
            WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
                    MSG_FAILED);
        }
    }

    WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
            MSG_FAILED);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:40,代码来源:WXNavigatorModule.java

示例10: rewrite

import android.net.Uri; //导入方法依赖的package包/类
@NonNull
@Override
public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
  Uri base = Uri.parse(instance.getBundleUrl());
  Uri.Builder resultBuilder = uri.buildUpon();

  if (uri.isRelative()) {
    resultBuilder = buildRelativeURI(resultBuilder, base, uri);
    return resultBuilder.build();
  }
  return uri;


}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:15,代码来源:DefaultUriAdapter.java

示例11: getScopeFromUrl

import android.net.Uri; //导入方法依赖的package包/类
/**
 * Generates a scope URL based on the passed in URL. It should be used if the Web Manifest
 * does not specify a scope URL.
 * @param url The url to convert to a scope.
 * @return The scope.
 */
@CalledByNative
public static String getScopeFromUrl(String url) {
    // Scope URL is generated by:
    // - Removing last component of the URL.
    // - Clearing the URL's query and fragment.

    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);

    builder.fragment("");
    builder.query("");
    return builder.build().toString();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:34,代码来源:ShortcutHelper.java

示例12: makeTranslateUri

import android.net.Uri; //导入方法依赖的package包/类
/**
 * Makes the given {@code Uri} into a similar Uri that triggers a Translate one-box.
 * @param baseUri The base Uri to build off of.
 * @param sourceLanguage The language of the original search term, or an empty string to
 *        auto-detect the source language.
 * @param targetLanguage The language that the user prefers, or an empty string to
 *        use server-side heuristics for the target language.
 * @return A {@link Uri} that has additional parameters for Translate appropriately set.
 */
private Uri makeTranslateUri(Uri baseUri, String sourceLanguage, String targetLanguage) {
    Uri.Builder builder = baseUri.buildUpon();
    builder.appendQueryParameter(CTXSL_TRANS_PARAM, CTXSL_TRANS_PARAM_VALUE);
    if (!sourceLanguage.isEmpty()) {
        builder.appendQueryParameter(TLITE_SOURCE_LANGUAGE_PARAM, sourceLanguage);
    }
    if (!targetLanguage.isEmpty()) {
        builder.appendQueryParameter(TLITE_TARGET_LANGUAGE_PARAM, targetLanguage);
    }
    builder.appendQueryParameter(TLITE_QUERY_PARAM, baseUri.getQueryParameter(GWS_QUERY_PARAM));
    return builder.build();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:ContextualSearchRequest.java

示例13: getList

import android.net.Uri; //导入方法依赖的package包/类
public String getList(String page, String rows, String id) throws Exception {
    Uri uri = Uri.parse("/list");
    Uri.Builder builder = uri.buildUpon();
    if(!TextUtils.isEmpty(page)) {
        builder.appendQueryParameter("page", page);
    }
    if(!TextUtils.isEmpty(rows)) {
        builder.appendQueryParameter("rows", rows);
    }
    if(!TextUtils.isEmpty(id)) {
        builder.appendQueryParameter("id", id);
    }
    uri = builder.build();
    return get(uri.toString());
}
 
开发者ID:AlphaBoom,项目名称:ClassifyView,代码行数:16,代码来源:NetManager.java

示例14: appendSourceUri

import android.net.Uri; //导入方法依赖的package包/类
@NonNull
private Uri appendSourceUri(@NonNull final Uri base, @NonNull final Map<String, String> queryParams) {
    final Uri.Builder sourceBuilder = base.buildUpon();
    for (Map.Entry<String, String> query : queryParams.entrySet()) {
        sourceBuilder.appendQueryParameter(query.getKey(), query.getValue());
    }
    return sourceBuilder.build();
}
 
开发者ID:drakeet,项目名称:Floo,代码行数:9,代码来源:Floo.java

示例15: onCreateLoader

import android.net.Uri; //导入方法依赖的package包/类
@Override
public Loader<List<Earthquake>> onCreateLoader(int id, Bundle args) {
    Log.d(LOG_TAG, "onCreateLoader:  is called" );

    //构造偏好设置Uri
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    String minMagnitude = sharedPreferences.getString(
            getString(R.string.setting_min_magnitude_key),
            getString(R.string.settings_min_magnitude_default)
    );

    String orderBy = sharedPreferences.getString(
            getString(R.string.settings_order_by_key),
            getString(R.string.settings_order_by_default)
    );

    Uri baseUri = Uri.parse(USGS_REQUEST_URL);
    //使用Uri.Builder构建Uri对象
    Uri.Builder uriBuilder = baseUri.buildUpon();

    uriBuilder.appendQueryParameter("format", "geojson");
    uriBuilder.appendQueryParameter("limit", "10");
    uriBuilder.appendQueryParameter("minmag", minMagnitude);
    uriBuilder.appendQueryParameter("orderby", orderBy);


    return new EarthquakeLoader(this, uriBuilder.toString());
}
 
开发者ID:wenzhifeifeidetutu,项目名称:QuakeRepor,代码行数:29,代码来源:EarthquakeActivity.java


注:本文中的android.net.Uri.buildUpon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。