Example usage for android.os AsyncTask getStatus

List of usage examples for android.os AsyncTask getStatus

Introduction

In this page you can find the example usage for android.os AsyncTask getStatus.

Prototype

public final Status getStatus() 

Source Link

Document

Returns the current status of this task.

Usage

From source file:Main.java

/**
 * Checks whether task is not null and if it is running.
 *//*from   ww  w  .  j  a v a 2s. c  o m*/
public static boolean isRunning(AsyncTask<?, ?, ?> task) {
    return task != null && task.getStatus() == AsyncTask.Status.RUNNING;
}

From source file:Main.java

/** Returns whether the task specified as an argument is running or not.
 * @param theTask {@link AsyncTask} to be checked.
 * @return True if the task is running, false otherwise.
 *///from   w  ww . j  a va 2s  .  co  m
public static boolean isRunning(final AsyncTask<?, ?, ?> theTask) {
    return (theTask != null && theTask.getStatus().equals(AsyncTask.Status.RUNNING));
}

From source file:Main.java

public static boolean isTaskRunning(@Nullable AsyncTask task) {
    return task != null && task.getStatus() == AsyncTask.Status.RUNNING;
}

From source file:Main.java

public static boolean isAsynctaskFinished(AsyncTask<?, ?, ?> paramAsyncTask) {
    return (paramAsyncTask == null) || (paramAsyncTask.getStatus() == AsyncTask.Status.FINISHED);
}

From source file:Main.java

/**
 * Cancel an {@link AsyncTask}./*from   w w w  .  ja v a 2  s  . c o  m*/
 *
 * @param mayInterruptIfRunning <tt>true</tt> if the thread executing this
 *        task should be interrupted; otherwise, in-progress tasks are allowed
 *        to complete.
 */
public static void cancelTask(AsyncTask<?, ?, ?> task, boolean mayInterruptIfRunning) {
    if (task != null && task.getStatus() != AsyncTask.Status.FINISHED) {
        task.cancel(mayInterruptIfRunning);
    }
}

From source file:Main.java

/**
 * Null-ignoring <code>AsyncTask</code> status determining method.
 *///from ww  w .  j a  va 2s .  c  o m
public static boolean isRunning(final AsyncTask<?, ?, ?> asyncTask) {
    return null != asyncTask && !AsyncTask.Status.FINISHED.equals(asyncTask.getStatus());
}

From source file:com.packpublishing.asynchronousandroid.chapter3.MyPuppyAlbumActivity.java

@Override
protected void onDestroy() {
    super.onDestroy();
    // Cancel Pending Tasks
    for (AsyncTask task : photoAsyncTasks) {
        if (task.getStatus() != AsyncTask.Status.FINISHED) {
            task.cancel(true);//from  ww  w  . j  ava  2s . c o m
        }
    }
    photoAsyncTasks.clear();
}

From source file:com.yattatech.dbtc.activity.GenericFragmentActivity.java

protected void cancelAsyncTask(AsyncTask<?, ?, ?> asyncTask) {
    Debug.d(mTag, "cancelAsyncTask");
    if ((asyncTask != null) && (asyncTask.getStatus() != Status.FINISHED)) {
        try {/*from  ww  w .  j a  va2s.  c o  m*/
            asyncTask.cancel(true);
        } catch (Exception e) {
            Debug.e(mTag, "Failed:", e);
        }
    }
}

From source file:hku.fyp14017.blencode.drone.DroneInitializer.java

private boolean taskRunning(AsyncTask<?, ?, ?> checkMediaTask2) {
    return !(checkMediaTask2 == null || checkMediaTask2.getStatus() == Status.FINISHED);
}

From source file:com.rodrigopontes.androidbubbles.BubblesManager.java

private void cancelAsyncTasks(AsyncTask... animations) {
    for (AsyncTask animation : animations) {
        if (animation != null && !animation.getStatus().name().equals("FINISHED")) {
            animation.cancel(true);//from  www. java  2 s . co  m
        }
    }
}