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:com.rodrigopontes.androidbubbles.BubblesManager.java

private boolean haveAsyncTasksFinished(AsyncTask... animations) {
    for (AsyncTask animation : animations) {
        if (!(animation == null || !animation.getStatus().name().equals("RUNNING"))) {
            return false;
        }//w  w  w  .java  2s  .co  m
    }
    return true;
}

From source file:se.chalmers.watchme.activity.MovieDetailsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_movie_details);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    db = new DatabaseAdapter(getContentResolver());

    this.movie = (Movie) getIntent().getSerializableExtra(MOVIE_EXTRA);
    this.imdb = new IMDBHandler();

    this.poster = (ImageView) findViewById(R.id.poster);
    this.poster.setOnClickListener(new OnPosterClickListener());

    this.imdbButton = (Button) findViewById(R.id.browser_button);
    this.imdbButton.setEnabled(false);

    this.tagField = (EditText) findViewById(R.id.tag_field_details);
    this.noteField = (EditText) findViewById(R.id.note_field_details);

    this.myRatingBar = (RatingBar) findViewById(R.id.my_rating_bar);
    this.myRatingBar.setEnabled(false); // Unable to do this in XML (?)

    this.dialog = new ImageDialog(this);

    // Hide the progress spinner on init
    findViewById(R.id.imdb_loading_spinner).setVisibility(View.INVISIBLE);

    /*// ww w .j  a  va  2  s. c o m
    * Create a new image download task for the poster image
    */
    this.imageTask = new ImageDownloadTask(new ImageDownloadTask.TaskActions() {

        public void onFinished(Bitmap image) {
            if (image != null) {
                poster.setImageBitmap(image);
            }
        }
    });

    /*
     * If no movie id was received earlier then finish this activity before
     * anything else is done
     */
    if (this.movie == null) {
        // TODO Why does this cause a crash?
        finish();
    }

    // Kick off the fetch for IMDb info IF there's a set API id
    // set.
    if (this.movie.hasApiIDSet()) {
        final AsyncTask<Integer, Void, JSONObject> t = new IMDBTask()
                .execute(new Integer[] { this.movie.getApiID() });

        // Cancel the task after a timeout
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {

            public void run() {
                if (t.getStatus() == AsyncTask.Status.RUNNING) {
                    t.cancel(true);
                    System.err.println("Fetching IMDb info did timeout");
                }
            }
        }, IMDB_FETCH_TIMEOUT);
    }

    // Populate various view fields from the Movie object
    populateFieldsFromMovie(this.movie);

}

From source file:com.zenithed.core.widget.scaledimageview.ScaledImageView.java

/**
 * Cancels any running tasks related to the view's images.
 *///from  w w w .  j  a  va2  s .  co m
public void cancelAll() {
    AsyncTask.Status status;

    for (AsyncTask task : mTasks) {
        status = task.getStatus();
        if (status == AsyncTask.Status.PENDING || status == AsyncTask.Status.RUNNING)
            task.cancel(true);
    }

    mTasks.clear();
}