package me.thekey.android.lib;

import static me.thekey.android.lib.Constant.REDIRECT_URI;
import me.thekey.android.TheKeySocketException;
import android.annotation.TargetApi;
import android.os.AsyncTask;
import android.os.Build;

public abstract class CodeGrantAsyncTask extends AsyncTask<String, Void, Boolean> {
    protected final TheKeyImpl thekey;

    public CodeGrantAsyncTask(final TheKeyImpl thekey) {
        this.thekey = thekey;
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public final AsyncTask<String, Void, Boolean> execute(final String code) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            return this.executeOnExecutor(THREAD_POOL_EXECUTOR, new String[] { code });
        } else {
            return this.execute(new String[] { code });
        }
    }

    @Override
    protected final Boolean doInBackground(final String... code) {
        if (code.length > 0) {
            try {
                return this.thekey.processCodeGrant(code[0], REDIRECT_URI);
            } catch (final TheKeySocketException e) {
                return false;
            }
        } else {
            return false;
        }
    }
}

@@ -88,107 +88,63 @@
 RI;%0A
+%0A
 import 
-me.thekey.android.TheKeySocketException;%0Aimport android.annotation.TargetApi;%0Aimport android
+android.os.AsyncTask;%0Aimport android.support.v4
 .os.
@@ -156,33 +156,63 @@
 Task
+Compat
 ;%0A
+%0A
 import 
-android.os.Build
+me.thekey.android.TheKeySocketException
 ;%0A%0Ap
@@ -432,54 +432,8 @@
  %7D%0A%0A
-    @TargetApi(Build.VERSION_CODES.HONEYCOMB)%0A
     
@@ -519,240 +519,59 @@
     
-if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.HONEYCOMB) %7B%0A            return this.executeOnExecutor(THREAD_POOL_EXECUTOR, new String%5B%5D %7B code %7D);%0A        %7D else %7B%0A            return this.execute(new String%5B%5D %7B code %7D);%0A        %7D
+return AsyncTaskCompat.executeParallel(this, code);
 %0A   

use AsyncTaskCompat instead of implementing our own branch logic