Merge "Do not invoke onProgressUpdate if the task is canceled. Bug #2734382"

This commit is contained in:
Romain Guy
2010-06-03 10:58:05 -07:00
committed by Android (Google) Code Review

View File

@@ -401,6 +401,9 @@ public abstract class AsyncTask<Params, Progress, Result> {
* publish updates on the UI thread while the background computation is
* still running. Each call to this method will trigger the execution of
* {@link #onProgressUpdate} on the UI thread.
*
* {@link #onProgressUpdate} will note be called if the task has been
* canceled.
*
* @param values The progress values to update the UI with.
*
@@ -408,8 +411,10 @@ public abstract class AsyncTask<Params, Progress, Result> {
* @see #doInBackground
*/
protected final void publishProgress(Progress... values) {
sHandler.obtainMessage(MESSAGE_POST_PROGRESS,
new AsyncTaskResult<Progress>(this, values)).sendToTarget();
if (!isCancelled()) {
sHandler.obtainMessage(MESSAGE_POST_PROGRESS,
new AsyncTaskResult<Progress>(this, values)).sendToTarget();
}
}
private void finish(Result result) {