ComponentNode

sealed class ComponentNode : Emittable
kotlin.Any
   ↳ androidx.ui.core.ComponentNode

The base type for all nodes from the tree generated from a component hierarchy.

Specific components are backed by a tree of nodes: Draw, Layout, SemanticsComponentNode, GestureDetector. All other components are not represented in the backing hierarchy.

Summary

Public methods

open Unit
attach(owner: Owner)

Set the Owner of this ComponentNode.

open Unit

Remove the ComponentNode from the Owner.

open Unit
emitInsertAt(index: Int, instance: Emittable)

Inserts a child ComponentNode at a particular index.

open Unit
emitMove(from: Int, to: Int, count: Int)

open Unit
emitRemoveAt(index: Int, count: Int)

Removes one or more children, starting at index.

operator ComponentNode
get(index: Int)

Returns the child ComponentNode at the given index.

Unit

Execute block on all children of this ComponentNode.

Unit

Execute block on all children of this ComponentNode in reverse order.

Extension functions

From androidx.ui.core
Unit

Inserts a child ComponentNode at a last index.

ComponentNode?

Executes selector on every parent of this ComponentNode and returns the closest ComponentNode to return true from selector or null if selector returns false for all ancestors.

LayoutNode?

Executes block on first level of LayoutNode descendants of this ComponentNode and returns the last LayoutNode to return true from block.

Boolean

Returns true if this ComponentNode has no descendant LayoutNodes.

Boolean

Returns true if this ComponentNode currently has an ComponentNode.owner.

Owner

Returns ComponentNode.owner or throws if it is null.

Unit

Executes block on first level of LayoutNode descendants of this ComponentNode.

Properties

open LayoutNode?

Protected method to find the parent's layout node.

Int

Returns the number of children in this ComponentNode.

Int

The tree depth of the ComponentNode.

Owner?

The view system Owner.

Any?

An opaque value set by the Owner.

ComponentNode?

The parent node in the ComponentNode hierarchy.

open LayoutNode?

This is the LayoutNode ancestor that contains this LayoutNode.

open RepaintBoundaryNode?

If this is a RepaintBoundaryNode, this is returned, otherwise the nearest ancestor RepaintBoundaryNode or null if there are no ancestor RepaintBoundaryNodes.

Public methods

attach

open fun attach(owner: Owner): Unit

Set the Owner of this ComponentNode. This ComponentNode must not already be attached. owner must match its parent.owner.

detach

open fun detach(): Unit

Remove the ComponentNode from the Owner. The owner must not be null before this call and its parent's owner must be null before calling this. This will also detach all children. After executing, the owner will be null.

emitInsertAt

open fun emitInsertAt(
    index: Int,
    instance: Emittable
): Unit

Inserts a child ComponentNode at a particular index. If this ComponentNode isAttached then instance will become attached also. instance must have a null parent.

emitMove

open fun emitMove(
    from: Int,
    to: Int,
    count: Int
): Unit

emitRemoveAt

open fun emitRemoveAt(
    index: Int,
    count: Int
): Unit

Removes one or more children, starting at index.

get

operator fun get(index: Int): ComponentNode

Returns the child ComponentNode at the given index. An exception will be thrown if there is no child at the given index.

visitChildren

inline fun visitChildren(block: (ComponentNode) -> Unit): Unit

Execute block on all children of this ComponentNode.

visitChildrenReverse

inline fun visitChildrenReverse(block: (ComponentNode) -> Unit): Unit

Execute block on all children of this ComponentNode in reverse order.

Properties

containingLayoutNode

protected open val containingLayoutNode: LayoutNode?

Protected method to find the parent's layout node. LayoutNode returns itself, but all other ComponentNodes return the parent's containingLayoutNode.

count

val count: Int

Returns the number of children in this ComponentNode.

depth

var depth: Int

The tree depth of the ComponentNode. This is valid only when isAttached is true.

owner

var owner: Owner?

The view system Owner. This null until attach is called

ownerData

var ownerData: Any?

An opaque value set by the Owner. It is null when isAttached is false, but may also be null when isAttached is true, depending on the needs of the Owner.

parent

var parent: ComponentNode?

The parent node in the ComponentNode hierarchy. This is null when the ComponentNode is attached (has an owner) and is the root of the tree or has not had add called for it.

parentLayoutNode

open val parentLayoutNode: LayoutNode?

This is the LayoutNode ancestor that contains this LayoutNode. This will be null for the root LayoutNode.

repaintBoundary

open val repaintBoundary: RepaintBoundaryNode?

If this is a RepaintBoundaryNode, this is returned, otherwise the nearest ancestor RepaintBoundaryNode or null if there are no ancestor RepaintBoundaryNodes.