T - The observer type.public abstract class Observable<T> extends Object
ArrayList.
This abstract class is intended to be subclassed and specialized to maintain a registry of observers of specific types and dispatch notifications to them.
| Modifier and Type | Field and Description |
|---|---|
protected List<T> |
mObservers
The list of observers.
|
| Constructor and Description |
|---|
Observable() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasObservers()
Checks if this observable has any registered observers.
|
void |
registerObserver(T observer)
Adds an observer to the list.
|
void |
unregisterAll()
Remove all registered observers.
|
void |
unregisterObserver(T observer)
Removes a previously registered observer.
|
public boolean hasObservers()
public void registerObserver(@NonNull T observer)
observer - the observer to registerpublic void unregisterObserver(@NonNull T observer)
observer - the observer to unregisterpublic void unregisterAll()