-
- All Implemented Interfaces:
-
app.rive.runtime.kotlin.core.RefCount
@OpenForTesting() public final class File extends NativeObject
Files are created in the Rive editor.
This object has a counterpart in C++, which implements much of its functionality. The base class's cppPointer keeps track of this relationship.
You can export .riv from the editor and use this class to load them. Files may contain multiple artboards.
If the given file cannot be loaded this will throw a RiveException. The Rive File format is evolving, and while we attempt to keep backwards (and forwards) compatibility where possible, there are times when this is not possible.
The Rive editor will always export your file in the latest runtime format.
⚠️ Important: If you create a File yourself using this constructor, you are responsible for calling release when you are done with it, otherwise it will leak memory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classFile.EnumThe name and values of an enum, whether system or user defined.
-
Field Summary
Fields Modifier and Type Field Description private final ReentrantLocklockprivate final ArtboardfirstArtboardprivate final IntegerartboardCountprivate final List<String>artboardNamesprivate final List<File.Enum>enumsprivate final IntegerviewModelCountprivate final RendererTyperendererTypeprivate final BooleanhasCppObjectprivate AtomicIntegerrefsprivate LongcppPointerprivate final List<RefCount>dependenciesprivate final IntegerrefCount
-
Constructor Summary
Constructors Constructor Description File(ByteArray bytes, RendererType rendererType, FileAssetLoader fileAssetLoader)
-
Method Summary
-
-
Constructor Detail
-
File
File(ByteArray bytes, RendererType rendererType, FileAssetLoader fileAssetLoader)
- Parameters:
bytes- The bytes of the .riv file.rendererType- The RendererType to use when rendering this file.fileAssetLoader- An optional FileAssetLoader to use when loading external assets (images, fonts, audio) referenced by this file.
-
-
Method Detail
-
getLock
final ReentrantLock getLock()
-
getFirstArtboard
final Artboard getFirstArtboard()
-
getArtboardCount
final Integer getArtboardCount()
-
getArtboardNames
final List<String> getArtboardNames()
-
getViewModelCount
final Integer getViewModelCount()
-
getRendererType
final RendererType getRendererType()
-
getHasCppObject
final Boolean getHasCppObject()
-
getRefs
final AtomicInteger getRefs()
-
setRefs
final Unit setRefs(AtomicInteger refs)
-
getCppPointer
final Long getCppPointer()
-
setCppPointer
final Unit setCppPointer(Long cppPointer)
-
getDependencies
final List<RefCount> getDependencies()
-
getRefCount
Integer getRefCount()
-
createBindableArtboardByName
final BindableArtboard createBindableArtboardByName(String name)
Create a BindableArtboard by name. This is can then be bound to a ViewModelArtboardProperty.
⚠️ Important: The bindable artboard can outlive this File instance, but in order to do so it has an extra reference count. You need to call BindableArtboard.release when you are done with it, otherwise it will leak memory.
- Parameters:
name- The name of the artboard in the Rive file to create.
-
createDefaultBindableArtboard
final BindableArtboard createDefaultBindableArtboard()
Create the default BindableArtboard, as marked in the Rive file. This is can then be bound to a ViewModelArtboardProperty.
⚠️ Important: The bindable artboard can outlive this File instance, but in order to do so it has an extra reference count. You need to call BindableArtboard.release when you are done with it, otherwise it will leak memory.
-
getViewModelByIndex
final ViewModel getViewModelByIndex(Integer viewModelIdx)
Get the ViewModel definition from the file.
- Parameters:
viewModelIdx- The Rive file 0-based index of the ViewModel.
-
getViewModelByName
final ViewModel getViewModelByName(String viewModelName)
Get the ViewModel definition from the file.
- Parameters:
viewModelName- The Rive file name of the ViewModel.
-
defaultViewModelForArtboard
final ViewModel defaultViewModelForArtboard(Artboard artboard)
Get the default ViewModel for an Artboard. Usually this will be the ViewModel intended for use with this artboard.
- Parameters:
artboard- The artboard to get the default ViewModel for.
-
-
-
-