@Config(reportSdk = VERSION_CODES.GINGERBREAD_MR1) @Test public void safeExecuteOnExecutor_beforeHoneycomb_shouldCallExecuteWithParams() throws Exception { AsyncTasks.safeExecuteOnExecutor(asyncTask, "hello"); verify(asyncTask).execute(eq("hello")); }
@TargetApi(VERSION_CODES.HONEYCOMB) public static <P> void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params) { Preconditions.checkNotNull(asyncTask, "Unable to execute null AsyncTask."); Preconditions.checkUiThread("AsyncTask must be executed on the main thread"); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { asyncTask.executeOnExecutor(sExecutor, params); } else { asyncTask.execute(params); } }
AsyncTasks { @TargetApi(VERSION_CODES.HONEYCOMB) public static <P> void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params) { Preconditions.checkNotNull(asyncTask, "Unable to execute null AsyncTask."); Preconditions.checkUiThread("AsyncTask must be executed on the main thread"); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { asyncTask.executeOnExecutor(sExecutor, params); } else { asyncTask.execute(params); } } }
AsyncTasks { @TargetApi(VERSION_CODES.HONEYCOMB) public static <P> void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params) { Preconditions.checkNotNull(asyncTask, "Unable to execute null AsyncTask."); Preconditions.checkUiThread("AsyncTask must be executed on the main thread"); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { asyncTask.executeOnExecutor(sExecutor, params); } else { asyncTask.execute(params); } }  }
AsyncTasks { @TargetApi(VERSION_CODES.HONEYCOMB) public static <P> void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params) { Preconditions.checkNotNull(asyncTask, "Unable to execute null AsyncTask."); Preconditions.checkUiThread("AsyncTask must be executed on the main thread"); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { asyncTask.executeOnExecutor(sExecutor, params); } else { asyncTask.execute(params); } }  @VisibleForTesting static void setExecutor(Executor executor); @TargetApi(VERSION_CODES.HONEYCOMB) static void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params); }
AsyncTasks { @TargetApi(VERSION_CODES.HONEYCOMB) public static <P> void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params) { Preconditions.checkNotNull(asyncTask, "Unable to execute null AsyncTask."); Preconditions.checkUiThread("AsyncTask must be executed on the main thread"); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { asyncTask.executeOnExecutor(sExecutor, params); } else { asyncTask.execute(params); } }  @VisibleForTesting static void setExecutor(Executor executor); @TargetApi(VERSION_CODES.HONEYCOMB) static void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params);  }