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


Java FormEncodingBuilder.build方法代码示例

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


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

示例1: buildRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
@Override
protected RequestBody buildRequestBody()
{
    RequestBody requestBody = null;
    switch (type)
    {
        case TYPE_PARAMS:
            FormEncodingBuilder builder = new FormEncodingBuilder();
            addParams(builder, params);
            requestBody = builder.build();
            break;
        case TYPE_BYTES:
            requestBody = RequestBody.create(MEDIA_TYPE_STREAM, bytes);
            break;
        case TYPE_FILE:
            requestBody = RequestBody.create(MEDIA_TYPE_STREAM, file);
            break;
        case TYPE_STRING:
            requestBody = RequestBody.create(MEDIA_TYPE_STRING, content);
            break;
    }
    return requestBody;
}
 
开发者ID:dscn,项目名称:ktball,代码行数:24,代码来源:OkHttpPostRequest.java

示例2: buildRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
@Override
protected RequestBody buildRequestBody()
{
    validParams();
    RequestBody requestBody = null;


    switch (type)
    {
        case TYPE_PARAMS:
            FormEncodingBuilder builder = new FormEncodingBuilder();
            addParams(builder, params);
            requestBody = builder.build();
            break;
        case TYPE_BYTES:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STREAM, bytes);
            break;
        case TYPE_FILE:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STREAM, file);
            break;
        case TYPE_STRING:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STRING, content);
            break;
    }
    return requestBody;
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:27,代码来源:OkHttpPostRequest.java

示例3: basePost

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
protected void basePost(String url, Map<String, String> params, CallbackListener<T> listener)
{
    if (params == null) {
       baseGet(url,listener);return;
    }
    FormEncodingBuilder builder = new FormEncodingBuilder();
    Set<Map.Entry<String, String>> entrySet = params.entrySet();
    for (Map.Entry<String, String> entry : entrySet) {
        builder.add(entry.getKey(), entry.getValue());
    }
    RequestBody requestBody = builder.build();
    Request request = new Request.Builder()
            .url(url)
            .post(requestBody)
            .tag(url)
            .build();
    doRequest(request, listener);
}
 
开发者ID:duguju,项目名称:MousePaintYzz,代码行数:19,代码来源:BaseHttp.java

示例4: buildPostFormRequest

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private Request buildPostFormRequest(String url, Param[] params, Object tag) {
    if (params == null) {
        params = new Param[0];
    }
    FormEncodingBuilder builder = new FormEncodingBuilder();
    for (Param param : params) {
        builder.add(param.key, param.value);
    }
    RequestBody requestBody = builder.build();


    Request.Builder reqBuilder = new Request.Builder();
    reqBuilder.url(url)
            .post(requestBody);

    if (tag != null) {
        reqBuilder.tag(tag);
    }
    return reqBuilder.build();
}
 
开发者ID:pengwei1024,项目名称:AndroidGeek,代码行数:21,代码来源:OkHttpClientManager.java

示例5: buildRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
@Override
protected RequestBody buildRequestBody() {
    validParams();
    RequestBody requestBody = null;


    switch (type) {
        case TYPE_PARAMS:
            FormEncodingBuilder builder = new FormEncodingBuilder();
            addParams(builder, params);
            requestBody = builder.build();
            break;
        case TYPE_BYTES:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STREAM, bytes);
            break;
        case TYPE_FILE:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STREAM, file);
            break;
        case TYPE_STRING:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STRING, content);
            break;
    }
    return requestBody;
}
 
开发者ID:bmbstack,项目名称:android-kit-old,代码行数:25,代码来源:OkHttpPostRequest.java

示例6: post

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
public static Call post(String url, Map<String, String> params, Object tag, OkHttpCallback responseCallback) {

        Request.Builder builder = new Request.Builder().url(url);
        if (tag != null) {
            builder.tag(tag);
        }

        FormEncodingBuilder encodingBuilder = new FormEncodingBuilder();

        if (params != null && params.size() > 0) {
            for (String key : params.keySet()) {
                encodingBuilder.add(key, params.get(key));
            }
        }

        RequestBody formBody = encodingBuilder.build();
        builder.post(formBody);

        Request request = builder.build();
        Call call = getInstance().newCall(request);
        call.enqueue(responseCallback);
        return call;
    }
 
开发者ID:ZhaoKaiQiang,项目名称:JianDan_OkHttp,代码行数:24,代码来源:OkHttpProxy.java

