JavaTimerManager

open class JavaTimerManager(reactApplicationContext: ReactApplicationContext, javaScriptTimerExecutor: JavaScriptTimerExecutor, reactChoreographer: ReactChoreographer, devSupportManager: DevSupportManager) : LifecycleEventListener, HeadlessJsTaskEventListener

This class is the native implementation for JS timer execution on Android. It schedules JS timers to be invoked on frame boundaries using ReactChoreographer.

This is used by the NativeModule TimingModule.

Constructors

Link copied to clipboard
constructor(reactApplicationContext: ReactApplicationContext, javaScriptTimerExecutor: JavaScriptTimerExecutor, reactChoreographer: ReactChoreographer, devSupportManager: DevSupportManager)

Functions

Link copied to clipboard
open fun createAndMaybeCallTimer(timerId: Int, duration: Int, jsSchedulingTime: Double, repeat: Boolean)

A method to be used for asynchronously creating a timer. If the timer has already expired, (based on the provided jsSchedulingTime) then it will be immediately invoked.

Link copied to clipboard
open fun createTimer(timerId: Int, delay: Long, repeat: Boolean)

A method to be used for synchronously creating a timer. The timer will not be invoked until the next frame, regardless of whether it has already expired (i.e. the delay is 0).

Link copied to clipboard
open fun deleteTimer(timerId: Int)
Link copied to clipboard
open override fun onHeadlessJsTaskFinish(taskId: Int)

Called when a JS task finishes (i.e. when HeadlessJsTaskSupportModule.notifyTaskFinished is called, or when it times out), on the UI thread.

Link copied to clipboard
open override fun onHeadlessJsTaskStart(taskId: Int)

Called when a JS task is started, on the UI thread.

Link copied to clipboard
open override fun onHostDestroy()

Called when host activity receives destroy event (e.g. Activity.onDestroy. Only called for the last React activity to be destroyed.

Link copied to clipboard
open override fun onHostPause()

Called when host activity receives pause event (e.g. Activity.onPause. Always called for the most current activity.

Link copied to clipboard
open override fun onHostResume()

Called either when the host activity receives a resume event (e.g. 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.

Link copied to clipboard
Link copied to clipboard
open fun setSendIdleEvents(sendIdleEvents: Boolean)