public abstract class ViewDataBinding extends BaseObservable
DataBindingUtil.bind(View)
or
DataBindingUtil.inflate(LayoutInflater, int, ViewGroup, boolean)
should be used.Modifier and Type | Class and Description |
---|---|
protected static class |
ViewDataBinding.IncludedLayouts
This class is used by generated subclasses of
ViewDataBinding to track the
included layouts contained in the bound layout. |
protected static class |
ViewDataBinding.PropertyChangedInverseListener
This class is used by generated subclasses of
ViewDataBinding to listen for
changes on variables of Bindings. |
Observable.OnPropertyChangedCallback
Modifier and Type | Field and Description |
---|---|
static String |
BINDING_TAG_PREFIX
Prefix for android:tag on Views with binding.
|
protected DataBindingComponent |
mBindingComponent
The DataBindingComponent used by this data binding.
|
Modifier | Constructor and Description |
---|---|
protected |
ViewDataBinding(DataBindingComponent bindingComponent,
View root,
int localFieldCount) |
Modifier and Type | Method and Description |
---|---|
void |
addOnRebindCallback(OnRebindCallback listener)
Add a listener to be called when reevaluating dirty fields.
|
protected static ViewDataBinding |
bind(DataBindingComponent bindingComponent,
View view,
int layoutId) |
protected void |
ensureBindingComponentIsNotNull(Class<?> oneExample) |
protected abstract void |
executeBindings() |
void |
executePendingBindings()
Evaluates the pending bindings, updating any Views that have expressions bound to
modified variables.
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
static int |
getBuildSdkInt() |
protected int |
getColorFromResource(int resourceId) |
protected ColorStateList |
getColorStateListFromResource(int resourceId) |
protected Drawable |
getDrawableFromResource(int resourceId) |
protected static <K,T> T |
getFrom(Map<K,T> map,
K key) |
protected static boolean |
getFromArray(boolean[] arr,
int index) |
protected static byte |
getFromArray(byte[] arr,
int index) |
protected static char |
getFromArray(char[] arr,
int index) |
protected static double |
getFromArray(double[] arr,
int index) |
protected static float |
getFromArray(float[] arr,
int index) |
protected static int |
getFromArray(int[] arr,
int index) |
protected static long |
getFromArray(long[] arr,
int index) |
protected static short |
getFromArray(short[] arr,
int index) |
protected static <T> T |
getFromArray(T[] arr,
int index) |
protected static <T> T |
getFromList(List<T> list,
int index) |
protected static <T> T |
getFromList(LongSparseArray<T> list,
int index) |
protected static <T> T |
getFromList(LongSparseArray<T> list,
int index) |
protected static <T> T |
getFromList(SparseArray<T> list,
int index) |
protected static boolean |
getFromList(SparseBooleanArray list,
int index) |
protected static int |
getFromList(SparseIntArray list,
int index) |
protected static long |
getFromList(SparseLongArray list,
int index) |
protected Object |
getObservedField(int localFieldId) |
View |
getRoot()
Returns the outermost View in the layout file associated with the Binding.
|
abstract boolean |
hasPendingBindings()
Returns whether the UI needs to be refresh to represent the current data.
|
abstract void |
invalidateAll()
Invalidates all binding expressions and requests a new rebind to refresh UI.
|
protected static Object[] |
mapBindings(DataBindingComponent bindingComponent,
View[] roots,
int numBindings,
ViewDataBinding.IncludedLayouts includes,
SparseIntArray viewsWithIds)
Walks the view hierarchy under roots and pulls out tagged Views, includes, and views with
IDs into an Object[] that is returned.
|
protected static Object[] |
mapBindings(DataBindingComponent bindingComponent,
View root,
int numBindings,
ViewDataBinding.IncludedLayouts includes,
SparseIntArray viewsWithIds)
Walks the view hierarchy under root and pulls out tagged Views, includes, and views with
IDs into an Object[] that is returned.
|
protected abstract boolean |
onFieldChange(int localFieldId,
Object object,
int fieldId)
Called when an observed object changes.
|
protected void |
registerTo(int localFieldId,
Object observable,
android.databinding.ViewDataBinding.CreateWeakListener listenerCreator) |
void |
removeOnRebindCallback(OnRebindCallback listener)
Removes a listener that was added in
addOnRebindCallback(OnRebindCallback) . |
protected void |
requestRebind() |
protected static void |
setBindingInverseListener(ViewDataBinding binder,
InverseBindingListener oldListener,
ViewDataBinding.PropertyChangedInverseListener listener) |
protected void |
setRootTag(View view) |
protected void |
setRootTag(View[] views) |
protected static void |
setTo(boolean[] arr,
int index,
boolean value) |
protected static void |
setTo(byte[] arr,
int index,
byte value) |
protected static void |
setTo(char[] arr,
int index,
char value) |
protected static void |
setTo(double[] arr,
int index,
double value) |
protected static void |
setTo(float[] arr,
int index,
float value) |
protected static void |
setTo(int[] arr,
int index,
int value) |
protected static <T> void |
setTo(List<T> list,
int index,
T value) |
protected static void |
setTo(long[] arr,
int index,
long value) |
protected static <T> void |
setTo(LongSparseArray<T> list,
int index,
T value) |
protected static <T> void |
setTo(LongSparseArray<T> list,
int index,
T value) |
protected static <K,T> void |
setTo(Map<K,T> map,
K key,
T value) |
protected static void |
setTo(short[] arr,
int index,
short value) |
protected static <T> void |
setTo(SparseArray<T> list,
int index,
T value) |
protected static void |
setTo(SparseBooleanArray list,
int index,
boolean value) |
protected static void |
setTo(SparseIntArray list,
int index,
int value) |
protected static void |
setTo(SparseLongArray list,
int index,
long value) |
protected static <T> void |
setTo(T[] arr,
int index,
T value) |
abstract boolean |
setVariable(int variableId,
Object value)
Set a value value in the Binding class.
|
void |
unbind()
Removes binding listeners to expression variables.
|
protected boolean |
unregisterFrom(int localFieldId) |
protected boolean |
updateRegistration(int localFieldId,
Observable observable) |
protected boolean |
updateRegistration(int localFieldId,
ObservableList observable) |
protected boolean |
updateRegistration(int localFieldId,
ObservableMap observable) |
addOnPropertyChangedCallback, notifyChange, notifyPropertyChanged, removeOnPropertyChangedCallback
public static final String BINDING_TAG_PREFIX
protected final DataBindingComponent mBindingComponent
protected ViewDataBinding(DataBindingComponent bindingComponent, View root, int localFieldCount)
protected void setRootTag(View view)
protected void setRootTag(View[] views)
public static int getBuildSdkInt()
protected abstract boolean onFieldChange(int localFieldId, Object object, int fieldId)
localFieldId
- The index into mLocalFieldObservers that this Object resides in.object
- The object that has changed.fieldId
- The BR ID of the field being changed or _all if
no specific field is being notified.public abstract boolean setVariable(int variableId, Object value)
Typically, the developer will be able to call the subclass's set method directly. For
example, if there is a variable x
in the Binding, a setX
method
will be generated. However, there are times when the specific subclass of ViewDataBinding
is unknown, so the generated method cannot be discovered without reflection. The
setVariable call allows the values of variables to be set without reflection.
variableId
- the BR id of the variable to be set. For example, if the variable is
x
, then variableId will be BR.x
.value
- The new value of the variable to be set.true
if the variable is declared or used in the binding or
false
otherwise.public void addOnRebindCallback(OnRebindCallback listener)
executePendingBindings()
.listener
- The listener to add.public void removeOnRebindCallback(OnRebindCallback listener)
addOnRebindCallback(OnRebindCallback)
.listener
- The listener to remove.public void executePendingBindings()
protected abstract void executeBindings()
public abstract void invalidateAll()
public abstract boolean hasPendingBindings()
public void unbind()
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
public View getRoot()
protected boolean unregisterFrom(int localFieldId)
protected void requestRebind()
protected Object getObservedField(int localFieldId)
protected boolean updateRegistration(int localFieldId, Observable observable)
protected boolean updateRegistration(int localFieldId, ObservableList observable)
protected boolean updateRegistration(int localFieldId, ObservableMap observable)
protected void ensureBindingComponentIsNotNull(Class<?> oneExample)
protected void registerTo(int localFieldId, Object observable, android.databinding.ViewDataBinding.CreateWeakListener listenerCreator)
protected static ViewDataBinding bind(DataBindingComponent bindingComponent, View view, int layoutId)
protected static Object[] mapBindings(DataBindingComponent bindingComponent, View root, int numBindings, ViewDataBinding.IncludedLayouts includes, SparseIntArray viewsWithIds)
bindingComponent
- The binding component to use with this binding.root
- The root of the view hierarchy to walk.numBindings
- The total number of ID'd views, views with expressions, and includesincludes
- The include layout information, indexed by their container's index.viewsWithIds
- Indexes of views that don't have tags, but have IDs.protected int getColorFromResource(int resourceId)
protected ColorStateList getColorStateListFromResource(int resourceId)
protected Drawable getDrawableFromResource(int resourceId)
protected static <T> T getFromArray(T[] arr, int index)
protected static <T> void setTo(T[] arr, int index, T value)
protected static boolean getFromArray(boolean[] arr, int index)
protected static void setTo(boolean[] arr, int index, boolean value)
protected static byte getFromArray(byte[] arr, int index)
protected static void setTo(byte[] arr, int index, byte value)
protected static short getFromArray(short[] arr, int index)
protected static void setTo(short[] arr, int index, short value)
protected static char getFromArray(char[] arr, int index)
protected static void setTo(char[] arr, int index, char value)
protected static int getFromArray(int[] arr, int index)
protected static void setTo(int[] arr, int index, int value)
protected static long getFromArray(long[] arr, int index)
protected static void setTo(long[] arr, int index, long value)
protected static float getFromArray(float[] arr, int index)
protected static void setTo(float[] arr, int index, float value)
protected static double getFromArray(double[] arr, int index)
protected static void setTo(double[] arr, int index, double value)
protected static <T> T getFromList(List<T> list, int index)
protected static <T> void setTo(List<T> list, int index, T value)
protected static <T> T getFromList(SparseArray<T> list, int index)
protected static <T> void setTo(SparseArray<T> list, int index, T value)
protected static <T> T getFromList(LongSparseArray<T> list, int index)
protected static <T> void setTo(LongSparseArray<T> list, int index, T value)
protected static <T> T getFromList(LongSparseArray<T> list, int index)
protected static <T> void setTo(LongSparseArray<T> list, int index, T value)
protected static boolean getFromList(SparseBooleanArray list, int index)
protected static void setTo(SparseBooleanArray list, int index, boolean value)
protected static int getFromList(SparseIntArray list, int index)
protected static void setTo(SparseIntArray list, int index, int value)
protected static long getFromList(SparseLongArray list, int index)
protected static void setTo(SparseLongArray list, int index, long value)
protected static <K,T> T getFrom(Map<K,T> map, K key)
protected static <K,T> void setTo(Map<K,T> map, K key, T value)
protected static void setBindingInverseListener(ViewDataBinding binder, InverseBindingListener oldListener, ViewDataBinding.PropertyChangedInverseListener listener)
protected static Object[] mapBindings(DataBindingComponent bindingComponent, View[] roots, int numBindings, ViewDataBinding.IncludedLayouts includes, SparseIntArray viewsWithIds)
bindingComponent
- The binding component to use with this binding.roots
- The root Views of the view hierarchy to walk. This is used with merge tags.numBindings
- The total number of ID'd views, views with expressions, and includesincludes
- The include layout information, indexed by their container's index.viewsWithIds
- Indexes of views that don't have tags, but have IDs.