Do not cast findViewById to View
This commit is contained in:
+2
-1
@@ -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,
|
||||
|
||||
+6
-6
@@ -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
|
||||
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user