MovableComponent


public final class MovableComponent implements Component


Allows users to interactively move the Entity. This component can be attached to a single instance of any PanelEntity.

NOTE: This Component is currently unsupported on GltfModelEntity.

Summary

Public methods

final void
addMoveListener(
    @NonNull Executor executor,
    @NonNull MoveListener moveListener
)

Adds a listener to the set of active listeners for the move events.

final @NonNull Dimensions

The current size of the entity, in meters.

boolean

Called when this component is attached to the entity.

void

Called when this component is detached from the entity.

final void

Removes a listener from the set of active listeners for the move events.

final void

The current size of the entity, in meters.

Public methods

addMoveListener

Added in 1.0.0-alpha01
public final void addMoveListener(
    @NonNull Executor executor,
    @NonNull MoveListener moveListener
)

Adds a listener to the set of active listeners for the move events. The listener will be invoked regardless of whether the entity is being moved by the system or the user.

The listener is invoked on the provided executor. If the app intends to modify the UI elements/views during the callback, the app should provide the thread executor that is appropriate for the UI operations. For example, if the app is using the main thread to render the UI, the app should provide the main thread (Looper.getMainLooper()) executor. If the app is using a separate thread to render the UI, the app should provide the executor for that thread.

Parameters
@NonNull Executor executor

The executor to run the listener on.

@NonNull MoveListener moveListener

The move event listener to set.

getSize

Added in 1.0.0-alpha01
public final @NonNull Dimensions getSize()

The current size of the entity, in meters. The size of the entity determines the size of the bounding box that is used to draw the draggable move affordances around the entity.

onAttach

Added in 1.0.0-alpha01
public boolean onAttach(@NonNull Entity entity)

Called when this component is attached to the entity.

Parameters
@NonNull Entity entity

Entity this component is being attached to.

Returns
boolean

True if the component can attach to given Entity.

onDetach

Added in 1.0.0-alpha01
public void onDetach(@NonNull Entity entity)

Called when this component is detached from the entity.

Parameters
@NonNull Entity entity

Entity this component is being detached from.

removeMoveListener

Added in 1.0.0-alpha01
public final void removeMoveListener(@NonNull MoveListener moveListener)

Removes a listener from the set of active listeners for the move events.

Parameters
@NonNull MoveListener moveListener

The move event listener to remove.

setSize

Added in 1.0.0-alpha01
public final void setSize(@NonNull Dimensions size)

The current size of the entity, in meters. The size of the entity determines the size of the bounding box that is used to draw the draggable move affordances around the entity.