Cast findViewById() result to Views safely

This commit is contained in:
Yan Zhulanow
2015-03-26 16:03:58 +03:00
parent 1f16328070
commit fae114f606
17 changed files with 62 additions and 62 deletions
@@ -140,8 +140,8 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
}
private fun KotlinStringWriter.writeSyntheticProperty(receiver: String, widget: AndroidWidget, stubCall: String) {
val cast = if (widget.className == "View") ":" else "as"
val body = arrayListOf("return $stubCall $cast ${widget.className}")
val cast = if (widget.className != "View") " as? ${widget.className}" else ""
val body = arrayListOf("return $stubCall$cast")
val type = widget.className
writeImmutableExtensionProperty(receiver,
name = widget.id,