From ec37c88570bdd1b94309ad613395295f13449c3f Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Mon, 2 Aug 2010 16:57:01 -0700 Subject: Adding a method called when detecting content change. Added Loader.onContentChanged() which is called by ForceLoadContentObserver when it detects a change, rather than forceLoad(). By default onContentChanged() just calls forceLoad(), so there's no change in behavior. This is useful when a subclass wants to perform custom operations upon data chantes. For example, a subclass may want to limit the number of automatic requeries per second. Change-Id: I493dac3f4f1a75b056d2c7065336ea9252dbf424 --- core/java/android/content/Loader.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/java/android/content/Loader.java b/core/java/android/content/Loader.java index db40e48..234096a 100644 --- a/core/java/android/content/Loader.java +++ b/core/java/android/content/Loader.java @@ -22,7 +22,7 @@ import android.os.Handler; /** * An abstract class that performs asynchronous loading of data. While Loaders are active * they should monitor the source of their data and deliver new results when the contents - * change. + * change. * * @param The result returned when the load is complete */ @@ -43,7 +43,7 @@ public abstract class Loader { @Override public void onChange(boolean selfChange) { - forceLoad(); + onContentChanged(); } } @@ -97,7 +97,7 @@ public abstract class Loader { /** * Registers a class that will receive callbacks when a load is complete. The callbacks will * be called on the UI thread so it's safe to pass the results to widgets. - * + * * Must be called from the UI thread */ public void registerListener(int id, OnLoadCompleteListener listener) { @@ -126,7 +126,7 @@ public abstract class Loader { * will be called on the UI thread. If a previous load has been completed and is still valid * the result may be passed to the callbacks immediately. The loader will monitor the source of * the data set and may deliver future callbacks if the source changes. Calling - * {@link #stopLoading} will stop the delivery of callbacks. + * {@link #stopLoading} will stop the delivery of callbacks. * * Must be called from the UI thread */ @@ -151,4 +151,14 @@ public abstract class Loader { * Must be called from the UI thread */ public abstract void destroy(); + + /** + * Called when {@link ForceLoadContentObserver} detects a change. Calls {@link #forceLoad()} + * by default. + * + * Must be called from the UI thread + */ + public void onContentChanged() { + forceLoad(); + } } \ No newline at end of file -- cgit v1.1