Package com.tomtom.ivi.platform.framework.api.common.lifecycle

Contains tools to ease the usage and integration of Android's Lifecycle aware components.

Types

Link copied to clipboard
abstract class LifecycleAwareListeners<T>

LifecycleAwareListeners is a container for listeners with Android Lifecycle awareness.

Link copied to clipboard
class LifecycleAwareListenersOwner<T> : LifecycleAwareListeners<T>

Provides access to a list of listeners with active Android Lifecycle owners from LifecycleAwareListeners.

Link copied to clipboard
class SubLifecycleOwner(parentLifecycleOwner: LifecycleOwner) : LifecycleOwner

An owner of a sub-lifecycle of the given parentLifecycleOwner. The state of the sub-lifecycle is always in a state that is at most the parentLifecycleOwner's state. It can be a lower state either due to being limited with stateLimit or if the sub-lifecycle is destroyed.

Functions

Link copied to clipboard
fun Lifecycle.doOnDestroy(onDestroy: (owner: LifecycleOwner) -> Unit): LifecycleObserver

A convenience function that calls onDestroy when the Lifecycle is destroyed.

fun LifecycleOwner.doOnDestroy(onDestroy: (owner: LifecycleOwner) -> Unit): LifecycleObserver

A convenience function that calls onDestroy when the LifecycleOwner is destroyed.

Link copied to clipboard
fun LifecycleRegistry.handleLifecycleEventInSteps(event: Lifecycle.Event)

Updates the LifecycleRegistry's state according to the event. This can be used instead of the default LifecycleRegistry.handleLifecycleEvent to update each LifecycleObserver for every step in the state change.

Link copied to clipboard
fun LifecycleRegistry.setCurrentStateInSteps(state: Lifecycle.State)

Updates the LifecycleRegistry's state to the given state. This can be used instead of the default LifecycleRegistry.setCurrentState to update each LifecycleObserver for every step in the state change. See handleLifecycleEventInSteps for an explanation why updating the state without steps can be problematic.