Java 类com.loopj.android.http.SyncHttpClient 实例源码

项目:GitHub    文件:SynchronousClientSample.java   
@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;
}
项目:GitHub    文件:SynchronousClientSample.java   
@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;
}
项目:Benefit_mvvm    文件:Repository.java   
@NonNull
private SyncHttpClient getUnsafeSyncHttpClient() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, KeyManagementException, UnrecoverableKeyException {
    // We initialize a default Keystore
    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    // We load the KeyStore
    trustStore.load(null, null);
    // We initialize a new SSLSocketFactory
    MySSLSocketFactory socketFactory = new MySSLSocketFactory(trustStore);
    // We set that all host names are allowed in the socket factory
    socketFactory.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    // We initialize the Async Client
    SyncHttpClient client = new SyncHttpClient();
    // We set the timeout to 30 seconds
    client.setTimeout(TIMEOUT);
    // We set the SSL Factory
    client.setSSLSocketFactory(socketFactory);
    client.setEnableRedirects(true);
    client.setUserAgent("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
    return client;
}
项目:WeiboWeiBaTong    文件:SynchronousClientSample.java   
@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;
}
项目:WeiboWeiBaTong    文件:SynchronousClientSample.java   
@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;
}
项目:UltimateAndroid    文件:HttpUtilsAsync.java   
/**
 * Upload files with {@link com.loopj.android.http.SyncHttpClient}
 *
 * @param url
 * @param paramsList
 * @param fileParams
 * @param files
 * @param responseHandler
 */
public static void uploadFiles(String url, List<NameValuePair> paramsList, String fileParams, List<File> files, AsyncHttpResponseHandler responseHandler) throws Exception {
    SyncHttpClient syncHttpClient = new SyncHttpClient();
    RequestParams params = new RequestParams();

    if (BasicUtils.judgeNotNull(paramsList)) {
        for (NameValuePair nameValuePair : paramsList) {
            params.put(nameValuePair.getName(), nameValuePair.getValue());
        }
    }
    if (BasicUtils.judgeNotNull(files))
        params.put(fileParams, files);

    syncHttpClient.setTimeout(timeout);
    syncHttpClient.post(url, params, responseHandler);
}
项目:android-http    文件:BaseGsonLoader.java   
/**
 * Creates new instance of {@link BaseGsonLoader} that is going to execute HTTP GET method with no url parameters.
 * Use set methods provided by this class to customize http request.
 * 
 * @param context used by loader.
 * @param url for HTTP request.
 */
public BaseGsonLoader(Context context, String url) {
    super(context);

    this.syncHttpClient = new SyncHttpClient() {

        @Override
        public String onRequestFailed(Throwable error, String content) {
            errorThrowable = error;
            errorResponse = content;
            return null;
        }
    };

    this.url = url;
    this.requestParams = null;
    this.httpMethod = HttpMethod.GET;
    this.headers = null;
    this.entity = null;
    this.contentType = null;
}
项目:FBEventSync    文件:Graph.java   
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);
}
项目:MHttp    文件:MHttpAsync.java   
private void init() {
    asyncHttpClient = new SyncHttpClient();
    asyncHttpClient.setTimeout(60 * 1000);
    asyncHttpClient.setSSLSocketFactory(MySSLSocketFactory.getFixedSocketFactory());
    asyncHttpClient.setCookieStore(new BasicCookieStore());//new PersistentCookieStore(context);
    addHeader("Accept", "application/json;");
    addHeader("Connection", "keep-alive");
}
项目:iTongJi-App    文件:NetWorkManager.java   
private NetWorkManager() {
        xuankeHttpClient = new SyncHttpClient();
        benyanHttpClient = new SyncHttpClient();
        cardRestHttpClient = new SyncHttpClient();
        cookies4m3 = new HashMap<>();
//        semaphore = new Semaphore(networkThreadCnt, true);
    }
项目:UltimateAndroid    文件:HttpUtilsAsync.java   
/**
 * Upload file with {@link com.loopj.android.http.SyncHttpClient}
 *
 * @param url
 * @param paramsList
 * @param fileParams
 * @param file
 * @param responseHandler
 * @throws FileNotFoundException
 */
