diff options
author | George Mount <mount@google.com> | 2016-09-07 11:23:38 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2016-09-14 19:20:32 +0000 |
commit | c70cb0486b336449f0f76f336ef4037f609d0299 (patch) | |
tree | d5912ccdfed5b19dd4f3e1a8e83bf84aebd66cc7 /compiler/src/main/kotlin/android/databinding | |
parent | 66b71794f1ec1e96bfdfd8a88d19148fa7f5ad15 (diff) | |
download | data-binding-c70cb0486b336449f0f76f336ef4037f609d0299.tar.gz |
Ensure that bindings are evaluated prior to their included bindings.
Bug 31085763
In the case where a layout with a binding includes another layout
with a binding, it is important to evaluate the bindings of the
containing before the included. This ensures that if the containing
binding has a value set, the value is set on the included binding
before evaluation.
This is part 2 of a 2-part change. This includes the aspects
that depend on the library and the tests.
Change-Id: I6b16c6c3f5961958259b0ca707ec2373d073658d
Diffstat (limited to 'compiler/src/main/kotlin/android/databinding')
-rw-r--r-- | compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt b/compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt index 745169d5..3820084d 100644 --- a/compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt +++ b/compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt @@ -524,6 +524,9 @@ class LayoutBinderWriter(val layoutBinder : LayoutBinder) { taggedViews.forEach { if (!layoutBinder.hasVariations() || it.id == null) { tab("this.${it.fieldName} = ${fieldConversion(it)};") + if (it.isBinder) { + tab("setContainedBinding(this.${it.fieldName});") + } } if (!it.isBinder) { if (it.resolvedType != null && it.resolvedType.extendsViewStub()) { @@ -969,13 +972,13 @@ class LayoutBinderWriter(val layoutBinder : LayoutBinder) { } } includedBinders.filter{it.isUsed }.forEach { binder -> - nl("${binder.fieldName}.executePendingBindings();") + nl("executeBindingsOn(${binder.fieldName});") } layoutBinder.sortedTargets.filter{ it.isUsed && it.resolvedType != null && it.resolvedType.extendsViewStub() }.forEach { block("if (${it.fieldName}.getBinding() != null)") { - nl("${it.fieldName}.getBinding().executePendingBindings();") + nl("executeBindingsOn(${it.fieldName}.getBinding());") } } } @@ -1227,6 +1230,9 @@ class LayoutBinderWriter(val layoutBinder : LayoutBinder) { tab("super(bindingComponent, root_, localFieldCount);") layoutBinder.sortedTargets.filter{it.id != null}.forEach { tab("this.${it.fieldName} = ${it.constructorParamName};") + if (it.isBinder) { + tab("setContainedBinding(this.${it.fieldName});") + } } } tab("}") |