Do not cast findViewById to View

This commit is contained in:
Yan Zhulanow
2015-03-20 19:44:41 +03:00
parent 2061e390b4
commit c40598b3e9
3 changed files with 11 additions and 10 deletions
@@ -135,7 +135,8 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
}
private fun KotlinStringWriter.writeSyntheticProperty(receiver: String, widget: AndroidWidget, stubCall: String) {
val body = arrayListOf("return $stubCall as ${widget.className}")
val cast = if (widget.className == "View") ":" else "as"
val body = arrayListOf("return $stubCall $cast ${widget.className}")
val type = widget.className
writeImmutableExtensionProperty(receiver,
name = widget.id,
@@ -7,20 +7,20 @@ import android.widget.*
import kotlin.internal.flexible.ft
val Activity.includeTag: ft<View, View?>
get() = findViewById(0) as View
get() = findViewById(0) : View
val Fragment.includeTag: ft<View, View?>
get() = getView().findViewById(0) as View
get() = getView().findViewById(0) : View
val Activity.mergeTag: ft<View, View?>
get() = findViewById(0) as View
get() = findViewById(0) : View
val Fragment.mergeTag: ft<View, View?>
get() = getView().findViewById(0) as View
get() = getView().findViewById(0) : View
val Activity.fragmentTag: ft<View, View?>
get() = findViewById(0) as View
get() = findViewById(0) : View
val Fragment.fragmentTag: ft<View, View?>
get() = getView().findViewById(0) as View
get() = getView().findViewById(0) : View
@@ -7,11 +7,11 @@ import android.widget.*
import kotlin.internal.flexible.ft
val View.includeTag: ft<View, View?>
get() = findViewById(0) as View
get() = findViewById(0) : View
val View.mergeTag: ft<View, View?>
get() = findViewById(0) as View
get() = findViewById(0) : View
val View.fragmentTag: ft<View, View?>
get() = findViewById(0) as View
get() = findViewById(0) : View