public static void uploadFile(String url, List<NameValuePair> paramsList, String fileParams, File file, AsyncHttpResponseHandler responseHandler) throws FileNotFoundException {
    SyncHttpClient syncHttpClient = new SyncHttpClient();
    RequestParams params = new RequestParams();
    if (BasicUtils.judgeNotNull(paramsList)) {
        for (NameValuePair nameValuePair : paramsList) {
            params.put(nameValuePair.getName(), nameValuePair.getValue());
        }
    }
    if (BasicUtils.judgeNotNull(file))
        params.put(fileParams, file);
    syncHttpClient.setTimeout(timeout);
    syncHttpClient.post(url, params, responseHandler);
}
项目:GitHub    文件:SynchronousClientSample.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setAsyncHttpClient(new SyncHttpClient());
}
项目:GitHub    文件:SynchronousClientSample.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setAsyncHttpClient(new SyncHttpClient());
}
项目:FBEventSync    文件:Graph.java   
public static RequestHandle events(String accessToken, RequestParams params, AsyncHttpResponseHandler handler) {
    SyncHttpClient client = new SyncHttpClient();
    params.add(ACCESS_TOKEN_PARAM, accessToken);
    return client.get(BASE_URL + "/me/events", params, handler);
}
项目:FBEventSync    文件:Graph.java   
public static RequestHandle fetchBirthdayICal(String birthdayICalUri, AsyncHttpResponseHandler handler) {
    SyncHttpClient client = new SyncHttpClient();
    // Pretend we are cURL, so that Facebook does not redirect us to facebook.com/unsupportedbrowser
    client.setUserAgent("curl/7.55.1");
    return client.get(birthdayICalUri, handler);
}
项目:photobook    文件:WSyncCommunication.java   
public Builder(Context context) {
    syncClient = new SyncHttpClient();
    this.context = context.getApplicationContext();
}
项目:WeiboWeiBaTong    文件:SynchronousClientSample.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setAsyncHttpClient(new SyncHttpClient());
}
项目:iTongJi-App    文件:NetWorkManager.java   
public SyncHttpClient getCardRestHttpClient() {
    return cardRestHttpClient;
}
项目:iTongJi-App    文件:NetWorkManager.java   
public SyncHttpClient getXuanKeHttpClient() {
    return xuankeHttpClient;
}
项目:iTongJi-App    文件:NetWorkManager.java   
public SyncHttpClient getBenyanHttpClient() {
    return benyanHttpClient;
}
项目:iTongJi-App    文件:NetWorkManager.java   
public void resetBenYanHttpClient() {
    benyanHttpClient = new SyncHttpClient();
}
项目:iTongJi-App    文件:NetWorkManager.java   
public void resetXuankeHttpClient() {
    xuankeHttpClient = new SyncHttpClient();
}
项目:iTongJi-App    文件:NetWorkManager.java   
public void resetCardRestHttpClient() {
    cardRestHttpClient = new SyncHttpClient();
}
项目:CuiTrip    文件:PagedEndlessAdapter.java   
private SyncHttpClient createClient() {
    return new SyncHttpClient();
}
项目:libtincent    文件:TXHttpUtil.java   
/**
 * @return 同步网络请求客户端
 */
public AsyncHttpClient getSyncHttpClient() {
    return new SyncHttpClient();
}
项目:ShanBay    文件:BaseSyncHttpClient.java   
public SyncHttpClient getSyncHttpClient()
{
  return this.client;
}
项目:WeiboWeiBaTong    文件:SynchronousClientSample.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setAsyncHttpClient(new SyncHttpClient());
}
项目:android_http_demo    文件:DownloadTask.java   
private SyncHttpClient getSyncHttpClient() {

        return new SyncHttpClient();
    }
项目:android-http    文件:BaseGsonLoader.java   
/**
 * Get syncronus client. Syncronus client is since everything happens in loader thread.
 * 
 * @return {@link SyncHttpClient} used by loader.
 */
public SyncHttpClient getSyncClient() {
    return syncHttpClient;
}