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


Java RequestHandle类代码示例

本文整理汇总了Java中com.loopj.android.http.RequestHandle的典型用法代码示例。如果您正苦于以下问题:Java RequestHandle类的具体用法?Java RequestHandle怎么用?Java RequestHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: executeSample

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public RequestHandle executeSample(final AsyncHttpClient client, final String URL, final Header[] headers, HttpEntity entity, final ResponseHandlerInterface responseHandler) {
    if (client instanceof SyncHttpClient) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                Log.d(LOG_TAG, "Before Request");
                client.get(SynchronousClientSample.this, URL, headers, null, responseHandler);
                Log.d(LOG_TAG, "After Request");
            }
        }).start();
    } else {
        Log.e(LOG_TAG, "Error, not using SyncHttpClient");
    }
    /**
     * SyncHttpClient does not return RequestHandle,
     * it executes each request directly,
     * therefore those requests are not in cancelable threads
     * */
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:SynchronousClientSample.java

示例2: executeSample

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    RequestParams params = new RequestParams();
    params.setUseJsonStreamer(true);
    JSONObject body;
    if (isRequestBodyAllowed() && (body = getBodyTextAsJSON()) != null) {
        try {
            Iterator keys = body.keys();
            Log.d(LOG_TAG, "JSON data:");
            while (keys.hasNext()) {
                String key = (String) keys.next();
                Log.d(LOG_TAG, "  " + key + ": " + body.get(key));
                params.put(key, body.get(key).toString());
            }
        } catch (JSONException e) {
            Log.w(LOG_TAG, "Unable to retrieve a JSON value", e);
        }
    }
    return client.post(this, URL, headers, params,
            RequestParams.APPLICATION_JSON, responseHandler);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:JsonStreamerSample.java

