Fixed
Status Update
Comments
rm...@google.com <rm...@google.com> #2
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
da...@google.com <da...@google.com> #3
To whomever picks up this bug, it looks like a few operators are not supported in data binding expressions. In fact, I'm surprised that ">" works when "<" doesn't... but looking online, it seems people have been using html escape codes in these cases, e.g.
< <
> >
& &
We should check with our PM, but I'm just thinking out loud here -- a reasonable solution here is two-fold (and we can break this up into two separate bugs in this case):
1) Add lints for automatically escaping these characters
2) IntelliJ supports code folding, so potentially fold these ugly escape characters so to people reading the code it looks normal
e.g.
"@{width > 0 && height > 0 ? ... : ...}"
might get folded into
"@{width [>] 0 [&&] height [>] 0 ? ... : ...}"
< <
> >
& &
We should check with our PM, but I'm just thinking out loud here -- a reasonable solution here is two-fold (and we can break this up into two separate bugs in this case):
1) Add lints for automatically escaping these characters
2) IntelliJ supports code folding, so potentially fold these ugly escape characters so to people reading the code it looks normal
e.g.
"@{width > 0 && height > 0 ? ... : ...}"
might get folded into
"@{width [>] 0 [&&] height [>] 0 ? ... : ...}"
da...@google.com <da...@google.com>
kn...@google.com <kn...@google.com>
kn...@google.com <kn...@google.com>
da...@google.com <da...@google.com> #4
Roar, just wanted to thank you again as you have submitted several great bugs with us. We're happy to report that the experience around unescaped XML in data binding should be much better moving forward. I think some of the improvements for this bug will land in the next Canary (Canary 7) and everything should be in by the one after that (Canary 8).
Feel free to reply to this bug if there's anything in the experience that you still think can be improved.
Feel free to reply to this bug if there's anything in the experience that you still think can be improved.
ro...@gmail.com <ro...@gmail.com> #5
I find myself now trying to use && (AND) in a reference where result should be true or false. Same problem here, and I need to use && insted. This should also be stated here: https://developer.android.com/topic/libraries/data-binding/expressions.html#common_features that using && might be a problem.
Is there any decision on brackets '[]' can/should be used instead (shorter though, but not really nice). Anyhow the '{' should be enough to state an exception on how references are parsed.
RG
Is there any decision on brackets '[]' can/should be used instead (shorter though, but not really nice). Anyhow the '{' should be enough to state an exception on how references are parsed.
RG
Description
AI-183.4139.22.34.5129585, JRE 1.8.0_152-release-1248-b01x64 JetBrains s.r.o, OS Windows 10(amd64) v10.0 , screens 1600x900, 1920x1080
Android Gradle Plugin: 3.4.0-alpha04
Gradle: 5.0
NDK: from local.properties: (not specified); latest from SDK: (not found);
LLDB: pinned revision 3.1 not found; latest from SDK: (package not found);
CMake: from local.properties: (not specified); latest from SDK: (not found); from PATH: (not found);
IMPORTANT: Please read
---
Using lesser than '<' in android:text for TextView may produce error message that '<' cannot be used.
Following example will produce succh error:
android:text = "@{station.airDistance < 1.0 ? @string/air_distance_data_format_string_m(station.airDistance/1000):@string/air_distance_data_format_string_km(station.airDistance)}"
--
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: The value of attribute "android:text" associated with an element type "TextView" must not contain the '<' character.
--
---
changing the logic to use greater than '>' will NOT produce error message. Remedies with changing the logic to:
android:text = "@{station.airDistance > 1.0 ? @string/air_distance_data_format_string_km(station.airDistance):@string/air_distance_data_format_string_m(station.airDistance*1000)}"
Conclusion?
Either you should state it is not possible to use lesser than or you should fix it so it can use lesser than.
See discussion here:
RG