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
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 @@
/**
* 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 @@
@Override
public void onChange(boolean selfChange) {
- forceLoad();
+ onContentChanged();
}
}
@@ -97,7 +97,7 @@
/**
* 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 @@
* 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 @@
* 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