-
- All Implemented Interfaces:
-
app.rive.runtime.kotlin.Observable,app.rive.runtime.kotlin.core.RefCount
public final class RiveFileController implements Observable<RiveFileController.Listener>, RefCount
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classRiveFileController.Companionpublic interfaceRiveFileController.Listenerpublic interfaceRiveFileController.RiveEventListener
-
Field Summary
Fields Modifier and Type Field Description private AtomicIntegerrefsprivate BooleanisActiveprivate Fitfitprivate Alignmentalignmentprivate FloatlayoutScaleFactorprivate FloatlayoutScaleFactorAutomaticprivate Filefileprivate ArtboardactiveArtboardprivate final List<LinearAnimationInstance>animationsprivate final List<StateMachineInstance>stateMachinesprivate final <ERROR CLASS><LinearAnimationInstance>playingAnimationsprivate final <ERROR CLASS><StateMachineInstance>playingStateMachinesprivate final Set<LinearAnimationInstance>pausedAnimationsprivate final Set<StateMachineInstance>pausedStateMachinesprivate final BooleanisAdvancingprivate final RectFartboardBoundsprivate RectFtargetBoundsprivate final <ERROR CLASS><RiveFileController.Listener>listenersprivate final <ERROR CLASS><RiveFileController.RiveEventListener>eventListenersprivate Looploopprivate Booleanautoplayprivate Function0<Unit>onStartprivate final IntegerrefCount
-
Method Summary
Modifier and Type Method Description AtomicIntegergetRefs()The number of objects referencing this controller. UnitsetRefs(AtomicInteger refs)The number of objects referencing this controller. final BooleangetIsActive()Whether this controller is active or not. final UnitsetIsActive(Boolean isActive)Whether this controller is active or not. final FitgetFit()final UnitsetFit(Fit fit)final AlignmentgetAlignment()final UnitsetAlignment(Alignment alignment)final FloatgetLayoutScaleFactor()The scale factor to use for Fit.LAYOUT. final UnitsetLayoutScaleFactor(Float layoutScaleFactor)final FloatgetLayoutScaleFactorAutomatic()The automatic scale factor set by Rive. final UnitsetLayoutScaleFactorAutomatic(Float layoutScaleFactorAutomatic)final FilegetFile()final UnitsetFile(File file)final ArtboardgetActiveArtboard()final UnitsetActiveArtboard(Artboard activeArtboard)final List<LinearAnimationInstance>getAnimations()final List<StateMachineInstance>getStateMachines()final <ERROR CLASS><LinearAnimationInstance>getPlayingAnimations()final <ERROR CLASS><StateMachineInstance>getPlayingStateMachines()final Set<LinearAnimationInstance>getPausedAnimations()final Set<StateMachineInstance>getPausedStateMachines()final BooleangetIsAdvancing()final RectFgetArtboardBounds()final RectFgetTargetBounds()final UnitsetTargetBounds(RectF targetBounds)final <ERROR CLASS><RiveFileController.Listener>getListeners()final <ERROR CLASS><RiveFileController.RiveEventListener>getEventListeners()final LoopgetLoop()final UnitsetLoop(Loop loop)final BooleangetAutoplay()final UnitsetAutoplay(Boolean autoplay)final Function0<Unit>getOnStart()final UnitsetOnStart(Function0<Unit> onStart)IntegergetRefCount()final ControllerStatesaveControllerState()Get a copy of the state of this controller and acquire a reference to the file to prevent it being released from memory. final UnitrestoreControllerState(ControllerState state)Restore a copy of the state to this Controller. final Unitadvance(Float elapsed)Note: This is happening in the render thread: this function is synchronized with a ReentrantLock stored on the File because this is a critical section with the UI thread. final UnitsetRiveFile(File file, String artboardName)Assigns the file to this Controller and instances the artboard provided via artboardName. final UnitselectArtboard(String name)Instances the artboard with the specified name. final Unitautoplay()final Unitplay(List<String> animationNames, Loop loop, Direction direction, Boolean areStateMachines, Boolean settleInitialState)final Unitplay(String animationName, Loop loop, Direction direction, Boolean isStateMachine, Boolean settleInitialState)final Unitplay(Loop loop, Direction direction, Boolean settleInitialState)Restarts paused animations if there are any. final Unitpause()final Unitpause(List<String> animationNames, Boolean areStateMachines)final Unitpause(String animationName, Boolean isStateMachine)final UnitstopAnimations()Named stopAnimations to avoid conflicting with stop. final UnitstopAnimations(List<String> animationNames, Boolean areStateMachines)final UnitstopAnimations(String animationName, Boolean isStateMachine)final UnitfireState(String stateMachineName, String inputName, String path)final UnitsetBooleanState(String stateMachineName, String inputName, Boolean value, String path)final UnitsetNumberState(String stateMachineName, String inputName, Float value, String path)final UnitfireStateAtPath(String inputName, String path)final UnitsetBooleanStateAtPath(String inputName, Boolean value, String path)final UnitsetNumberStateAtPath(String inputName, Float value, String path)final StringgetTextRunValue(String textRunName)Get the current value for a text run named textRunName on the active artboard if it exists. final StringgetTextRunValue(String textRunName, String path)Get the text value for a text run named textRunName on the nested artboard represented at path. final UnitsetTextRunValue(String textRunName, String textValue)Set the text value for a text run named textRunName to textValue on the active artboard. final UnitsetTextRunValue(String textRunName, String textValue, String path)Set the text value for a text run named textRunName to textValue on the nested artboard represented at path. final FloatgetVolume()Get the active Artboard's volume. final UnitsetVolume(Float value)Set the active Artboard's volume to value. final UnitpointerEvent(PointerEvents eventType, Float x, Float y)UnitregisterListener(RiveFileController.Listener listener)UnitunregisterListener(RiveFileController.Listener listener)final UnitaddEventListener(RiveFileController.RiveEventListener listener)Adds a RiveEventListener to get notified on RiveEvents. final UnitremoveEventListener(RiveFileController.RiveEventListener listener)Removes the listener. Integerrelease()Release a reference associated with this Controller. -
-
Method Detail
-
getRefs
AtomicInteger getRefs()
-
setRefs
Unit setRefs(AtomicInteger refs)
-
getIsActive
final Boolean getIsActive()
Whether this controller is active or not. If this is false, it will prevent advancing or drawing.
-
setIsActive
final Unit setIsActive(Boolean isActive)
Whether this controller is active or not. If this is false, it will prevent advancing or drawing.
-
getAlignment
final Alignment getAlignment()
-
setAlignment
final Unit setAlignment(Alignment alignment)
-
getLayoutScaleFactor
final Float getLayoutScaleFactor()
The scale factor to use for Fit.LAYOUT. If null, it will use a density determined by Rive (automatic). See RiveFileController.layoutScaleFactorAutomatic for more details.
-
setLayoutScaleFactor
final Unit setLayoutScaleFactor(Float layoutScaleFactor)
-
getLayoutScaleFactorAutomatic
final Float getLayoutScaleFactorAutomatic()
The automatic scale factor set by Rive. This value will only be used if layoutScaleFactor is not set (null).
-
setLayoutScaleFactorAutomatic
final Unit setLayoutScaleFactorAutomatic(Float layoutScaleFactorAutomatic)
-
getActiveArtboard
final Artboard getActiveArtboard()
-
setActiveArtboard
final Unit setActiveArtboard(Artboard activeArtboard)
-
getAnimations
final List<LinearAnimationInstance> getAnimations()
-
getStateMachines
final List<StateMachineInstance> getStateMachines()
-
getPlayingAnimations
final <ERROR CLASS><LinearAnimationInstance> getPlayingAnimations()
-
getPlayingStateMachines
final <ERROR CLASS><StateMachineInstance> getPlayingStateMachines()
-
getPausedAnimations
final Set<LinearAnimationInstance> getPausedAnimations()
-
getPausedStateMachines
final Set<StateMachineInstance> getPausedStateMachines()
-
getIsAdvancing
final Boolean getIsAdvancing()
-
getArtboardBounds
final RectF getArtboardBounds()
-
getTargetBounds
final RectF getTargetBounds()
-
setTargetBounds
final Unit setTargetBounds(RectF targetBounds)
-
getListeners
final <ERROR CLASS><RiveFileController.Listener> getListeners()
-
getEventListeners
final <ERROR CLASS><RiveFileController.RiveEventListener> getEventListeners()
-
getAutoplay
final Boolean getAutoplay()
-
setAutoplay
final Unit setAutoplay(Boolean autoplay)
-
getOnStart
final Function0<Unit> getOnStart()
-
setOnStart
final Unit setOnStart(Function0<Unit> onStart)
-
getRefCount
Integer getRefCount()
-
saveControllerState
final ControllerState saveControllerState()
Get a copy of the state of this controller and acquire a reference to the file to prevent it being released from memory.
Returns a ControllerState object with everything the controller was using. If the controller is pointing to stale data, it will return null.
-
restoreControllerState
final Unit restoreControllerState(ControllerState state)
Restore a copy of the state to this Controller.
It also release()s any resources currently associated with this Controller in favor of the ones stored on the state.
-
advance
@WorkerThread() final Unit advance(Float elapsed)
Note: This is happening in the render thread: this function is synchronized with a ReentrantLock stored on the File because this is a critical section with the UI thread. When advancing or performing operations around an animations data structure, be conscious of thread safety.
-
setRiveFile
final Unit setRiveFile(File file, String artboardName)
Assigns the file to this Controller and instances the artboard provided via artboardName. If none is provided, it instantiates the first (i.e. default) artboard. If this controller is set to autoplay it will also start playing.
-
selectArtboard
final Unit selectArtboard(String name)
-
play
final Unit play(List<String> animationNames, Loop loop, Direction direction, Boolean areStateMachines, Boolean settleInitialState)
-
play
final Unit play(String animationName, Loop loop, Direction direction, Boolean isStateMachine, Boolean settleInitialState)
-
play
final Unit play(Loop loop, Direction direction, Boolean settleInitialState)
Restarts paused animations if there are any. Otherwise, it starts playing the first animation (timeline or state machine) in the Artboard.
-
stopAnimations
final Unit stopAnimations()
Named stopAnimations to avoid conflicting with stop.
-
stopAnimations
final Unit stopAnimations(List<String> animationNames, Boolean areStateMachines)
-
stopAnimations
final Unit stopAnimations(String animationName, Boolean isStateMachine)
-
setBooleanState
final Unit setBooleanState(String stateMachineName, String inputName, Boolean value, String path)
-
setNumberState
final Unit setNumberState(String stateMachineName, String inputName, Float value, String path)
-
fireStateAtPath
final Unit fireStateAtPath(String inputName, String path)
-
setBooleanStateAtPath
final Unit setBooleanStateAtPath(String inputName, Boolean value, String path)
-
setNumberStateAtPath
final Unit setNumberStateAtPath(String inputName, Float value, String path)
-
getTextRunValue
final String getTextRunValue(String textRunName)
Get the current value for a text run named textRunName on the active artboard if it exists.
-
getTextRunValue
final String getTextRunValue(String textRunName, String path)
Get the text value for a text run named textRunName on the nested artboard represented at path.
-
setTextRunValue
final Unit setTextRunValue(String textRunName, String textValue)
Set the text value for a text run named textRunName to textValue on the active artboard.
-
setTextRunValue
final Unit setTextRunValue(String textRunName, String textValue, String path)
Set the text value for a text run named textRunName to textValue on the nested artboard represented at path.
-
pointerEvent
final Unit pointerEvent(PointerEvents eventType, Float x, Float y)
-
registerListener
Unit registerListener(RiveFileController.Listener listener)
-
unregisterListener
Unit unregisterListener(RiveFileController.Listener listener)
-
addEventListener
final Unit addEventListener(RiveFileController.RiveEventListener listener)
Adds a RiveEventListener to get notified on RiveEvents.
Remove with: removeEventListener.
-
removeEventListener
final Unit removeEventListener(RiveFileController.RiveEventListener listener)
Removes the listener.
-
-
-
-