diff options
Diffstat (limited to 'core/java/android/content/AsyncTaskLoader.java')
-rw-r--r-- | core/java/android/content/AsyncTaskLoader.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/content/AsyncTaskLoader.java b/core/java/android/content/AsyncTaskLoader.java index 0b54396..944ca6b 100644 --- a/core/java/android/content/AsyncTaskLoader.java +++ b/core/java/android/content/AsyncTaskLoader.java @@ -173,6 +173,7 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { if (DEBUG) Slog.v(TAG, "cancelLoad: cancelled=" + cancelled); if (cancelled) { mCancellingTask = mTask; + onCancelLoadInBackground(); } mTask = null; return cancelled; @@ -256,6 +257,25 @@ public abstract class AsyncTaskLoader<D> extends Loader<D> { } /** + * Override this method to try to abort the computation currently taking + * place on a background thread. + * + * Note that when this method is called, it is possible that {@link #loadInBackground} + * has not started yet or has already completed. + */ + protected void onCancelLoadInBackground() { + } + + /** + * Returns true if the current execution of {@link #loadInBackground()} is being canceled. + * + * @return True if the current execution of {@link #loadInBackground()} is being canceled. + */ + protected boolean isLoadInBackgroundCanceled() { + return mCancellingTask != null; + } + + /** * Locks the current thread until the loader completes the current load * operation. Returns immediately if there is no load operation running. * Should not be called from the UI thread: calling it from the UI |