Move to Android N-MR1 SDK.
[android_tools.git] / sdk / sources / android-25 / android / database / ContentObservable.java
blob7692bb39da71416d886ec28b040d5be7180622e0
1 /*
2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package android.database;
19 import android.net.Uri;
21 /**
22 * A specialization of {@link Observable} for {@link ContentObserver}
23 * that provides methods for sending notifications to a list of
24 * {@link ContentObserver} objects.
26 public class ContentObservable extends Observable<ContentObserver> {
27 // Even though the generic method defined in Observable would be perfectly
28 // fine on its own, we can't delete this overridden method because it would
29 // potentially break binary compatibility with existing applications.
30 @Override
31 public void registerObserver(ContentObserver observer) {
32 super.registerObserver(observer);
35 /**
36 * Invokes {@link ContentObserver#dispatchChange(boolean)} on each observer.
37 * <p>
38 * If <code>selfChange</code> is true, only delivers the notification
39 * to the observer if it has indicated that it wants to receive self-change
40 * notifications by implementing {@link ContentObserver#deliverSelfNotifications}
41 * to return true.
42 * </p>
44 * @param selfChange True if this is a self-change notification.
46 * @deprecated Use {@link #dispatchChange(boolean, Uri)} instead.
48 @Deprecated
49 public void dispatchChange(boolean selfChange) {
50 dispatchChange(selfChange, null);
53 /**
54 * Invokes {@link ContentObserver#dispatchChange(boolean, Uri)} on each observer.
55 * Includes the changed content Uri when available.
56 * <p>
57 * If <code>selfChange</code> is true, only delivers the notification
58 * to the observer if it has indicated that it wants to receive self-change
59 * notifications by implementing {@link ContentObserver#deliverSelfNotifications}
60 * to return true.
61 * </p>
63 * @param selfChange True if this is a self-change notification.
64 * @param uri The Uri of the changed content, or null if unknown.
66 public void dispatchChange(boolean selfChange, Uri uri) {
67 synchronized(mObservers) {
68 for (ContentObserver observer : mObservers) {
69 if (!selfChange || observer.deliverSelfNotifications()) {
70 observer.dispatchChange(selfChange, uri);
76 /**
77 * Invokes {@link ContentObserver#onChange} on each observer.
79 * @param selfChange True if this is a self-change notification.
81 * @deprecated Use {@link #dispatchChange} instead.
83 @Deprecated
84 public void notifyChange(boolean selfChange) {
85 synchronized(mObservers) {
86 for (ContentObserver observer : mObservers) {
87 observer.onChange(selfChange, null);