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


Java FormEncodingBuilder.add方法代码示例

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


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

示例1: doInBackground

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
/**
 *
 * @param params
 * @return
 */
@Override
protected String doInBackground(Void... params) {
    OkHttpClient client = new OkHttpClient();

    HttpUrl httpUrl = HttpUrl.parse(COIN_DESK_API_URL);
    //System.out.println("Requesting : " + httpUrl.toString());

    FormEncodingBuilder formBody = new FormEncodingBuilder();
    formBody.add("lastHours", "24");
    formBody.add("maxRespArrSize", "24");

    Request request = new Request.Builder()
            .url(httpUrl)
            .post(formBody.build())
            .build();

    String content = null;
    try {
        Response response = client.newCall(request).execute();
        ResponseBody body = response.body();

        if (isZipped(response)) {
            content = unzip(body);
        } else {
            content = body.string();
        }

        body.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return content;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:40,代码来源:CexChartAPI.java

示例2: addParams

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private void addParams(FormEncodingBuilder builder, Map<String, String> params)
{
    if (builder == null)
    {
        throw new IllegalArgumentException("builder can not be null .");
    }

    if (params != null && !params.isEmpty())
    {
        for (String key : params.keySet())
        {
            builder.add(key, params.get(key));
            LogUtils.e(key+":"+params.get(key));
        }
    }
}
 
开发者ID:dscn,项目名称:ktball,代码行数:17,代码来源: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: register

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
@OnClick(R.id.btn_register_submit)
void register() {
    showProgressDialog("正在注册,请稍后...");
    String mobile = etMobile.getText().toString();
    String nickname = etNickname.getText().toString();
    if (!StringUtils.isPhone(mobile)) {
        UIHelper.showToast("请输入正确的手机号~");
        return;
    }
    if (!StringUtils.isNick(nickname)) {
        UIHelper.showToast("请输入昵称(不能是中文)~");
        return;
    }
    FormEncodingBuilder builder = new FormEncodingBuilder();
    builder.add("phone", mobile);
    builder.add("nickname", nickname);
    TaskQueue.getDefault().addSerially(getCallable(AppConfig.REGISTER_URL, builder), callback, this);
}
 
开发者ID:brucewuu520,项目名称:Qianlichuanyin,代码行数:19,代码来源:RegisterActivity.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: doInBackground

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
/**
 *
 * @param params
 * @return
 */
@Override
protected String doInBackground(Void... params) {

    OkHttpClient client = new OkHttpClient();

    String cred = Credentials.basic(_key, _secret);

    FormEncodingBuilder formBody = new FormEncodingBuilder();
    formBody.add("grant_type", "client_credentials");

    Request request = new Request.Builder()
            .url(TWITTER_AUTH_URL)
            .post(formBody.build())
            .addHeader("Authorization", cred)
            .addHeader("ContentType", "application/x-www-form-urlencoded;charset=UTF-8")
            .addHeader("Accept-Encoding", "gzip")
            .build();

    try {
        Response response = client.newCall(request).execute();

        if (isZipped(response)) {
            return unzip(response.body());
        } else {
            return response.body().string();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:37,代码来源:TwitterAuthApi.java

示例10: addParams

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private void addParams(FormEncodingBuilder builder)
{
    if (params == null || params.isEmpty())
    {
        builder.add("1", "1");
        return;
    }

    for (String key : params.keySet())
    {
        builder.add(key, params.get(key));
    }
}
 
开发者ID:iQuick,项目名称:NewsMe,代码行数:14,代码来源:PostFormRequest.java

示例11: postItem

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private void postItem(String name, final int pos) {
    hideFab();
    FormEncodingBuilder feb = ConnectionUtils.febWithViewStates(user.getViewStates());
    boolean hasCheckedItem = false;
    for (OrderItem orderItem : orderItems) {
        if (orderItem.isChecked) {
            feb.add(orderItem.name, ON);
            hasCheckedItem = true;
        }
    }
    final boolean finalHasCheckItem = hasCheckedItem;
    RequestBody formBody = feb.add(EVENT_TARGET, name)
            .add(EVENT_ARG, "").build();
    Subscription sub = RetrofitManager.api().postOrder(formBody)
            .retry(1)
            .compose(this.bindUntilEvent(ActivityEvent.STOP))
            .cast(Document.class)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Subscriber<Document>() {
                @Override
                public void onCompleted() {
                    if (finalHasCheckItem) showFab();
                }

                @Override
                public void onError(Throwable e) {
                    if (finalHasCheckItem) showFab();
                    rvAdapter.progressDone(false, pos);
                }

                @Override
                public void onNext(Document document) {
                    rvAdapter.progressDone(true, pos);
                    harcananText.setText(document.getElementById(HARCANAN_BAKIYE).text().replace("TL", " TL"));
                    kalanText.setText(document.getElementById(KALAN_BAKIYE).text().replace("TL", " TL"));
                }
            });
    subs.add(sub);
}
 
开发者ID:y3seker,项目名称:EgeYemekhaneMobil,代码行数:41,代码来源:OrderActivity.java

示例12: postTheOrder

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private void postTheOrder() {
    showProgressDialog("Sipariş işleniyor");
    FormEncodingBuilder feb = ConnectionUtils.febWithViewStates(user.getViewStates());
    for (OrderItem orderItem : orderItems) {
        if (orderItem.isChecked) {
            feb.add(orderItem.name, "on");
        }
    }
    RequestBody postOrderBody = feb
            .add(EVENT_TARGET, "")
            .add(EVENT_ARG, "")
            .add("ctl00$ContentPlaceHolder1$Button3", NEXT)
            .build();
    RetrofitManager.api().postOrder(postOrderBody)
            .retry(1)
            .compose(this.bindToLifecycle())
            .cast(Document.class)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new HandlerSubscriber() {
                @Override
                public void onException(Throwable e) {
                    super.onException(e);
                    dismissProgressDialog();
                    onFailed(R.string.connection_error, Snackbar.LENGTH_LONG, null);
                }

                @Override
                public void onDone(Document document) {
                    super.onDone(document);
                    dismissProgressDialog();
                    orderControlDialog(document);
                }
            });
}
 
开发者ID:y3seker,项目名称:EgeYemekhaneMobil,代码行数:36,代码来源:OrderActivity.java

示例13: postTheCancel

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private void postTheCancel() {
    fab.hide();
    showProgressBar();
    FormEncodingBuilder feb = ConnectionUtils.febWithViewStates(user.getViewStates());
    for (CancelItem cancelItem : cancelItems) {
        if (cancelItem.isChecked) {
            feb.add(cancelItem.name, "on");
        }
    }
    RequestBody formBody = feb
            .add(ParseConstants.EVENT_TARGET, "ctl00$ContentPlaceHolder1$Button2")
            .add(ParseConstants.EVENT_ARG, "")
            .build();
    RetrofitManager.api().postCancel(formBody)
            .retry(1)
            .compose(this.bindToLifecycle())
            .cast(Document.class)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new HandlerSubscriber() {
                @Override
                public void onException(Throwable e) {
                    super.onException(e);
                    hideProgressBar();
                    onFailed(R.string.connection_error, new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            postTheCancel();
                        }
                    });
                }

                @Override
                public void onDone(Document document) {
                    super.onDone(document);
                    changeItemsUI(document);
                }
            });
}
 
开发者ID:y3seker,项目名称:EgeYemekhaneMobil,代码行数:40,代码来源:CancelActivity.java

示例14: addParams

import com.squareup.okhttp.FormEncodingBuilder; //导入方法依赖的package包/类
private void addParams(FormEncodingBuilder builder, Map<String, String> params)
{
    if (builder == null)
    {
        throw new IllegalArgumentException("builder can not be null .");
    }

    if (params != null && !params.isEmpty())
    {
        for (String key : params.keySet())
        {
            builder.add(key, params.get(key));
        }
    }
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:16,代码来源:OkHttpPostRequest.java

示例15: 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


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