Back to project page android-deferred-object.
The source code is released under:
GNU General Public License
If you think the Android project android-deferred-object listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.codeandmagic.deferredobject.android; /* w w w . ja va 2s.c o m*/ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class DeferredHttpUrlConnection extends DeferredAsyncTask<HttpURLConnection, HttpURLConnection, Float> { private final URL url; public DeferredHttpUrlConnection(URL url) { this.url = url; } protected HttpURLConnection onPreExecute(HttpURLConnection connection) { return connection; } @Override protected HttpURLConnection convertResultToFailure(HttpURLConnection resolved) { try { if (resolved.getResponseCode() >= 300) return resolved; else return null; } catch (IOException e) { return resolved; } } @Override protected HttpURLConnection doInBackground() throws Exception { final HttpURLConnection connection = onPreExecute((HttpURLConnection) url.openConnection()); connection.getInputStream(); return connection; } }