diff options
| author | Jeff Brown <jeffbrown@google.com> | 2012-01-23 15:51:41 -0800 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2012-01-23 17:28:29 -0800 |
| commit | 655e66bceba7595a2b80e7a328433e6ed5dc28a9 (patch) | |
| tree | 79dfc3c3008d34e4969a1c123da90ce27a207edf /core/java/android/database/ContentObservable.java | |
| parent | 86de0590b94bcce27e3038c27464bed510bb564a (diff) | |
Inform ContentObservers about the changed content Uri.
Added a new method ContentObserver.onChange(boolean, Uri) that
receives the changed content Uri. This can help applications make
better decisions about how to interpret a change notification.
Change-Id: I8e35378b6485fe22c5bc240ba07557d269af0836
Diffstat (limited to 'core/java/android/database/ContentObservable.java')
| -rw-r--r-- | core/java/android/database/ContentObservable.java | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/core/java/android/database/ContentObservable.java b/core/java/android/database/ContentObservable.java index aece90482ab5..7692bb39da71 100644 --- a/core/java/android/database/ContentObservable.java +++ b/core/java/android/database/ContentObservable.java @@ -16,6 +16,8 @@ package android.database; +import android.net.Uri; + /** * A specialization of {@link Observable} for {@link ContentObserver} * that provides methods for sending notifications to a list of @@ -31,20 +33,41 @@ public class ContentObservable extends Observable<ContentObserver> { } /** - * Invokes {@link ContentObserver#dispatchChange} on each observer. - * + * Invokes {@link ContentObserver#dispatchChange(boolean)} on each observer. + * <p> * If <code>selfChange</code> is true, only delivers the notification * to the observer if it has indicated that it wants to receive self-change * notifications by implementing {@link ContentObserver#deliverSelfNotifications} * to return true. + * </p> * * @param selfChange True if this is a self-change notification. + * + * @deprecated Use {@link #dispatchChange(boolean, Uri)} instead. */ + @Deprecated public void dispatchChange(boolean selfChange) { + dispatchChange(selfChange, null); + } + + /** + * Invokes {@link ContentObserver#dispatchChange(boolean, Uri)} on each observer. + * Includes the changed content Uri when available. + * <p> + * If <code>selfChange</code> is true, only delivers the notification + * to the observer if it has indicated that it wants to receive self-change + * notifications by implementing {@link ContentObserver#deliverSelfNotifications} + * to return true. + * </p> + * + * @param selfChange True if this is a self-change notification. + * @param uri The Uri of the changed content, or null if unknown. + */ + public void dispatchChange(boolean selfChange, Uri uri) { synchronized(mObservers) { for (ContentObserver observer : mObservers) { if (!selfChange || observer.deliverSelfNotifications()) { - observer.dispatchChange(selfChange); + observer.dispatchChange(selfChange, uri); } } } @@ -61,7 +84,7 @@ public class ContentObservable extends Observable<ContentObserver> { public void notifyChange(boolean selfChange) { synchronized(mObservers) { for (ContentObserver observer : mObservers) { - observer.onChange(selfChange); + observer.onChange(selfChange, null); } } } |
