Search in sources :

Example 1 with BasicResponseHandler

use of cz.msebera.android.httpclient.impl.client.BasicResponseHandler in project cw-omnibus by commonsguy.

the class LoadThread method run.

@Override
public void run() {
    try {
        HttpClient client = HttpClientBuilder.create().setConnectionManager(new PoolingHttpClientConnectionManager()).build();
        HttpGet get = new HttpGet(SO_URL);
        try {
            String result = client.execute(get, new BasicResponseHandler());
            SOQuestions questions = new Gson().fromJson(result, SOQuestions.class);
            EventBus.getDefault().post(new QuestionsLoadedEvent(questions));
        } catch (IOException e) {
            Log.e(getClass().getSimpleName(), "Exception parsing JSON", e);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "Exception parsing JSON", e);
    }
}
Also used : HttpClient(cz.msebera.android.httpclient.client.HttpClient) HttpGet(cz.msebera.android.httpclient.client.methods.HttpGet) BasicResponseHandler(cz.msebera.android.httpclient.impl.client.BasicResponseHandler) Gson(com.google.gson.Gson) IOException(java.io.IOException) IOException(java.io.IOException) PoolingHttpClientConnectionManager(cz.msebera.android.httpclient.impl.conn.PoolingHttpClientConnectionManager)

Aggregations

Gson (com.google.gson.Gson)1 HttpClient (cz.msebera.android.httpclient.client.HttpClient)1 HttpGet (cz.msebera.android.httpclient.client.methods.HttpGet)1 BasicResponseHandler (cz.msebera.android.httpclient.impl.client.BasicResponseHandler)1 PoolingHttpClientConnectionManager (cz.msebera.android.httpclient.impl.conn.PoolingHttpClientConnectionManager)1 IOException (java.io.IOException)1