* View used by all container views in Valdi. Will contain the ValdiContext, which * uniquely identifies a Valdi view tree. */
| 21 | * uniquely identifies a Valdi view tree. |
| 22 | */ |
| 23 | @Keep |
| 24 | open class ValdiView : ViewGroup, ValdiRecyclableView, ValdiClippableView, ValdiForegroundHolder { |
| 25 | constructor(context: Context) : super(context) |
| 26 | constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) |
| 27 | |
| 28 | override var clipToBounds = false |
| 29 | set(value) { |
| 30 | if (field != value) { |
| 31 | field = value |
| 32 | updateLayer() |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | override val clipToBoundsDefaultValue: Boolean |
| 37 | get() = false |
| 38 | |
| 39 | /** |
| 40 | * The ValdiContext to which this ValdiView belongs to. |
| 41 | */ |
| 42 | val valdiContext: ValdiContext? |
| 43 | get() = ViewUtils.findValdiContext(this) |
| 44 | |
| 45 | val valdiViewNode: ValdiViewNode? |
| 46 | get() = ViewUtils.findViewNode(this) |
| 47 | |
| 48 | private val clipperBounds = Rect(0, 0, 0, 0) |
| 49 | override val clipper = CanvasClipper() |
| 50 | |
| 51 | override var valdiForeground: Drawable? |
| 52 | get() = valdiForegroundField |
| 53 | set(value) { |
| 54 | valdiForegroundField = value |
| 55 | } |
| 56 | private var valdiForegroundField: Drawable? = null |
| 57 | |
| 58 | init { |
| 59 | clipChildren = false |
| 60 | } |
| 61 | |
| 62 | fun hasDragGestureRecognizer(): Boolean { |
| 63 | val gestureRecognizer = ViewUtils.getGestureRecognizers(this, false) ?: return false |
| 64 | return gestureRecognizer.hasGestureRecognizer(DragGestureRecognizer::class.java) |
| 65 | } |
| 66 | |
| 67 | fun getDragGestureRecognizer(): DragGestureRecognizer? { |
| 68 | val gestureRecognizer = ViewUtils.getGestureRecognizers(this, false) ?: return null |
| 69 | return gestureRecognizer.getGestureRecognizer(DragGestureRecognizer::class.java) |
| 70 | } |
| 71 | |
| 72 | override fun setClipChildren(clipChildren: Boolean) { |
| 73 | invalidate() |
| 74 | super.setClipChildren(clipChildren) |
| 75 | } |
| 76 | |
| 77 | override fun setBackground(background: Drawable?) { |
| 78 | invalidate() |
| 79 | super.setBackground(background) |
| 80 | } |