@Override public Result loadInBackground() { final Fetch fetch = mFetch; final HttpConnectionHelper helper = mHelper; List<NameValuePair> parameters = mParameterExtractor.extract(fetch); HttpUriRequest request = helper.obtainHttpRequest(fetch.getFetchMethod(), fetch.getUrl(), parameters); Utils.debug(request.getURI().toString()); if (fetch.onPreFetch(request, Collections.unmodifiableList(parameters))) { return mResult; } HttpResponse response = helper.execute(request); fetch.onPostFetch(request); if (null == response) { return null; } try { Result result = mResult = mParser.parse(fetch, new InputStreamReader(response.getEntity().getContent())); Utils.debug(result); return result; } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
public RemoteAsyncTaskLoader( Context context, Fetch fetch, Parser<Reader, ? extends Result, ?> parser, FetchParameterExtractor extractor) { super(context); mHelper = HttpConnectionHelper.getInstance(); mFetch = fetch; mParser = parser; mParameterExtractor = null == extractor ? new BaseFetchParameterExtractor() : extractor; }