示例3: executeSample

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public RequestHandle executeSample(final AsyncHttpClient client, final String URL, final Header[] headers, HttpEntity entity, final ResponseHandlerInterface responseHandler) {

    final Activity ctx = this;
    FutureTask<RequestHandle> future = new FutureTask<>(new Callable<RequestHandle>() {
        public RequestHandle call() {
            Log.d(LOG_TAG, "Executing GET request on background thread");
            return client.get(ctx, URL, headers, null, responseHandler);
        }
    });

    executor.execute(future);

    RequestHandle handle = null;
    try {
        handle = future.get(5, TimeUnit.SECONDS);
        Log.d(LOG_TAG, "Background thread for GET request has finished");
    } catch (Exception e) {
        Toast.makeText(ctx, e.getMessage(), Toast.LENGTH_LONG).show();
        e.printStackTrace();
    }

    return handle;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:AsyncBackgroundThreadSample.java

示例4: executeSample

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    RequestParams rParams = new RequestParams();
    rParams.put("sample_key", "Sample String");
    try {
        File sample_file = File.createTempFile("temp_", "_handled", getCacheDir());
        rParams.put("sample_file", sample_file);
    } catch (IOException e) {
        Log.e(LOG_TAG, "Cannot add sample file", e);
    }
    return client.post(this, URL, headers, rParams, "multipart/form-data", responseHandler);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ContentTypeForHttpEntitySample.java

示例5: executeSample

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    try {
        RequestParams params = new RequestParams();
        final String contentType = RequestParams.APPLICATION_OCTET_STREAM;
        params.put("fileOne", createTempFile("fileOne", 1020), contentType, "fileOne");
        params.put("fileTwo", createTempFile("fileTwo", 1030), contentType);
        params.put("fileThree", createTempFile("fileThree", 1040), contentType, "customFileThree");
        params.put("fileFour", createTempFile("fileFour", 1050), contentType);
        params.put("fileFive", createTempFile("fileFive", 1060), contentType, "testingFileFive");
        params.setHttpEntityIsRepeatable(true);
        params.setUseJsonStreamer(false);
        return client.post(this, URL, params, responseHandler);
    } catch (FileNotFoundException fnfException) {
        Log.e(LOG_TAG, "executeSample failed with FileNotFoundException", fnfException);
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:FilesSample.java

示例6: call

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Nullable
private static RequestHandle call(int method, Context context, String url, RequestParams params, ResponseHandlerInterface responseHandler) {


    if (NetWorkUtil.isNetWorkConnected(context)) {
        switch (method) {
            case METHOD_GET:
                if (params == null) {
                    return getInstance().get(context, url, responseHandler);
                } else {
                    return getInstance().get(context, url, params, responseHandler);
                }
            case METHOD_POST:
                return getInstance().post(context, url, params, responseHandler);
            default:
                return null;
        }
    } else {
        responseHandler.sendFailureMessage(FAILED_NO_NETWORK, null, null, new NetworkErrorException(MESSAGE_NO_NETWORK));
        return null;
    }
}
 
开发者ID:ZhaoKaiQiang,项目名称:JianDan_AsyncHttpClient,代码行数:23,代码来源:HttpClientProxy.java

示例7: post

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
public static boolean post(String servicePath,
                           String jsonRequest,
                           SEHTTPResponseHandler responseHandler,
                           HashMap<String, String> headers) {
    if (isNetworkUnavailable() || responseHandler == null) {
        return false;
    }
    AsyncHttpClient client = createHttpClient(headers);
    RequestHandle handler = null;
    try {
        handler = client.post(SaltEdgeSDK.getInstance().getContext(),
                getAbsoluteUrl(servicePath),
                new StringEntity(jsonRequest, HTTP.UTF_8),
                SEConstants.MIME_TYPE_JSON,
                responseHandler);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();

    }
    return (handler != null);
}
 
开发者ID:saltedge,项目名称:saltedge-android,代码行数:22,代码来源:SERestClient.java

示例8: likeService

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
public static RequestHandle likeService(Context context, AsyncHttpClient client, LabAsyncHttpResponseHandler handler,
                                           String sid, String serviceName, String serviceAddress, String servicePic
        , String insiderId, String insiderNick, String insiderPic, String insiderCarrer) {
    LabRequestParams params = new LabRequestParams();
    params.setToken(context);
    params.put("sid", sid);
    params.put("type", "1");
    params.put("serviceName", serviceName);
    params.put("serviceAddress", serviceAddress);
    params.put("servicePic", servicePic);
    params.put("insiderId", insiderId);
    params.put("insiderNick", insiderNick);
    params.put("insiderPic", insiderPic);
    params.put("insiderCarrer", insiderCarrer);
    return client.post(context, BusinessHelper.getApiUrl("addLikes"), params, handler);
}
 
开发者ID:MoonRune,项目名称:CuiTrip,代码行数:17,代码来源:ServiceBusiness.java

示例9: modifyUserInfo

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
public static RequestHandle modifyUserInfo(Context context, AsyncHttpClient client, LabAsyncHttpResponseHandler handler,
                                           String realName, String nick,
                                           String gender, String city, String language, String career,
                                           String interests, String sign) {
    LabRequestParams params = new LabRequestParams();
    params.setToken(context);
    params.put("realName", realName);
    params.put("nick", nick);
    params.put("gender", gender);
    params.put("city", city);
    params.put("language", language);
    params.put("career", career);
    params.put("interests", interests);
    params.put("sign", sign);

    return client.post(context, BusinessHelper.getApiUrl("modifyUserInfo"), params, handler);
}
 
开发者ID:MoonRune,项目名称:CuiTrip,代码行数:18,代码来源:UserBusiness.java

示例10: executeSample

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    Intent serviceCall = new Intent(this, ExampleIntentService.class);
    serviceCall.putExtra(ExampleIntentService.INTENT_URL, URL);
    startService(serviceCall);
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:IntentServiceSample.java

示例11: onCancelButtonPressed

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public void onCancelButtonPressed() {
    Log.d(LOG_TAG, String.format("Number of handles found: %d", getRequestHandles().size()));
    int counter = 0;
    for (RequestHandle handle : getRequestHandles()) {
        if (!handle.isCancelled() && !handle.isFinished()) {
            Log.d(LOG_TAG, String.format("Cancelling handle %d", counter));
            Log.d(LOG_TAG, String.format("Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed"));
        } else {
            Log.d(LOG_TAG, String.format("Handle %d already non-cancellable", counter));
        }
        counter++;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:CancelRequestHandleSample.java

示例12: executeSample

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    if (fileSize > 0) {
        // Send a GET query when we know the size of the remote file.
        return client.get(this, URL, headers, null, responseHandler);
    } else {
        // Send a HEAD query to know the size of the remote file.
        return client.head(this, URL, headers, null, responseHandler);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:RangeResponseSample.java

示例13: refreshTokens

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
public static RequestHandle refreshTokens(Context context, String scopes, AsyncHttpResponseHandler handler) {
    SyncHttpClient client = new SyncHttpClient();
    RequestParams params = new RequestParams();
    params.put("client_id", context.getString(R.string.facebook_app_id));
    params.put("redirect_uri", "https://www.facebook.com/connect/login_success.html");
    params.put("response_type", "token");
    params.put("scopes", scopes);
    return client.get("https://www.facebook.com/v2.9/dialog/oauth", params, handler);
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:10,代码来源:Graph.java

示例14: loadMethodHandler

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
/**
 * @return
 */
private static RequestHandle loadMethodHandler() {

    switch (requestMethod) {

        case GET:
            return TamicHttpClient.get(context, path, headers, bodys, new JsonHttpResponseHandler(true));
        case POST:
            return TamicHttpClient.post(context, path, headers, bodys, contentType, new JsonHttpResponseHandler());
        // more .......
    }

    return null;
}
 
开发者ID:Tamicer,项目名称:Tamic_Retrofit,代码行数:17,代码来源:Tamic.java

示例15: get

import com.loopj.android.http.RequestHandle; //导入依赖的package包/类
public RequestHandle get(Context paramContext, String paramString, RequestParams paramRequestParams, AsyncHttpResponseHandler paramAsyncHttpResponseHandler)
{
  String str = getAbsoluteUrl(paramString);
  d("get:" + str);
  d("params:" + paramRequestParams);
  getSyncHttpClient().addHeader("SBAY-API-VER", "1.0");
  return getSyncHttpClient().get(paramContext, str, paramRequestParams, paramAsyncHttpResponseHandler);
}
 
开发者ID:AndyGu,项目名称:ShanBay,代码行数:9,代码来源:BaseSyncHttpClient.java


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