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


Java HttpUrl.Builder方法代码示例

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


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

示例1: onCreate

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());

    final PackageInfo packageInfo = application.packageInfo();
    final int versionNameSplit = packageInfo.versionName.indexOf('-');
    final HttpUrl.Builder url = HttpUrl
            .parse(Constants.VERSION_URL
                    + (versionNameSplit >= 0 ? packageInfo.versionName.substring(versionNameSplit) : ""))
            .newBuilder();
    url.addEncodedQueryParameter("package", packageInfo.packageName);
    url.addQueryParameter("current", Integer.toString(packageInfo.versionCode));
    versionUrl = url.build();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:19,代码来源:AlertDialogsFragment.java

示例2: generateGET

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
String generateGET(Transaction transaction) {
    // Validate merchantId
    if (merchantId == null || merchantId.isEmpty()) {
        // The merchantId is required
        throw new Error("The merchantId is required", Error.ERROR_MISSING_MERCHANT_ID, null);
    }

    HttpUrl.Builder builder = new HttpUrl.Builder()
            .scheme(secure ? "https" : "http")
            .host(SERVER)
            .addPathSegment("merchants")
            .addPathSegment(merchantId);
    // Serialize query
    transaction.serialize(builder);
    Log.d(TAG, builder.build().query());
    return builder.build().url().toString();
}
 
开发者ID:scarabresearch,项目名称:EmarsysPredictSDKAndroid,代码行数:18,代码来源:Session.java

示例3: get

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
public <ResultType extends ResultAdapter>ResultType get(Class<ResultType> resultType) throws IOException, WebException {
    HttpUrl.Builder builder = HttpUrl.parse(getFullUrl()).newBuilder();
    String[] keys = getParamKeys();
    for (String key : keys) {
        builder.addEncodedQueryParameter(key, param.get(key));
    }
    HttpUrl httpUrl = builder.build();

    Request.Builder reqestBuilder = new Request.Builder().url(httpUrl);
    addHeaderAll(reqestBuilder);

    Request request = reqestBuilder.build();
    debugRequest("GET", paramString);

    clearAllParams();
    call = client.newCall(request);
    Response response = call.execute();
    ResultType result = getResult(response, resultType);
    debugResponse(result.getBody(), response);
    unexpectedCode(response, result.getBody());
    return result;
}
 
开发者ID:muabe,项目名称:JwTools,代码行数:23,代码来源:OkWeb.java

示例4: getUserTips

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 * Returns tips from a user.
 * 
 * @param userId Identity of the user to get tips from. Pass self to get tips of the acting
 *        user.
 * @param limit Number of results to return, up to 200.
 * @param offset The number of results to skip. Used to page through results.
 * @param llBounds optional Restricts the returned results to the input bounding box.
 * @param categoryId optional Restricts the returned results to venues matching the input
 *        category id.
 * @param sort optional Sorts the list items. Possible values are recent and nearby. recent
 *        sorts the list items by the date added to the list. nearby sorts the list items by the
 *        distance from the center of the provided llBounds.
 * @return a List of tips
 */
