mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix(xml-inflater): do not set background and foreground to TextureView
This commit is contained in:
@@ -71,6 +71,7 @@ abstract class IViewAdapter<T : View> : AbstractParser() {
|
||||
private val attributeHandlers by lazy {
|
||||
val handlers = mutableMapOf<String, AttributeHandlerScope<T>.() -> Unit>()
|
||||
createAttrHandlers(handlers::put)
|
||||
postCreateAttrHandlers(handlers)
|
||||
return@lazy handlers
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ abstract class IViewAdapter<T : View> : AbstractParser() {
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
*/
|
||||
protected open fun removeAttrHandler(name: String) {
|
||||
protected fun removeAttrHandler(name: String) {
|
||||
this.attributeHandlers.remove(name)
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ abstract class IViewAdapter<T : View> : AbstractParser() {
|
||||
* @param name The name of the attribute.
|
||||
* @param handler The attribute handler.
|
||||
*/
|
||||
protected open fun putAttrHandler(name: String,
|
||||
protected fun putAttrHandler(name: String,
|
||||
handler: AttributeHandlerScope<T>.() -> Unit) {
|
||||
this.attributeHandlers[name] = handler
|
||||
}
|
||||
@@ -210,4 +211,15 @@ abstract class IViewAdapter<T : View> : AbstractParser() {
|
||||
create: (String, AttributeHandlerScope<T>.() -> Unit) -> Unit
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the attribute handlers are created. Subclasses can use this to remove attribute
|
||||
* handlers that are added by their superclasses.
|
||||
*
|
||||
* @param handlers The attribute handlers, mapped by the attribute names.
|
||||
* @see createAttrHandlers
|
||||
*/
|
||||
protected open fun postCreateAttrHandlers(
|
||||
handlers: MutableMap<String, AttributeHandlerScope<T>.() -> Unit>) {
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -20,6 +20,7 @@ package com.itsaky.androidide.inflater.internal.adapters
|
||||
import android.view.TextureView
|
||||
import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner
|
||||
import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.WIDGETS
|
||||
import com.itsaky.androidide.inflater.AttributeHandlerScope
|
||||
import com.itsaky.androidide.inflater.models.UiWidget
|
||||
import com.itsaky.androidide.resources.R.drawable
|
||||
import com.itsaky.androidide.resources.R.string
|
||||
@@ -32,6 +33,15 @@ import com.itsaky.androidide.resources.R.string
|
||||
@com.itsaky.androidide.annotations.inflater.ViewAdapter(TextureView::class)
|
||||
@IncludeInDesigner(group = WIDGETS)
|
||||
open class TextureViewAdapter<T : TextureView> : ViewAdapter<T>() {
|
||||
|
||||
private val unsupportedAttrs = arrayOf("background", "foreground")
|
||||
|
||||
override fun postCreateAttrHandlers(
|
||||
handlers: MutableMap<String, AttributeHandlerScope<T>.() -> Unit>) {
|
||||
|
||||
unsupportedAttrs.forEach(handlers::remove)
|
||||
}
|
||||
|
||||
override fun createUiWidgets(): List<UiWidget> {
|
||||
return listOf(
|
||||
UiWidget(TextureView::class.java, string.widget_textureview, drawable.ic_widget_textureview)
|
||||
|
||||
Reference in New Issue
Block a user