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


Java Call.enqueue方法代码示例

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


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

示例1: post

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
Call post(Callback callback) throws IOException {
    OkHttpClient client = getUnsafeOkHttpClient();
    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    client.setCookieHandler(cookieManager);
    RequestBody requestBody = new FormEncodingBuilder()
            .add("user_id", NetId)
            .add("user_password", password)
            .build();
    Request request = new Request.Builder()
            .url("https://studentmaintenance.webapps.snu.edu.in/students/public/studentslist/studentslist/loginauth")
            .post(requestBody)
            .build();
    Call call = client.newCall(request);
    call.enqueue(callback);
    return call;
}
 
开发者ID:anuragsai97,项目名称:Library-Token-Automation,代码行数:18,代码来源:LoginActivity.java

示例2: enqueue

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
@Override
public void enqueue(final Request request,final Callback<Response> callback) {
    Call call = mClient.newCall(makeRequest(request));
    request.handle().setHandle(new CallHandle(call));
    com.squareup.okhttp.Callback ok2Callback = new com.squareup.okhttp.Callback() {
        @Override
        public void onFailure(com.squareup.okhttp.Request okReq, IOException e) {
            Exception throwable;
            if("Canceled".equals(e.getMessage())){
                throwable = new CanceledException(e);
            }else{
                throwable = e;
            }
            callback.onFailed(request,throwable);
        }

        @Override
        public void onResponse(com.squareup.okhttp.Response response) throws IOException {
            callback.onSuccess(request,response.headers().toMultimap(),new OkResponse(response,request));
        }
    };
    call.enqueue(ok2Callback);
}
 
开发者ID:alexclin0188,项目名称:httplite,代码行数:24,代码来源:Ok2Lite.java

示例3: post

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
/**
 * Send POST request to the server to log the user in or out.
 *
 * @param mode  Mode is used by the server script to differentiate between login and logout.
 *              191: Login
 *              193: Logout
 * @param username The username of user
 * @param password The password of user
 * @param callback The Callback
 * @return Call object
 * @throws IOException
 */
Call post(String mode, String username, String password, Callback callback) throws IOException {
    OkHttpClient client = new OkHttpClient();
    RequestBody formBody = new FormEncodingBuilder()
            .add("mode", mode)
            .add("username", username + "@snu.in")
            .add("password", password)
            .build();
    Request request = new Request.Builder()
            .url("http://192.168.50.1/24online/servlet/E24onlineHTTPClient")
            .post(formBody)
            .build();
    Call call = client.newCall(request);
    call.enqueue(callback);
    return call;
}
 
开发者ID:arafsheikh,项目名称:snu-data-usage,代码行数:28,代码来源:MainActivity.java

示例4: post

import com.squareup.okhttp.Call; //导入方法依赖的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

示例5: post

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
Call post(String url, String json, Callback callback) {
    RequestBody body = RequestBody.create(JSON, json);
    Request request = new Request.Builder()
            .addHeader("Content-Type","application/json")
            .addHeader("Authorization","key=AIzaSyAkeFnKc_r6TJSO7tm5OVnzkbni6dEk4Lw")
            .url(url)
            .post(body)
            .build();
    Call call = client.newCall(request);
    call.enqueue(callback);
    return call;
}
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:13,代码来源:ChatActivity.java

示例6: post

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
Call post(String mode, String username, String password, Callback callback) throws IOException {
    OkHttpClient client = new OkHttpClient();
    RequestBody formBody = new FormEncodingBuilder()
            .add("mode", mode)
            .add("username", username + "@snu.in")
            .add("password", password)
            .build();
    Request request = new Request.Builder()
            .url("http://192.168.50.1/24online/servlet/E24onlineHTTPClient")
            .post(formBody)
            .build();
    Call call = client.newCall(request);
    call.enqueue(callback);
    return call;
}
 
开发者ID:anuragsai97,项目名称:Library-Token-Automation,代码行数:16,代码来源:MainActivity.java

示例7: fillFutureCache

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
/**
 * Makes async segment requests to fill the cache up to a certain level.
 */
