use of cz.msebera.android.httpclient.impl.client.CloseableHttpClient in project Simple-Dilbert by smarek.
the class GetStripUrl method doInBackground.
@Override
protected String[] doInBackground(Void... params) {
if (this.currDate == null) {
Log.e(TAG, "Cannot load for null date");
return null;
}
String cached = this.preferences.getCachedUrl(this.currDate);
if (cached != null) {
return new String[] { cached, this.preferences.getCachedTitle(this.currDate) };
}
HttpGet get = new HttpGet("http://dilbert.com/strip/" + currDate.toString(DilbertPreferences.DATE_FORMATTER) + "/");
HttpResponse response = null;
CloseableHttpClient client = null;
try {
client = HttpClients.createSystem();
response = client.execute(get);
} catch (Exception e) {
Log.e(TAG, "HttpGet failed", e);
}
if (response == null) {
return null;
}
String[] rtn = handleParse(response);
try {
client.close();
} catch (IOException e) {
Log.e(TAG, "Closing HttpClient failed", e);
}
return rtn;
}
Aggregations