public abstract class ViewDataBinding
extends java.lang.Object
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. |
Modifier and Type | Field and Description |
---|---|
static java.lang.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,
android.view.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,
android.view.View view,
int layoutId) |
protected void |
ensureBindingComponentIsNotNull(java.lang.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() |
static int |
getBuildSdkInt() |
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(java.util.List<T> list,
int index) |
protected java.lang.Object |
getObservedField(int localFieldId) |
android.view.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 java.lang.Object[] |
mapBindings(DataBindingComponent bindingComponent,
android.view.View[] roots,
int numBindings,
ViewDataBinding.IncludedLayouts includes,
android.util.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 java.lang.Object[] |
mapBindings(DataBindingComponent bindingComponent,
android.view.View root,
int numBindings,
ViewDataBinding.IncludedLayouts includes,
android.util.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,
java.lang.Object object,
int fieldId)
Called when an observed object changes.
|
protected void |
registerTo(int localFieldId,
java.lang.Object observable,
android.databinding.ViewDataBinding.CreateWeakListener listenerCreator) |
void |
removeOnRebindCallback(OnRebindCallback listener)
Removes a listener that was added in
addOnRebindCallback(OnRebindCallback) . |
protected void |
requestRebind() |
protected void |
setRootTag(android.view.View view) |
protected void |
setRootTag(android.view.View[] views) |
abstract boolean |
setVariable(int variableId,
java.lang.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) |
public static final java.lang.String BINDING_TAG_PREFIX
protected final DataBindingComponent mBindingComponent
protected ViewDataBinding(DataBindingComponent bindingComponent, android.view.View root, int localFieldCount)
protected void setRootTag(android.view.View view)
protected void setRootTag(android.view.View[] views)
public static int getBuildSdkInt()
protected abstract boolean onFieldChange(int localFieldId, java.lang.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, java.lang.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 java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public android.view.View getRoot()
protected boolean unregisterFrom(int localFieldId)
protected void requestRebind()
protected java.lang.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(java.lang.Class<?> oneExample)
protected void registerTo(int localFieldId, java.lang.Object observable, android.databinding.ViewDataBinding.CreateWeakListener listenerCreator)
protected static ViewDataBinding bind(DataBindingComponent bindingComponent, android.view.View view, int layoutId)
protected static java.lang.Object[] mapBindings(DataBindingComponent bindingComponent, android.view.View root, int numBindings, ViewDataBinding.IncludedLayouts includes, android.util.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 static <T> T getFromArray(T[] arr, int index)
protected static boolean getFromArray(boolean[] arr, int index)
protected static byte getFromArray(byte[] arr, int index)
protected static short getFromArray(short[] arr, int index)
protected static char getFromArray(char[] arr, int index)
protected static int getFromArray(int[] arr, int index)
protected static long getFromArray(long[] arr, int index)
protected static float getFromArray(float[] arr, int index)
protected static double getFromArray(double[] arr, int index)
protected static <T> T getFromList(java.util.List<T> list, int index)
protected static java.lang.Object[] mapBindings(DataBindingComponent bindingComponent, android.view.View[] roots, int numBindings, ViewDataBinding.IncludedLayouts includes, android.util.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.