MCPcopy Create free account
hub / github.com/Snapchat/Valdi / ValdiViewNode

Class ValdiViewNode

valdi/src/java/com/snap/valdi/nodes/ValdiViewNode.kt:36–456  ·  view source on GitHub ↗

* A ValdiViewNode identifies a View inside a ValdiContext. */

Source from the content-addressed store, hash-verified

34/**
35 * A ValdiViewNode identifies a View inside a ValdiContext.
36 */
37class ValdiViewNode(nativeHandle: Long,
38 private var context: ValdiContext?): NativeRef(nativeHandle), IValdiViewNode {
39
40 private data class AccessibilityHierarchyRepresentation(
41 val array: Array<Any?>,
42 var index: Int,
43 )
44
45 override val id: Int
46 get() = NativeBridge.getNodeId(nativeHandle)
47
48 override val viewClassName: String
49 get() = NativeBridge.getViewClassName(nativeHandle) ?: ""
50
51 val isLayoutDirectionHorizontal: Boolean
52 get() = NativeBridge.isViewNodeLayoutDirectionHorizontal(nativeHandle)
53
54 private val runtimeNativeHandle: Long
55 get() {
56 val contextNative = this.context?.native ?: return 0L
57
58 return contextNative.runtimeNative.nativeHandle
59 }
60
61 override fun invalidateLayout() {
62 NativeBridge.invalidateLayout(nativeHandle)
63 }
64
65 override fun setAttribute(attributeName: String, attributeValue: Any?, keepAsOverride: Boolean) {
66 NativeBridge.setValueForAttribute(nativeHandle, attributeName, attributeValue, keepAsOverride)
67 }
68
69 fun setInlineTextAnimationAttributes(
70 hasOpacity: Boolean,
71 opacity: Double,
72 hasTransform: Boolean,
73 translationY: Double,
74 scale: Double
75 ) {
76 NativeBridge.setInlineTextAnimationAttributesForViewNode(
77 nativeHandle,
78 hasOpacity,
79 opacity,
80 hasTransform,
81 translationY,
82 scale
83 )
84 }
85
86 override fun getAttribute(attributeName: String): Any? {
87 return NativeBridge.getValueForAttribute(nativeHandle, attributeName)
88 }
89
90 override fun setStoredObject(key: InternedString, value: Any?) {
91 val nativeKey = (key as? InternedStringCPP)?.nativeHandle ?: return
92 NativeBridge.setStoredObjectForViewNode(nativeHandle, nativeKey, value)
93 }

Callers 5

getRetainedViewNodeMethod · 0.85
doGetChildrenMethod · 0.85
hitTestAccessibilityMethod · 0.85
createViewNodeWrapperMethod · 0.85

Calls 3

getNodeIdMethod · 0.45
getViewClassNameMethod · 0.45

Tested by

no test coverage detected