summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2010-08-02 16:57:01 -0700
committerMakoto Onuki <omakoto@google.com>2010-08-03 09:30:47 -0700
commitec37c88570bdd1b94309ad613395295f13449c3f (patch)
tree6c28b4f5fc671b7d65af75021729a181059ba653 /core
parent100e106551af965b2f53a506011a875daffb0274 (diff)
downloadframeworks_base-ec37c88570bdd1b94309ad613395295f13449c3f.zip
frameworks_base-ec37c88570bdd1b94309ad613395295f13449c3f.tar.gz
frameworks_base-ec37c88570bdd1b94309ad613395295f13449c3f.tar.bz2
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
Diffstat (limited to 'core')
-rw-r--r--core/java/android/content/Loader.java18
1 files changed, 14 insertions, 4 deletions
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 <D> The result returned when the load is complete
*/
@@ -43,7 +43,7 @@ public abstract class Loader<D> {
@Override
public void onChange(boolean selfChange) {
- forceLoad();
+ onContentChanged();
}
}
@@ -97,7 +97,7 @@ public abstract class Loader<D> {
/**
* 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<D> listener) {
@@ -126,7 +126,7 @@ public abstract class Loader<D> {
* 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<D> {
* 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