public Result<List> getUserTips(String userId, Integer limit, Integer offset, 
        String llBounds, String categoryId, String sort) {
    HttpUrl.Builder urlBuilder = newApiUrlBuilder()
            .addPathSegment("lists")
            .addPathSegment(userId)
            .addPathSegment("tips");
    if (limit != null) urlBuilder.addQueryParameter("limit", String.valueOf(limit));
    if (offset != null) urlBuilder.addQueryParameter("offset", String.valueOf(offset));
    if (llBounds != null) urlBuilder.addQueryParameter("llBounds", llBounds);
    if (categoryId != null) urlBuilder.addQueryParameter("categoryId", categoryId);
    if (sort != null) urlBuilder.addQueryParameter("sort", sort);
    String json = newRequest(urlBuilder.toString());
    LOGGER.debug("Response ---> {}", json);
    return Parser.parse(json, "list", List.class);
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:31,代码来源:FoursquareApi.java

示例5: getUserVenueLikes

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 * Returns a list of venues liked by the specified user.
 * 
 * @param userId User ID or self.
 * @param beforeTimestamp Seconds since epoch..
 * @param afterTimestamp Seconds since epoch.
 * @param categoryId Limits returned venues to those in this category. If specifying a top-level
 *        category, all sub-categories will also match the query.
 * @param limit Number of results to return.
 * @param offset Used to page through results.
 * @return a Group of Venues wrapped in a Result object.
 */
public Result<Group<Venue>> getUserVenueLikes(String userId, Long beforeTimestamp, 
        Long afterTimestamp, String categoryId, Integer limit, Integer offset) {
    HttpUrl.Builder urlBuilder = newApiUrlBuilder()
            .addPathSegment("users")
            .addPathSegment(userId)
            .addPathSegment("venuelikes");
    if (beforeTimestamp != null) urlBuilder.addQueryParameter("beforeTimestamp", String.valueOf(beforeTimestamp));
    if (afterTimestamp != null) urlBuilder.addQueryParameter("afterTimestamp", String.valueOf(afterTimestamp));
    if (categoryId != null) urlBuilder.addQueryParameter("categoryId", categoryId);
    if (limit != null) urlBuilder.addQueryParameter("limit", String.valueOf(limit));
    if (offset != null) urlBuilder.addQueryParameter("offset", String.valueOf(offset));
    String json = newRequest(urlBuilder.toString());
    LOGGER.debug("Response ---> {}", json);
    return Parser.parse(json, "venues", new TypeToken<Group<Venue>>(){});
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:28,代码来源:FoursquareApi.java

示例6: getMartianUrl

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 * Returns a canonicalized URL as a string that can be used for Martian system requests. These
 * URLs will be of the form http://martian.proxy/{path}. The provided path should contian a
 * leading slash. Any forward slashes in the provided path will be handled as path delimeters.
 *
 * @param path Path portion of the Martian system request URL
 **/
public String getMartianUrl(String path) {
  HttpUrl.Builder urlBuilder = new HttpUrl.Builder().scheme("http").host(this.proxyHost);
  String[] parts = path.split("/");
  for (String part : parts) {
    urlBuilder.addPathSegment(part);
  }

  return urlBuilder.build().toString();
}
 
开发者ID:google,项目名称:martian-java,代码行数:17,代码来源:Client.java

示例7: formatUrl

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
HttpUrl formatUrl(String template, Map<String, String> pathParams,
        Map<String, Object> queryParams) {
    String path = template;
    for (Map.Entry<String, String> entry : pathParams.entrySet()) {
        path = path.replace(":" + entry.getKey(), entry.getValue());
    }
    HttpUrl.Builder builder = baseUrl.resolve(path).newBuilder();
    for (Map.Entry<String, Object> param : queryParams.entrySet()) {
        builder.addQueryParameter(param.getKey(), param.getValue().toString());
    }
    return builder.build();
}
 
开发者ID:gocardless,项目名称:gocardless-pro-java,代码行数:13,代码来源:UrlFormatter.java

示例8: getAccessToken

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 * Retrieves the access token from Foursquare when using native authentication in clients.
 * 
 * @param redirectUri your registered redirect uri. Pass {@code null} if you got the code from a
 *        native app (iOS or Android).
 * @param code the authorization code.
 * @return a AccessTokenResponse.
 */
public AccessTokenResponse getAccessToken(String redirectUri, String code) {
    HttpUrl.Builder urlBuilder = HttpUrl.parse(authUrl()).newBuilder()
            .addQueryParameter("client_id", clientId)
            .addQueryParameter("client_secret", clientSecret)
            .addQueryParameter("grant_type", "authorization_code")
            .addQueryParameter("code", code);
    if (redirectUri != null) urlBuilder.addQueryParameter("redirect_uri", redirectUri);
    String json = newRequest(urlBuilder.toString());
    LOGGER.debug("Response ---> {}", json);
    return new AccessTokenResponse(json);
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:20,代码来源:FoursquareApi.java

示例9: getUserFriends

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 * Returns an array of a user's friends.
 * 
 * @param userId Identity of the user to get friends of. Pass self to get friends of the acting
 *        user.
 * @param limit Number of results to return, up to 500.
 * @param offset Used to page through results.
 * @return a Group of Users wrapped in a Result object.
 */
public Result<Group<User>> getUserFriends(String userId, Integer limit, Integer offset) {
    HttpUrl.Builder urlBuilder = newApiUrlBuilder()
            .addPathSegment("users")
            .addPathSegment(userId)
            .addPathSegment("friends");
    if (limit != null) urlBuilder.addQueryParameter("limit", String.valueOf(limit));
    if (offset != null) urlBuilder.addQueryParameter("offset", String.valueOf(offset));
    String json = newRequest(urlBuilder.toString());
    LOGGER.debug("Response ---> {}", json);
    return Parser.parse(json, "friends", new TypeToken<Group<User>>(){});
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:21,代码来源:FoursquareApi.java

示例10: newApiUrlBuilder

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 * Builds a new HttpUrl.Builder preinitialized with the Foursquare API url parameters.
 * 
 * @return a new HttpUrl.Builder.
 */
private HttpUrl.Builder newApiUrlBuilder() {
    HttpUrl.Builder urlBuilder = HttpUrl.parse(apiUrl()).newBuilder()
            .addQueryParameter("v", VERSION);
    if (accessToken != null) urlBuilder.addQueryParameter("oauth_token", accessToken);
    else {
        urlBuilder.addQueryParameter("client_id", clientId)
            .addQueryParameter("client_secret", clientSecret);
    }
    return urlBuilder;
}
 
开发者ID:dan-zx,项目名称:foursquare4j,代码行数:16,代码来源:FoursquareApi.java

示例11: resolve

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
public HttpUrl resolve(HttpUrl base) {
    HttpUrl.Builder builder = base.newBuilder();
    for (String path : mPaths) {
        builder.addPathSegment(path);
    }
    return builder.build();
}
 
开发者ID:Jaspersoft,项目名称:js-android-sdk,代码行数:8,代码来源:PathResolver.java

示例12: buildQuery

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Override
void buildQuery(HttpUrl.Builder urlBuilder) {
    urlBuilder.addQueryParameter("ca", toString());
}
 
开发者ID:scarabresearch,项目名称:EmarsysPredictSDKAndroid,代码行数:5,代码来源:Command.java

示例13: getDefaultUrlBuilder

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
protected HttpUrl.Builder getDefaultUrlBuilder() {
    return new HttpUrl.Builder()
            .scheme(ApiConfig.DEFAULT_SCHEME)
            .host(ApiConfig.DEFAULT_HOST)
            .addEncodedPathSegment(ApiConfig.DEFAULT_PREFIX_PATH_SEGMENT);
}
 
开发者ID:sckm,项目名称:ProconAppAndroid,代码行数:7,代码来源:BaseApi.java


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