public class NativeAnimatedModule extends ReactContextBaseJavaModule implements LifecycleEventListener, UIManagerModuleListener
NativeAnimatedNodesManager
. Since all the methods from
NativeAnimatedNodesManager
need to be called from the UI thread, we we create a queue of
animated graph operations that is then enqueued to be executed in the UI Thread at the end of the
batch of JS->native calls (similarly to how it's handled in UIManagerModule
). This
isolates us from the problems that may be caused by concurrent updates of animated graph while UI
thread is "executing" the animation loop.NativeModule.NativeMethod
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
NAME |
METHOD_TYPE_ASYNC, METHOD_TYPE_PROMISE, METHOD_TYPE_SYNC
Constructor and Description |
---|
NativeAnimatedModule(ReactApplicationContext reactContext) |
Modifier and Type | Method and Description |
---|---|
void |
addAnimatedEventToView(int viewTag,
java.lang.String eventName,
ReadableMap eventMapping) |
void |
connectAnimatedNodes(int parentNodeTag,
int childNodeTag) |
void |
connectAnimatedNodeToView(int animatedNodeTag,
int viewTag) |
void |
createAnimatedNode(int tag,
ReadableMap config) |
void |
disconnectAnimatedNodeFromView(int animatedNodeTag,
int viewTag) |
void |
disconnectAnimatedNodes(int parentNodeTag,
int childNodeTag) |
void |
dropAnimatedNode(int tag) |
void |
extractAnimatedNodeOffset(int tag) |
void |
flattenAnimatedNodeOffset(int tag) |
java.lang.String |
getName() |
void |
initialize()
This is called at the end of
CatalystApplicationFragment#createCatalystInstance()
after the CatalystInstance has been created, in order to initialize NativeModules that require
the CatalystInstance or JS modules. |
void |
onHostDestroy()
Called when host activity receives destroy event (e.g.
|
void |
onHostPause()
Called when host activity receives pause event (e.g.
|
void |
onHostResume()
Called either when the host activity receives a resume event (e.g.
|
void |
removeAnimatedEventFromView(int viewTag,
java.lang.String eventName,
int animatedValueTag) |
void |
setAnimatedNodeOffset(int tag,
double value) |
void |
setAnimatedNodeValue(int tag,
double value) |
void |
setNodesManager(com.facebook.react.animated.NativeAnimatedNodesManager nodesManager) |
void |
startAnimatingNode(int animationId,
int animatedNodeTag,
ReadableMap animationConfig,
Callback endCallback) |
void |
startListeningToAnimatedNodeValue(int tag) |
void |
stopAnimation(int animationId) |
void |
stopListeningToAnimatedNodeValue(int tag) |
void |
willDispatchViewUpdates(UIManagerModule uiManager)
Called right before view updates are dispatched at the end of a batch.
|
getCurrentActivity, getReactApplicationContext
canOverrideExistingModule, getConstants, hasConstants, onCatalystInstanceDestroy
protected static final java.lang.String NAME
public NativeAnimatedModule(ReactApplicationContext reactContext)
public void initialize()
NativeModule
CatalystApplicationFragment#createCatalystInstance()
after the CatalystInstance has been created, in order to initialize NativeModules that require
the CatalystInstance or JS modules.initialize
in interface NativeModule
initialize
in class BaseJavaModule
public void onHostResume()
LifecycleEventListener
Activity#onResume
or
if the native module that implements this is initialized while the host activity is already
resumed. Always called for the most current activity.onHostResume
in interface LifecycleEventListener
public void willDispatchViewUpdates(UIManagerModule uiManager)
UIManagerModuleListener
willDispatchViewUpdates
in interface UIManagerModuleListener
public void onHostPause()
LifecycleEventListener
Activity#onPause
. Always called
for the most current activity.onHostPause
in interface LifecycleEventListener
public void onHostDestroy()
LifecycleEventListener
Activity#onDestroy
. Only called
for the last React activity to be destroyed.onHostDestroy
in interface LifecycleEventListener
public java.lang.String getName()
getName
in interface NativeModule
require()
this module
from javascript.public void setNodesManager(com.facebook.react.animated.NativeAnimatedNodesManager nodesManager)
public void createAnimatedNode(int tag, ReadableMap config)
public void startListeningToAnimatedNodeValue(int tag)
public void stopListeningToAnimatedNodeValue(int tag)
public void dropAnimatedNode(int tag)
public void setAnimatedNodeValue(int tag, double value)
public void setAnimatedNodeOffset(int tag, double value)
public void flattenAnimatedNodeOffset(int tag)
public void extractAnimatedNodeOffset(int tag)
public void startAnimatingNode(int animationId, int animatedNodeTag, ReadableMap animationConfig, Callback endCallback)
public void stopAnimation(int animationId)
public void connectAnimatedNodes(int parentNodeTag, int childNodeTag)
public void disconnectAnimatedNodes(int parentNodeTag, int childNodeTag)
public void connectAnimatedNodeToView(int animatedNodeTag, int viewTag)
public void disconnectAnimatedNodeFromView(int animatedNodeTag, int viewTag)
public void addAnimatedEventToView(int viewTag, java.lang.String eventName, ReadableMap eventMapping)
public void removeAnimatedEventFromView(int viewTag, java.lang.String eventName, int animatedValueTag)