當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。