diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/TextureViewAdapter.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/TextureViewAdapter.kt index f97b12b47..853e515c9 100644 --- a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/TextureViewAdapter.kt +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/TextureViewAdapter.kt @@ -21,6 +21,7 @@ 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.internal.ui.DesignerTextureView import com.itsaky.androidide.inflater.models.UiWidget import com.itsaky.androidide.resources.R.drawable import com.itsaky.androidide.resources.R.string @@ -44,7 +45,8 @@ open class TextureViewAdapter : ViewAdapter() { override fun createUiWidgets(): List { return listOf( - UiWidget(TextureView::class.java, string.widget_textureview, drawable.ic_widget_textureview) + UiWidget(DesignerTextureView::class.java, string.widget_textureview, + drawable.ic_widget_textureview) ) } } diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/ui/DesignerTextureView.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/ui/DesignerTextureView.kt new file mode 100644 index 000000000..0a5ff5c93 --- /dev/null +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/ui/DesignerTextureView.kt @@ -0,0 +1,44 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.inflater.internal.ui + +import android.content.Context +import android.graphics.drawable.Drawable +import android.util.AttributeSet +import android.view.TextureView +import androidx.annotation.StyleRes + +/** + * Custom [TextureView] that is used in the XML Layout Inflater. This implementation does not throw + * an [UnsupportedOperationException] when [setForeground] or [setBackgroundDrawable] is called. + * + * @author Akash Yadav + */ +class DesignerTextureView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, + @StyleRes defStyleAttr: Int = 0, @StyleRes defStyleRes: Int = 0) : + TextureView(context, attrs, defStyleAttr, defStyleRes) { + + override fun setForeground(foreground: Drawable?) { + // ignore + } + + @Deprecated("Deprecated in Java") + override fun setBackgroundDrawable(background: Drawable?) { + // ignore + } +} \ No newline at end of file