package org.mtransit.android.commons;

import java.util.concurrent.Executor;

import org.mtransit.android.commons.MTLog;
import org.mtransit.android.commons.task.MTAsyncTask;

public final class TaskUtils implements MTLog.Loggable {

	private static final String TAG = TaskUtils.class.getSimpleName();

	@Override
	public String getLogTag() {
		return TAG;
	}

	public static final Executor THREAD_POOL_EXECUTOR = MTAsyncTask.THREAD_POOL_EXECUTOR;

	@SuppressWarnings("unchecked")
	public static <Params, Progress, Result> void execute(MTAsyncTask<Params, Progress, Result> asyncTask, Params... params) {
		if (asyncTask == null) {
			return;
		}
		asyncTask.executeOnExecutor(THREAD_POOL_EXECUTOR, params);
	}
}

@@ -703,11 +703,370 @@
 ams);%0A%09%7D
+%0A%0A%09public static %3CParams, Progress, Result%3E boolean cancelQuietly(MTAsyncTask%3CParams, Progress, Result%3E asyncTask, boolean mayInterruptIfRunning) %7B%0A%09%09try %7B%0A%09%09%09if (asyncTask == null) %7B%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%09%09%09return asyncTask.cancel(mayInterruptIfRunning);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09MTLog.w(TAG, e, %22Error while cancelling task!%22);%0A%09%09%09return false;%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Add utility method to cancel AsyncTasks quietly.