示例7: buildPostRequest

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private Request buildPostRequest(String url, Param[] params) {
    if (params == null) {
        params = new Param[0];
    }
    FormEncodingBuilder builder = new FormEncodingBuilder();
    for (Param param : params) {
        builder.add(param.key, param.value);
    }
    RequestBody requestBody = builder.build();
    return new Request.Builder()
            .url(url)
            .post(requestBody)
            .build();
}
 
开发者ID:NaOHAndroid,项目名称:Logistics-guard,代码行数:15,代码来源:OkHttpClientManager.java

示例8: buildRequestBodyFormEncoding

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
/**
 * Build a form-encoding request body with the given form parameters.
 *
 * @param formParams Form parameters in the form of Map
 * @return RequestBody
 */
public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams) {
    FormEncodingBuilder formBuilder  = new FormEncodingBuilder();
    for (Entry<String, Object> param : formParams.entrySet()) {
        formBuilder.add(param.getKey(), parameterToString(param.getValue()));
    }
    return formBuilder.build();
}
 
开发者ID:ina-foss,项目名称:afp-api-client,代码行数:14,代码来源:ApiClient.java

示例9: buildPostRequest

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private Request buildPostRequest(String url, List<Param> params) {
    FormEncodingBuilder builder = new FormEncodingBuilder();
    for (Param param : params) {
        builder.add(param.key, param.value);
    }
    RequestBody requestBody = builder.build();
    return new Request.Builder().url(url).post(requestBody).build();
}
 
开发者ID:whiskeyfei,项目名称:SimpleNews.io,代码行数:9,代码来源:OkHttpUtils.java

示例10: generateRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private static final RequestBody generateRequestBody(Map<String, String> params) {
    RequestBody requestBody = null;
    if (params != null) {
        FormEncodingBuilder encoding = new FormEncodingBuilder();
        for (Map.Entry<String, String> entry : params.entrySet()) {
            encoding.add(entry.getKey(), entry.getValue());
        }
        requestBody = encoding.build();
    }
    return requestBody;
}
 
开发者ID:binkery,项目名称:allinone,代码行数:12,代码来源:Http.java

示例11: buildRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
public static RequestBody buildRequestBody(ContentValues values) {
    FormEncodingBuilder builder = new FormEncodingBuilder();

    if (values == null || values.size() == 0) {
        return builder.build();
    }

    Set<String> ketSet = values.keySet();

    for (String param : ketSet) {
        builder.add(param, values.get(param).toString());
    }

    return builder.build();
}
 
开发者ID:dcf82,项目名称:TwitterRestfulAPI,代码行数:16,代码来源:OkHttpUtil.java

示例12: buildPostRequest

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private Request buildPostRequest(String url, Param[] params) {
	if (params == null) {
		params = new Param[0];
	}
	FormEncodingBuilder builder = new FormEncodingBuilder();
	for (Param param : params) {
		builder.add(param.key, param.value);
	}
	RequestBody requestBody = builder.build();
	return new Request.Builder().url(url).post(requestBody).build();
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:12,代码来源:OkHttpClientManager.java

示例13: buildInitialRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private RequestBody buildInitialRequestBody() {
    FormEncodingBuilder postdata = new FormEncodingBuilder();
    if (TransactionType.Bevo.equals(mType)) {
        postdata.add("sRequestSw", "B");
    } else if (TransactionType.Dinein.equals(mType)) {
        postdata.add("rRequestSw", "B");
    }
    return postdata.build();
}
 
开发者ID:NasaGeek,项目名称:utexas-utilities,代码行数:10,代码来源:TransactionsFragment.java

示例14: builderFormData

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private RequestBody builderFormData(Map<String, Object> params) {


        FormEncodingBuilder builder = new FormEncodingBuilder();

        if (params != null) {


            for (Map.Entry<String, Object> entry : params.entrySet()) {

                builder.add(entry.getKey(), entry.getValue() == null ? "" : entry.getValue().toString());
            }

            String token = App.getInstance().getToken();
            if (!TextUtils.isEmpty(token))
                builder.add("token", token);
        }

        return builder.build();

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:OkHttpHelper.java

示例15: builderFormData

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private RequestBody builderFormData(Map<String,Object> params){


            FormEncodingBuilder builder = new FormEncodingBuilder();

            if(params !=null){



                for (Map.Entry<String,Object> entry :params.entrySet() ){

                    builder.add(entry.getKey(),entry.getValue()==null?"":entry.getValue().toString());
                }

                String token = CniaoApplication.getInstance().getToken();
                if(!TextUtils.isEmpty(token))
                    builder.add("token", token);
            }

            return  builder.build();

        }
 
开发者ID:zzlnewair,项目名称:Myshop,代码行数:23,代码来源:OkHttpHelper.java


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