private synchronized void fillFutureCache(Representation representation) {
    int segmentsToBuffer = (int)Math.ceil((double)mMinBufferTimeUs / mRepresentation.segmentDurationUs);
    for(int i = mCurrentSegment + 1; i < Math.min(mCurrentSegment + 1 + segmentsToBuffer, mRepresentation.segments.size()); i++) {
        if(!mFutureCache.containsKey(i) && !mFutureCacheRequests.containsKey(i)) {
            Segment segment = representation.segments.get(i);
            Request request = buildSegmentRequest(segment);
            Call call = mHttpClient.newCall(request);
            CachedSegment cachedSegment = new CachedSegment(i, segment, representation); // segment could be accessed through representation by i
            call.enqueue(new SegmentDownloadCallback(cachedSegment));
            mFutureCacheRequests.put(i, call);
        }
    }
}
 
开发者ID:g-marsh,项目名称:MediaPlayer-GregMods,代码行数:17,代码来源:DashMediaExtractor.java

示例8: newRequestCall

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
private void newRequestCall(Callback callback, String url, RequestBody requestBody) {
    Request request = new Request.Builder()
            .url(url)
            .post(requestBody)
            .build();
    Call call = mOkHttpClient.newCall(request);
    call.enqueue(callback);
}
 
开发者ID:macouen,项目名称:lunzi,代码行数:9,代码来源:UploadFileRequest.java

示例9: get

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
public static Call get(String url, Object tag, OkHttpCallback responseCallback) {
    Request.Builder builder = new Request.Builder().url(url);
    if (tag != null) {
        builder.tag(tag);
    }
    Request request = builder.build();
    Call call = getInstance().newCall(request);
    call.enqueue(responseCallback);
    return call;
}
 
开发者ID:ZhaoKaiQiang,项目名称:JianDan_OkHttp,代码行数:11,代码来源:OkHttpProxy.java

示例10: request

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
void request(RequestType mRequestType, OkHttpClient mOkHttpClient, String url, Header[] headers, Object tag, BaseApiHandler baseHandler) {
    Request.Builder mBuilder = new Request.Builder();

    mBuilder.url(url);
    if (mRequestType == RequestType.GET) {
        mBuilder.get();
    } else {
        mBuilder.post(null);
    }


    if (headers != null) {
        Headers.Builder mHB = new Headers.Builder();
        for (int i = 0; i < headers.length; i++) {
            String value = headers[i].getValue();
            String key = headers[i].getName();
            mHB.add(key, value);


        }
        Headers mHeader = mHB.build();
        mBuilder.headers(mHeader);
    }


    mBuilder.tag(tag);


    Call mCall = mOkHttpClient.newCall(mBuilder.build());
    mCall.enqueue(baseHandler);
}
 
开发者ID:JuMiGe,项目名称:CopyOfNetEase,代码行数:32,代码来源:RestHttpClient.java

示例11: get

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
public static Call get(String url, Callback callback) {
    Request request = new Request.Builder().url(url).build();
    Call call = getHttpClient().newCall(request);
    call.enqueue(callback);
    return call;
}
 
开发者ID:xxxifan,项目名称:StunnelAndroid,代码行数:7,代码来源:HttpUtils.java

示例12: post

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
public static Call post(String url, RequestBody body, Callback callback) {
    Request request = new Request.Builder().url(url).post(body).build();
    Call call = getHttpClient().newCall(request);
    call.enqueue(callback);
    return call;
}
 
开发者ID:xxxifan,项目名称:StunnelAndroid,代码行数:7,代码来源:HttpUtils.java

示例13: send

import com.squareup.okhttp.Call; //导入方法依赖的package包/类
@Override
   public void send(final URL webhookUrl, final String payload) {
Request request = new Builder().url(webhookUrl).post(RequestBody.create(JSON, payload)).build();
Call call = okHttpClient.newCall(request);
call.enqueue(RESPONSE_CALLBACK);
   }
 
开发者ID:tobias-,项目名称:slack-appender,代码行数:7,代码来源:OkHttp2Client.java


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