execute api requests on a thread pool

This commit is contained in:
Andrew Dolgov 2013-05-23 14:42:20 +04:00
parent 327f1af0ba
commit e3575f6be8

View File

@ -17,6 +17,7 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
@ -64,6 +65,15 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
} }
@SuppressLint("NewApi")
@SuppressWarnings("unchecked")
public void execute(HashMap<String,String> map) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
super.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, map);
else
super.execute(map);
}
protected int getErrorMessage() { protected int getErrorMessage() {
switch (m_lastError) { switch (m_lastError) {
case NO_ERROR: case NO_ERROR: