Java Code Examples for androidx.databinding.ViewDataBinding#setVariable()
The following examples show how to use
androidx.databinding.ViewDataBinding#setVariable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrgUnitRow.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
@NonNull @Override public OrgUnitHolder onCreate(@NonNull ViewGroup parent) { ViewDataBinding binding = DataBindingUtil.inflate( inflater, isBgTransparent ? R.layout.custom_text_view : R.layout.custom_text_view_accent, parent, false ); binding.setVariable(BR.renderType, renderType); binding.executePendingBindings(); binding.getRoot().findViewById(R.id.input_editText).setFocusable(false); //Makes editText binding.getRoot().findViewById(R.id.input_editText).setClickable(true);// but clickable return new OrgUnitHolder(fm, binding, processor); }
Example 2
Source File: DataBindingModelWithAllFieldTypesNoValidation_.java From epoxy with Apache License 2.0 | 6 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding) { binding.setVariable(BR.valueInt, valueInt); binding.setVariable(BR.valueInteger, valueInteger); binding.setVariable(BR.valueShort, valueShort); binding.setVariable(BR.valueShortWrapper, valueShortWrapper); binding.setVariable(BR.valueChar, valueChar); binding.setVariable(BR.valueCharacter, valueCharacter); binding.setVariable(BR.valuebByte, valuebByte); binding.setVariable(BR.valueByteWrapper, valueByteWrapper); binding.setVariable(BR.valueLong, valueLong); binding.setVariable(BR.valueLongWrapper, valueLongWrapper); binding.setVariable(BR.valueDouble, valueDouble); binding.setVariable(BR.valueDoubleWrapper, valueDoubleWrapper); binding.setVariable(BR.valueFloat, valueFloat); binding.setVariable(BR.valueFloatWrapper, valueFloatWrapper); binding.setVariable(BR.valueBoolean, valueBoolean); binding.setVariable(BR.valueBooleanWrapper, valueBooleanWrapper); binding.setVariable(BR.valueIntArray, valueIntArray); binding.setVariable(BR.valueObjectArray, valueObjectArray); binding.setVariable(BR.valueString, valueString); binding.setVariable(BR.valueObject, valueObject); binding.setVariable(BR.valueList, valueList); }
Example 3
Source File: FieldViewFactory.java From ground-android with Apache License 2.0 | 5 votes |
/** * Inflates the view, generates a new view model and binds to the {@link ViewDataBinding}. * * @param fieldType Type of the field * @param root Parent layout * @return {@link ViewDataBinding} */ ViewDataBinding addFieldView(Field.Type fieldType, LinearLayout root) { ViewDataBinding binding = DataBindingUtil.inflate(fragment.getLayoutInflater(), getLayoutId(fieldType), root, true); binding.setLifecycleOwner(fragment); binding.setVariable(BR.viewModel, viewModelFactory.create(getViewModelClass(fieldType))); assignGeneratedId(binding.getRoot()); return binding; }
Example 4
Source File: ModelWithDataBindingWithoutDonothashBindingModel_.java From epoxy with Apache License 2.0 | 5 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding) { if (!binding.setVariable(BR.stringValue, stringValue)) { throw new IllegalStateException("The attribute stringValue was defined in your data binding model (com.airbnb.epoxy.DataBindingEpoxyModel) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.clickListener, clickListener)) { throw new IllegalStateException("The attribute clickListener was defined in your data binding model (com.airbnb.epoxy.DataBindingEpoxyModel) but a data variable of that name was not found in the layout."); } }
Example 5
Source File: ModelWithDataBindingWithoutDonothashBindingModel_.java From epoxy with Apache License 2.0 | 5 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previousModel) { if (!(previousModel instanceof ModelWithDataBindingWithoutDonothashBindingModel_)) { setDataBindingVariables(binding); return; } ModelWithDataBindingWithoutDonothashBindingModel_ that = (ModelWithDataBindingWithoutDonothashBindingModel_) previousModel; if ((stringValue != null ? !stringValue.equals(that.stringValue) : that.stringValue != null)) { binding.setVariable(BR.stringValue, stringValue); } if ((clickListener != null ? !clickListener.equals(that.clickListener) : that.clickListener != null)) { binding.setVariable(BR.clickListener, clickListener); } }
Example 6
Source File: ModelWithDataBindingBindingModel_.java From epoxy with Apache License 2.0 | 5 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previousModel) { if (!(previousModel instanceof ModelWithDataBindingBindingModel_)) { setDataBindingVariables(binding); return; } ModelWithDataBindingBindingModel_ that = (ModelWithDataBindingBindingModel_) previousModel; if ((stringValue != null ? !stringValue.equals(that.stringValue) : that.stringValue != null)) { binding.setVariable(BR.stringValue, stringValue); } }
Example 7
Source File: ViewModelHelper.java From AndroidViewModel with Apache License 2.0 | 5 votes |
public void performBinding(@NonNull final IView bindingView) { // skip if already create if (mBinding != null) { return; } // get ViewModelBinding config final ViewModelBindingConfig viewModelConfig = bindingView.getViewModelBindingConfig(); // if fragment not providing ViewModelBindingConfig, do not perform binding operations if (viewModelConfig == null) { return; } // perform Data Binding initialization final ViewDataBinding viewDataBinding; if (bindingView instanceof Activity) { viewDataBinding = DataBindingUtil.setContentView(((Activity) bindingView), viewModelConfig.getLayoutResource()); } else if (bindingView instanceof Fragment) { viewDataBinding = DataBindingUtil.inflate(LayoutInflater.from(viewModelConfig.getContext()), viewModelConfig.getLayoutResource(), null, false); } else { throw new IllegalArgumentException("View must be an instance of Activity or Fragment (support-v4)."); } // bind all together if (!viewDataBinding.setVariable(viewModelConfig.getViewModelVariableName(), getViewModel())) { throw new IllegalArgumentException("Binding variable wasn't set successfully. Probably viewModelVariableName of your " + "ViewModelBindingConfig of " + bindingView.getClass().getSimpleName() + " doesn't match any variable in " + viewDataBinding.getClass().getSimpleName()); } mBinding = viewDataBinding; }
Example 8
Source File: DataBindingModelWithAllFieldTypesNoValidation_.java From epoxy with Apache License 2.0 | 4 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previousModel) { if (!(previousModel instanceof DataBindingModelWithAllFieldTypesNoValidation_)) { setDataBindingVariables(binding); return; } DataBindingModelWithAllFieldTypesNoValidation_ that = (DataBindingModelWithAllFieldTypesNoValidation_) previousModel; if ((valueInt != that.valueInt)) { binding.setVariable(BR.valueInt, valueInt); } if ((valueInteger != null ? !valueInteger.equals(that.valueInteger) : that.valueInteger != null)) { binding.setVariable(BR.valueInteger, valueInteger); } if ((valueShort != that.valueShort)) { binding.setVariable(BR.valueShort, valueShort); } if ((valueShortWrapper != null ? !valueShortWrapper.equals(that.valueShortWrapper) : that.valueShortWrapper != null)) { binding.setVariable(BR.valueShortWrapper, valueShortWrapper); } if ((valueChar != that.valueChar)) { binding.setVariable(BR.valueChar, valueChar); } if ((valueCharacter != null ? !valueCharacter.equals(that.valueCharacter) : that.valueCharacter != null)) { binding.setVariable(BR.valueCharacter, valueCharacter); } if ((valuebByte != that.valuebByte)) { binding.setVariable(BR.valuebByte, valuebByte); } if ((valueByteWrapper != null ? !valueByteWrapper.equals(that.valueByteWrapper) : that.valueByteWrapper != null)) { binding.setVariable(BR.valueByteWrapper, valueByteWrapper); } if ((valueLong != that.valueLong)) { binding.setVariable(BR.valueLong, valueLong); } if ((valueLongWrapper != null ? !valueLongWrapper.equals(that.valueLongWrapper) : that.valueLongWrapper != null)) { binding.setVariable(BR.valueLongWrapper, valueLongWrapper); } if ((Double.compare(that.valueDouble, valueDouble) != 0)) { binding.setVariable(BR.valueDouble, valueDouble); } if ((valueDoubleWrapper != null ? !valueDoubleWrapper.equals(that.valueDoubleWrapper) : that.valueDoubleWrapper != null)) { binding.setVariable(BR.valueDoubleWrapper, valueDoubleWrapper); } if ((Float.compare(that.valueFloat, valueFloat) != 0)) { binding.setVariable(BR.valueFloat, valueFloat); } if ((valueFloatWrapper != null ? !valueFloatWrapper.equals(that.valueFloatWrapper) : that.valueFloatWrapper != null)) { binding.setVariable(BR.valueFloatWrapper, valueFloatWrapper); } if ((valueBoolean != that.valueBoolean)) { binding.setVariable(BR.valueBoolean, valueBoolean); } if ((valueBooleanWrapper != null ? !valueBooleanWrapper.equals(that.valueBooleanWrapper) : that.valueBooleanWrapper != null)) { binding.setVariable(BR.valueBooleanWrapper, valueBooleanWrapper); } if (!Arrays.equals(valueIntArray, that.valueIntArray)) { binding.setVariable(BR.valueIntArray, valueIntArray); } if (!Arrays.equals(valueObjectArray, that.valueObjectArray)) { binding.setVariable(BR.valueObjectArray, valueObjectArray); } if ((valueString != null ? !valueString.equals(that.valueString) : that.valueString != null)) { binding.setVariable(BR.valueString, valueString); } if ((valueObject != null ? !valueObject.equals(that.valueObject) : that.valueObject != null)) { binding.setVariable(BR.valueObject, valueObject); } if ((valueList != null ? !valueList.equals(that.valueList) : that.valueList != null)) { binding.setVariable(BR.valueList, valueList); } }
Example 9
Source File: DataBindingModelWithAllFieldTypes_.java From epoxy with Apache License 2.0 | 4 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding) { if (!binding.setVariable(BR.valueInt, valueInt)) { throw new IllegalStateException("The attribute valueInt was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueInteger, valueInteger)) { throw new IllegalStateException("The attribute valueInteger was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueShort, valueShort)) { throw new IllegalStateException("The attribute valueShort was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueShortWrapper, valueShortWrapper)) { throw new IllegalStateException("The attribute valueShortWrapper was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueChar, valueChar)) { throw new IllegalStateException("The attribute valueChar was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueCharacter, valueCharacter)) { throw new IllegalStateException("The attribute valueCharacter was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valuebByte, valuebByte)) { throw new IllegalStateException("The attribute valuebByte was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueByteWrapper, valueByteWrapper)) { throw new IllegalStateException("The attribute valueByteWrapper was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueLong, valueLong)) { throw new IllegalStateException("The attribute valueLong was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueLongWrapper, valueLongWrapper)) { throw new IllegalStateException("The attribute valueLongWrapper was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueDouble, valueDouble)) { throw new IllegalStateException("The attribute valueDouble was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueDoubleWrapper, valueDoubleWrapper)) { throw new IllegalStateException("The attribute valueDoubleWrapper was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueFloat, valueFloat)) { throw new IllegalStateException("The attribute valueFloat was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueFloatWrapper, valueFloatWrapper)) { throw new IllegalStateException("The attribute valueFloatWrapper was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueBoolean, valueBoolean)) { throw new IllegalStateException("The attribute valueBoolean was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueBooleanWrapper, valueBooleanWrapper)) { throw new IllegalStateException("The attribute valueBooleanWrapper was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueIntArray, valueIntArray)) { throw new IllegalStateException("The attribute valueIntArray was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueObjectArray, valueObjectArray)) { throw new IllegalStateException("The attribute valueObjectArray was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueString, valueString)) { throw new IllegalStateException("The attribute valueString was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueObject, valueObject)) { throw new IllegalStateException("The attribute valueObject was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } if (!binding.setVariable(BR.valueList, valueList)) { throw new IllegalStateException("The attribute valueList was defined in your data binding model (com.airbnb.epoxy.DataBindingModelWithAllFieldTypes) but a data variable of that name was not found in the layout."); } }
Example 10
Source File: DataBindingModelWithAllFieldTypes_.java From epoxy with Apache License 2.0 | 4 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previousModel) { if (!(previousModel instanceof DataBindingModelWithAllFieldTypes_)) { setDataBindingVariables(binding); return; } DataBindingModelWithAllFieldTypes_ that = (DataBindingModelWithAllFieldTypes_) previousModel; if ((valueInt != that.valueInt)) { binding.setVariable(BR.valueInt, valueInt); } if ((valueInteger != null ? !valueInteger.equals(that.valueInteger) : that.valueInteger != null)) { binding.setVariable(BR.valueInteger, valueInteger); } if ((valueShort != that.valueShort)) { binding.setVariable(BR.valueShort, valueShort); } if ((valueShortWrapper != null ? !valueShortWrapper.equals(that.valueShortWrapper) : that.valueShortWrapper != null)) { binding.setVariable(BR.valueShortWrapper, valueShortWrapper); } if ((valueChar != that.valueChar)) { binding.setVariable(BR.valueChar, valueChar); } if ((valueCharacter != null ? !valueCharacter.equals(that.valueCharacter) : that.valueCharacter != null)) { binding.setVariable(BR.valueCharacter, valueCharacter); } if ((valuebByte != that.valuebByte)) { binding.setVariable(BR.valuebByte, valuebByte); } if ((valueByteWrapper != null ? !valueByteWrapper.equals(that.valueByteWrapper) : that.valueByteWrapper != null)) { binding.setVariable(BR.valueByteWrapper, valueByteWrapper); } if ((valueLong != that.valueLong)) { binding.setVariable(BR.valueLong, valueLong); } if ((valueLongWrapper != null ? !valueLongWrapper.equals(that.valueLongWrapper) : that.valueLongWrapper != null)) { binding.setVariable(BR.valueLongWrapper, valueLongWrapper); } if ((Double.compare(that.valueDouble, valueDouble) != 0)) { binding.setVariable(BR.valueDouble, valueDouble); } if ((valueDoubleWrapper != null ? !valueDoubleWrapper.equals(that.valueDoubleWrapper) : that.valueDoubleWrapper != null)) { binding.setVariable(BR.valueDoubleWrapper, valueDoubleWrapper); } if ((Float.compare(that.valueFloat, valueFloat) != 0)) { binding.setVariable(BR.valueFloat, valueFloat); } if ((valueFloatWrapper != null ? !valueFloatWrapper.equals(that.valueFloatWrapper) : that.valueFloatWrapper != null)) { binding.setVariable(BR.valueFloatWrapper, valueFloatWrapper); } if ((valueBoolean != that.valueBoolean)) { binding.setVariable(BR.valueBoolean, valueBoolean); } if ((valueBooleanWrapper != null ? !valueBooleanWrapper.equals(that.valueBooleanWrapper) : that.valueBooleanWrapper != null)) { binding.setVariable(BR.valueBooleanWrapper, valueBooleanWrapper); } if (!Arrays.equals(valueIntArray, that.valueIntArray)) { binding.setVariable(BR.valueIntArray, valueIntArray); } if (!Arrays.equals(valueObjectArray, that.valueObjectArray)) { binding.setVariable(BR.valueObjectArray, valueObjectArray); } if ((valueString != null ? !valueString.equals(that.valueString) : that.valueString != null)) { binding.setVariable(BR.valueString, valueString); } if ((valueObject != null ? !valueObject.equals(that.valueObject) : that.valueObject != null)) { binding.setVariable(BR.valueObject, valueObject); } if ((valueList != null ? !valueList.equals(that.valueList) : that.valueList != null)) { binding.setVariable(BR.valueList, valueList); } }
Example 11
Source File: ModelWithDataBindingBindingModel_.java From epoxy with Apache License 2.0 | 4 votes |
@Override protected void setDataBindingVariables(ViewDataBinding binding) { if (!binding.setVariable(BR.stringValue, stringValue)) { throw new IllegalStateException("The attribute stringValue was defined in your data binding model (com.airbnb.epoxy.DataBindingEpoxyModel) but a data variable of that name was not found in the layout."); } }