diff options
author | George Mount <mount@google.com> | 2016-09-22 10:41:11 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2016-09-26 17:15:48 -0700 |
commit | 2dc087b58747f726413ac62bd0b6fd43c1835a8f (patch) | |
tree | afb91a7324c86c60fd97b720ec0e37ee174523ac /compiler/src/main/kotlin/android/databinding | |
parent | 315ded5d95dd5ce6dbe1226a1065aa340df251a7 (diff) | |
download | data-binding-2dc087b58747f726413ac62bd0b6fd43c1835a8f.tar.gz |
Add support for dependent bindable properties.
Bug 31675606
Getters annotated with @Bindable can now take an optional
list of other property names that the attribute depends on.
The propery will be considered dirty whenever any of the other
properties have had change notifications.
Change-Id: Ie0166befb4ef5eb92b26e9f7edc4cdcf7110d80d
Diffstat (limited to 'compiler/src/main/kotlin/android/databinding')
-rw-r--r-- | compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt | 5 |
1 files changed, 3 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 3820084d..2da9367d 100644 --- a/compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt +++ b/compiler/src/main/kotlin/android/databinding/tool/writer/LayoutBinderWriter.kt @@ -749,14 +749,15 @@ class LayoutBinderWriter(val layoutBinder : LayoutBinder) { block("switch (fieldId)", { val accessedFields: List<FieldAccessExpr> = it.parents.filterIsInstance(FieldAccessExpr::class.java) accessedFields.filter { it.isUsed && it.hasBindableAnnotations() } - .groupBy { it.brName } + .flatMap { expr -> expr.dirtyingProperties.map { Pair(it, expr)} } + .groupBy { it.first } .forEach { // If two expressions look different but resolve to the same method, // we are not yet able to merge them. This is why we merge their // flags below. block("case ${it.key}:") { block("synchronized(this)") { - val flagSet = it.value.foldRight(FlagSet()) { l, r -> l.invalidateFlagSet.or(r) } + val flagSet = it.value.foldRight(FlagSet()) { l, r -> l.second.invalidateFlagSet.or(r) } mDirtyFlags.mapOr(flagSet) { suffix, index -> tab("${mDirtyFlags.localValue(index)} |= ${flagSet.localValue(index)};") |