Added in API level 1

Observable


abstract class Observable<T : Any!>
kotlin.Any
   ↳ android.database.Observable

Provides methods for registering or unregistering arbitrary observers in an 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.

Summary

Public constructors

Public methods
open Unit
registerObserver(observer: T)

Adds an observer to the list.

open Unit

Remove all registered observers.

open Unit
unregisterObserver(observer: T)

Removes a previously registered observer.

Properties
ArrayList<T>!

The list of observers.

Public constructors

Observable

Observable()

Public methods

registerObserver

Added in API level 1
open fun registerObserver(observer: T): Unit

Adds an observer to the list. The observer cannot be null and it must not already be registered.

Parameters
observer T: the observer to register
Exceptions
java.lang.IllegalArgumentException the observer is null
java.lang.IllegalStateException the observer is already registered

unregisterAll

Added in API level 1
open fun unregisterAll(): Unit

Remove all registered observers.

unregisterObserver

Added in API level 1
open fun unregisterObserver(observer: T): Unit

Removes a previously registered observer. The observer must not be null and it must already have been registered.

Parameters
observer T: the observer to unregister
Exceptions
java.lang.IllegalArgumentException the observer is null
java.lang.IllegalStateException the observer is not yet registered

Properties

mObservers

Added in API level 1
protected val mObservers: ArrayList<T>!

The list of observers. An observer can be in the list at most once and will never be null.