package hu.kojak.android.restservice.restapi;

import android.annotation.TargetApi;
import android.os.AsyncTask;
import android.os.Build;

/**
 * This class has an exec() method, which calls the appropriate execute() method to be API
 * level safe!
 */
public abstract class ApiAsyncTask<Params, Progress, Result>
        extends AsyncTask<Params, Progress, Result> {

  @TargetApi(11)
  @SuppressWarnings("unchecked")
  public final void exec(Params... params) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    } else {
      execute(params);
    }
  }
}

@@ -130,16 +130,98 @@
 s.Build;
+%0Aimport android.util.Log;%0A%0Aimport java.util.concurrent.RejectedExecutionException;
 %0A%0A/**%0A *
@@ -494,16 +494,143 @@
 ecked%22)%0A
+  /**%0A   * Returns true if execution started without problem, false if cannot start asynctask because%0A   * pool is full.%0A   */%0A
   public
@@ -640,12 +640,15 @@
 nal 
-void
+boolean
  exe
@@ -665,24 +665,36 @@
 . params) %7B%0A
+    try %7B%0A  
     if (Buil
@@ -749,24 +749,26 @@
 MB) %7B%0A      
+ 
+ 
 executeOnExe
@@ -818,16 +818,18 @@
 s);%0A    
+  
 %7D else %7B
@@ -829,16 +829,18 @@
  else %7B%0A
+  
       ex
@@ -850,24 +850,167 @@
 te(params);%0A
+      %7D%0A      return true;%0A    %7D catch (RejectedExecutionException e) %7B%0A      Log.d(%22kojak%22, %22thread pool is full :(%22, e);%0A      return false;%0A
     %7D%0A  %7D%0A%7D%0A

Comment added.