Generate synthetic packages even for layouts without @+id/ attributes declared
This commit is contained in:
+11
-12
@@ -92,20 +92,19 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
|||||||
return resourceManager.getLayoutXmlFiles().flatMap { entry ->
|
return resourceManager.getLayoutXmlFiles().flatMap { entry ->
|
||||||
val files = entry.getValue()
|
val files = entry.getValue()
|
||||||
val widgets = parseLayout(files)
|
val widgets = parseLayout(files)
|
||||||
if (widgets.isNotEmpty()) {
|
|
||||||
val layoutPackage = files[0].genSyntheticPackageName()
|
|
||||||
|
|
||||||
val mainLayoutFile = renderLayoutFile(layoutPackage, widgets) {
|
val layoutPackage = files[0].genSyntheticPackageName()
|
||||||
writeSyntheticProperty("Activity", it, "findViewById(0)")
|
|
||||||
writeSyntheticProperty("Fragment", it, "getView().findViewById(0)")
|
|
||||||
}
|
|
||||||
|
|
||||||
val viewLayoutFile = renderLayoutFile("$layoutPackage.view", widgets) {
|
val mainLayoutFile = renderLayoutFile(layoutPackage, widgets) {
|
||||||
writeSyntheticProperty("View", it, "findViewById(0)")
|
writeSyntheticProperty("Activity", it, "findViewById(0)")
|
||||||
}
|
writeSyntheticProperty("Fragment", it, "getView().findViewById(0)")
|
||||||
|
}
|
||||||
|
|
||||||
listOf(mainLayoutFile, viewLayoutFile)
|
val viewLayoutFile = renderLayoutFile("$layoutPackage.view", widgets) {
|
||||||
} else listOf()
|
writeSyntheticProperty("View", it, "findViewById(0)")
|
||||||
|
}
|
||||||
|
|
||||||
|
listOf(mainLayoutFile, viewLayoutFile)
|
||||||
}.filterNotNull() + commonFiles
|
}.filterNotNull() + commonFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +155,7 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
|||||||
for (widget in widgets) {
|
for (widget in widgets) {
|
||||||
if (widgetMap.contains(widget.id)) {
|
if (widgetMap.contains(widget.id)) {
|
||||||
val existingElement = widgetMap.get(widget.id)
|
val existingElement = widgetMap.get(widget.id)
|
||||||
if (existingElement.className != widget.className) {
|
if (existingElement.className != widget.className && existingElement.className != "View") {
|
||||||
// Widgets with the same id but different types exist.
|
// Widgets with the same id but different types exist.
|
||||||
widgetMap.put(widget.id, widget.copy(className = "View"))
|
widgetMap.put(widget.id, widget.copy(className = "View"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package kotlinx.android.synthetic.layout
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Fragment
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.*
|
||||||
|
import kotlin.internal.flexible.ft
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package kotlinx.android.synthetic.layout.view
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Fragment
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.*
|
||||||
|
import kotlin.internal.flexible.ft
|
||||||
|
|
||||||
Reference in New Issue
Block a user