# CallbackRegistry

Summary:[Nested Classes](https://developer.android.com/reference/android/databinding/CallbackRegistry#nestedclasses)\|[Ctors](https://developer.android.com/reference/android/databinding/CallbackRegistry#pubctors)\|[Methods](https://developer.android.com/reference/android/databinding/CallbackRegistry#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/databinding/CallbackRegistry#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/databinding/CallbackRegistry#)  

# CallbackRegistry

`
public


class
CallbackRegistry
`  
`

extends `[Object](http://developer.android.com/reference/java/lang/Object.html)`


``


implements

`[Cloneable](http://developer.android.com/reference/java/lang/Cloneable.html)`


`

|---|-------------------------------------------------|
| [java.lang.Object](http://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.databinding.CallbackRegistry\<C, T, A\> |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/databinding/CallbackRegistry#)Known Direct Subclasses [ListChangeRegistry](https://developer.android.com/reference/android/databinding/ListChangeRegistry),[MapChangeRegistry](https://developer.android.com/reference/android/databinding/MapChangeRegistry),[PropertyChangeRegistry](https://developer.android.com/reference/android/databinding/PropertyChangeRegistry) |--------------------------------------------------------------------------------------------------------------|------------------------------------------------------| | [ListChangeRegistry](https://developer.android.com/reference/android/databinding/ListChangeRegistry)         | Utility class for managing ObservableList callbacks. | | [MapChangeRegistry](https://developer.android.com/reference/android/databinding/MapChangeRegistry)           | Utility class for managing ObservableMap callbacks.  | | [PropertyChangeRegistry](https://developer.android.com/reference/android/databinding/PropertyChangeRegistry) | Utility class for managing Observable callbacks.     | |

<br />

*** ** * ** ***

A utility for storing and notifying callbacks. This class supports reentrant modification of the callbacks during notification without adversely disrupting notifications. A common pattern for callbacks is to receive a notification and then remove themselves. This class handles this behavior with constant memory under most circumstances.

A subclass of[CallbackRegistry.NotifierCallback](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback)must be passed to the constructor to define how notifications should be called. That implementation does the actual notification on the listener. It is typically a static instance that can be reused for all similar CallbackRegistries.

This class supports only callbacks with at most three parameters. Typically, these are the notification originator and a parameter, with another to indicate which method to call, but these may be used as required. If more than three parameters are required or primitive types other than the single int provided must be used,`A`should be some kind of containing structure that the subclass may reuse between notifications.

<br />

## Summary

|                                                                                             ### Nested classes                                                                                             ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [CallbackRegistry.NotifierCallback](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback)`<C, T, A>` Class used to notify events from CallbackRegistry. |

|                                                                                                                                                                                      ### Public constructors                                                                                                                                                                                      ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CallbackRegistry](https://developer.android.com/reference/android/databinding/CallbackRegistry#CallbackRegistry(android.databinding.CallbackRegistry.NotifierCallback<C, T, A>))`(`[NotifierCallback](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback)`<C, T, A> notifier) ` Creates an EventRegistry that notifies the event with notifier. |

|                                                                                                                                                                                              ### Public methods                                                                                                                                                                                              ||
|----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                        | ` `[add](https://developer.android.com/reference/android/databinding/CallbackRegistry#add(C))`(C callback) ` Add a callback to be notified.                                                                                                                                                  |
| ` void`                                                                                                        | ` `[clear](https://developer.android.com/reference/android/databinding/CallbackRegistry#clear())`() ` Removes all callbacks from the list.                                                                                                                                                   |
| ` `[CallbackRegistry](https://developer.android.com/reference/android/databinding/CallbackRegistry)`<C, T, A>` | ` `[clone](https://developer.android.com/reference/android/databinding/CallbackRegistry#clone())`() `                                                                                                                                                                                        |
| ` `[ArrayList](http://developer.android.com/reference/java/util/ArrayList.html)`<C>`                           | ` `[copyCallbacks](https://developer.android.com/reference/android/databinding/CallbackRegistry#copyCallbacks())`() ` Makes a copy of the registered callbacks and returns it.                                                                                                               |
| ` void`                                                                                                        | ` `[copyCallbacks](https://developer.android.com/reference/android/databinding/CallbackRegistry#copyCallbacks(java.util.List<C>))`(`[List](http://developer.android.com/reference/java/util/List.html)`<C> callbacks) ` Modifies`callbacks`to contain all callbacks in the CallbackRegistry. |
| ` boolean`                                                                                                     | ` `[isEmpty](https://developer.android.com/reference/android/databinding/CallbackRegistry#isEmpty())`() ` Returns true if there are no registered callbacks or false otherwise.                                                                                                              |
| ` void`                                                                                                        | ` `[notifyCallbacks](https://developer.android.com/reference/android/databinding/CallbackRegistry#notifyCallbacks(T, int, A))`(T sender, int arg, A arg2) ` Notify all callbacks.                                                                                                            |
| ` void`                                                                                                        | ` `[remove](https://developer.android.com/reference/android/databinding/CallbackRegistry#remove(C))`(C callback) ` Remove a callback.                                                                                                                                                        |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/databinding/CallbackRegistry#)From class` `[java.lang.Object](http://developer.android.com/reference/java/lang/Object.html)` ` |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | ` `[Object](http://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                               | | ` boolean`                                                                         | ` equals(`[Object](http://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                            | ` finalize() `                                                                            | | ` final `[Class](http://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                            | | ` int`                                                                             | ` hashCode() `                                                                            | | ` final void`                                                                      | ` notify() `                                                                              | | ` final void`                                                                      | ` notifyAll() `                                                                           | | ` `[String](http://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                            | | ` final void`                                                                      | ` wait(long arg0, int arg1) `                                                             | | ` final void`                                                                      | ` wait(long arg0) `                                                                       | | ` final void`                                                                      | ` wait() `                                                                                | ||

## Public constructors

### CallbackRegistry

```
CallbackRegistry (NotifierCallback<C, T, A> notifier)
```

Creates an EventRegistry that notifies the event with notifier.

<br />

|                                Parameters                                 ||
|------------|---------------------------------------------------------------|
| `notifier` | `NotifierCallback`: The class to use to notify events. <br /> |

## Public methods

### add

```
void add (C callback)
```

Add a callback to be notified. If the callback is already in the list, another won't be added. This does not affect current notifications.

<br />

|                  Parameters                  ||
|------------|----------------------------------|
| `callback` | `C`: The callback to add. <br /> |

### clear

```
void clear ()
```

Removes all callbacks from the list.

<br />

### clone

```
CallbackRegistry<C, T, A> clone ()
```

<br />

<br />

|                                                                                              Returns                                                                                               ||
|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| [CallbackRegistry](https://developer.android.com/reference/android/databinding/CallbackRegistry)`<C, T, A>` | A copy of the CallbackRegistry with all callbacks listening to both instances. <br /> |

### copyCallbacks

```
ArrayList<C> copyCallbacks ()
```

Makes a copy of the registered callbacks and returns it.

<br />

|                                                            Returns                                                            ||
|-----------------------------------------------------------------------------------|--------------------------------------------|
| [ArrayList](http://developer.android.com/reference/java/util/ArrayList.html)`<C>` | a copy of the registered callbacks. <br /> |

### copyCallbacks

```
void copyCallbacks (List<C> callbacks)
```

Modifies`callbacks`to contain all callbacks in the CallbackRegistry.

<br />

|                                         Parameters                                          ||
|-------------|--------------------------------------------------------------------------------|
| `callbacks` | `List`: modified to contain all callbacks registered to receive events. <br /> |

### isEmpty

```
boolean isEmpty ()
```

Returns true if there are no registered callbacks or false otherwise.

<br />

|                                     Returns                                     ||
|-----------|----------------------------------------------------------------------|
| `boolean` | true if there are no registered callbacks or false otherwise. <br /> |

### notifyCallbacks

```
void notifyCallbacks (T sender, 
                int arg, 
                A arg2)
```

Notify all callbacks.

<br />

|                                                                                                                        Parameters                                                                                                                        ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sender` | `T`: The originator. This is an opaque parameter passed to[onNotifyCallback(Object, Object, int, Object)](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback#onNotifyCallback(C, T, int, A)) <br /> |
| `arg`    | `int`: An opaque parameter passed to[onNotifyCallback(Object, Object, int, Object)](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback#onNotifyCallback(C, T, int, A)) <br />                       |
| `arg2`   | `A`: An opaque parameter passed to[onNotifyCallback(Object, Object, int, Object)](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback#onNotifyCallback(C, T, int, A)) <br />                         |

### remove

```
void remove (C callback)
```

Remove a callback. This callback won't be notified after this call completes.

<br />

|                   Parameters                    ||
|------------|-------------------------------------|
| `callback` | `C`: The callback to remove. <br /> |

-

  ## Annotations

  - [Bindable](https://developer.android.com/reference/android/databinding/Bindable)
  - [BindingAdapter](https://developer.android.com/reference/android/databinding/BindingAdapter)
  - [BindingConversion](https://developer.android.com/reference/android/databinding/BindingConversion)
  - [BindingMethod](https://developer.android.com/reference/android/databinding/BindingMethod)
  - [BindingMethods](https://developer.android.com/reference/android/databinding/BindingMethods)
  - [InverseBindingAdapter](https://developer.android.com/reference/android/databinding/InverseBindingAdapter)
  - [InverseBindingMethod](https://developer.android.com/reference/android/databinding/InverseBindingMethod)
  - [InverseBindingMethods](https://developer.android.com/reference/android/databinding/InverseBindingMethods)
  - [InverseMethod](https://developer.android.com/reference/android/databinding/InverseMethod)
-

  ## Interfaces

  - [DataBindingComponent](https://developer.android.com/reference/android/databinding/DataBindingComponent)
  - [InverseBindingListener](https://developer.android.com/reference/android/databinding/InverseBindingListener)
  - [Observable](https://developer.android.com/reference/android/databinding/Observable)
  - [ObservableList](https://developer.android.com/reference/android/databinding/ObservableList)
  - [ObservableMap](https://developer.android.com/reference/android/databinding/ObservableMap)
-

  ## Classes

  - [BaseObservable](https://developer.android.com/reference/android/databinding/BaseObservable)
  - [CallbackRegistry](https://developer.android.com/reference/android/databinding/CallbackRegistry)
  - [CallbackRegistry.NotifierCallback](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback)
  - [DataBindingUtil](https://developer.android.com/reference/android/databinding/DataBindingUtil)
  - [ListChangeRegistry](https://developer.android.com/reference/android/databinding/ListChangeRegistry)
  - [MapChangeRegistry](https://developer.android.com/reference/android/databinding/MapChangeRegistry)
  - [MergedDataBinderMapper](https://developer.android.com/reference/android/databinding/MergedDataBinderMapper)
  - [Observable.OnPropertyChangedCallback](https://developer.android.com/reference/android/databinding/Observable.OnPropertyChangedCallback)
  - [ObservableArrayList](https://developer.android.com/reference/android/databinding/ObservableArrayList)
  - [ObservableArrayMap](https://developer.android.com/reference/android/databinding/ObservableArrayMap)
  - [ObservableBoolean](https://developer.android.com/reference/android/databinding/ObservableBoolean)
  - [ObservableByte](https://developer.android.com/reference/android/databinding/ObservableByte)
  - [ObservableChar](https://developer.android.com/reference/android/databinding/ObservableChar)
  - [ObservableDouble](https://developer.android.com/reference/android/databinding/ObservableDouble)
  - [ObservableField](https://developer.android.com/reference/android/databinding/ObservableField)
  - [ObservableFloat](https://developer.android.com/reference/android/databinding/ObservableFloat)
  - [ObservableInt](https://developer.android.com/reference/android/databinding/ObservableInt)
  - [ObservableList.OnListChangedCallback](https://developer.android.com/reference/android/databinding/ObservableList.OnListChangedCallback)
  - [ObservableLong](https://developer.android.com/reference/android/databinding/ObservableLong)
  - [ObservableMap.OnMapChangedCallback](https://developer.android.com/reference/android/databinding/ObservableMap.OnMapChangedCallback)
  - [ObservableParcelable](https://developer.android.com/reference/android/databinding/ObservableParcelable)
  - [ObservableShort](https://developer.android.com/reference/android/databinding/ObservableShort)
  - [OnRebindCallback](https://developer.android.com/reference/android/databinding/OnRebindCallback)
  - [PropertyChangeRegistry](https://developer.android.com/reference/android/databinding/PropertyChangeRegistry)
  - [ViewDataBinding](https://developer.android.com/reference/android/databinding/ViewDataBinding)
  - [ViewStubProxy](https://developer.android.com/reference/android/databinding/ViewStubProxy)