AnimationThreadController

Experimental controller singleton allowing to use background thread for all Mapbox animations. Most likely should not be used directly, calling useBackgroundThread should do all the work.

By default all Mapbox animations are running on Android Main thread.

Following Mapbox plugins are updated to make use of background animation thread:

  • plugin-locationcomponent

  • plugin-animation

  • plugin-viewport

Switching between useBackgroundThread and useMainThread could be done at any point in runtime.

Using this class is extremely unsafe and error prone, it should be used in very specific use-cases! Even when it's essential to use it (for example Android Auto use-case on specific devices when locking the device) it would be safer to use Android Main thread as much as possible and switch to background thread only when it's needed.

Functions

Link copied to clipboard
fun postOnAnimatorThread(function: () -> Unit)

Execute function on animator thread.

Link copied to clipboard
fun postOnMainThread(function: () -> Unit)

Execute function on Android Main thread.

Link copied to clipboard

Spawn new animation HandlerThread that will be used for all Mapbox animators. If animation thread is already running - function is no-op.

Link copied to clipboard

If useBackgroundThread was called beforehand - kill background animator thread and use Android Main thread for all Mapbox animators. Otherwise function is no-op.

Properties

Link copied to clipboard

Indicates if background thread is used now to run Mapbox animators.