/**
* Lifecycle states. You can consider the states as the nodes in a graph and
* [Event]s as the edges between these nodes.
*/publicenumclassState{/**
* Destroyed state for a LifecycleOwner. After this event, this Lifecycle will not dispatch
* any more events. For instance, for an [android.app.Activity], this state is reached
* **right before** Activity's [onDestroy][android.app.Activity.onDestroy] call.
*/DESTROYED,/**
* Initialized state for a LifecycleOwner. For an [android.app.Activity], this is
* the state when it is constructed but has not received
* [onCreate][android.app.Activity.onCreate] yet.
*/INITIALIZED,/**
* Created state for a LifecycleOwner. For an [android.app.Activity], this state
* is reached in two cases:
*
* * after [onCreate][android.app.Activity.onCreate] call;
* * **right before** [onStop][android.app.Activity.onStop] call.
*
*/CREATED,/**
* Started state for a LifecycleOwner. For an [android.app.Activity], this state
* is reached in two cases:
*
* * after [onStart][android.app.Activity.onStart] call;
* * **right before** [onPause][android.app.Activity.onPause] call.
*
*/STARTED,/**
* Resumed state for a LifecycleOwner. For an [android.app.Activity], this state
* is reached after [onResume][android.app.Activity.onResume] is called.
*/RESUMED;/**
* Compares if this State is greater or equal to the given `state`.
*
* @param state State to compare with
* @return true if this State is greater or equal to the given `state`
*/publicfunisAtLeast(state:State):Boolean{returncompareTo(state)>=0}}
/**
* Marks a class as a LifecycleObserver. Don't use this interface directly. Instead implement either
* [DefaultLifecycleObserver] or [LifecycleEventObserver] to be notified about
* lifecycle events.
*
* @see Lifecycle Lifecycle - for samples and usage patterns.
*/publicinterfaceLifecycleObserver
/**
* Class that can receive any lifecycle change and dispatch it to the receiver.
*
* If a class implements both this interface and
* [androidx.lifecycle.DefaultLifecycleObserver], then
* methods of `DefaultLifecycleObserver` will be called first, and then followed by the call
* of [LifecycleEventObserver.onStateChanged]
*
* If a class implements this interface and in the same time uses [OnLifecycleEvent], then
* annotations will be ignored.
*/publicfuninterfaceLifecycleEventObserver:LifecycleObserver{/**
* Called when a state transition event happens.
*
* @param source The source of the event
* @param event The event
*/publicfunonStateChanged(source:LifecycleOwner,event:Lifecycle.Event)}
publicinterfaceDefaultLifecycleObserver:LifecycleObserver{/**
* Notifies that `ON_CREATE` event occurred.
*
*
* This method will be called after the [LifecycleOwner]'s `onCreate`
* method returns.
*
* @param owner the component, whose state was changed
*/publicfunonCreate(owner:LifecycleOwner){}/**
* Notifies that `ON_START` event occurred.
*
*
* This method will be called after the [LifecycleOwner]'s `onStart` method returns.
*
* @param owner the component, whose state was changed
*/publicfunonStart(owner:LifecycleOwner){}/**
* Notifies that `ON_RESUME` event occurred.
*
*
* This method will be called after the [LifecycleOwner]'s `onResume`
* method returns.
*
* @param owner the component, whose state was changed
*/publicfunonResume(owner:LifecycleOwner){}/**
* Notifies that `ON_PAUSE` event occurred.
*
*
* This method will be called before the [LifecycleOwner]'s `onPause` method
* is called.
*
* @param owner the component, whose state was changed
*/publicfunonPause(owner:LifecycleOwner){}/**
* Notifies that `ON_STOP` event occurred.
*
*
* This method will be called before the [LifecycleOwner]'s `onStop` method
* is called.
*
* @param owner the component, whose state was changed
*/publicfunonStop(owner:LifecycleOwner){}/**
* Notifies that `ON_DESTROY` event occurred.
*
*
* This method will be called before the [LifecycleOwner]'s `onDestroy` method
* is called.
*
* @param owner the component, whose state was changed
*/publicfunonDestroy(owner:LifecycleOwner){}}
internalclassDefaultLifecycleObserverAdapter(privatevaldefaultLifecycleObserver:DefaultLifecycleObserver,privatevallifecycleEventObserver:LifecycleEventObserver?):LifecycleEventObserver{overridefunonStateChanged(source:LifecycleOwner,event:Lifecycle.Event){when(event){Lifecycle.Event.ON_CREATE->defaultLifecycleObserver.onCreate(source)Lifecycle.Event.ON_START->defaultLifecycleObserver.onStart(source)Lifecycle.Event.ON_RESUME->defaultLifecycleObserver.onResume(source)Lifecycle.Event.ON_PAUSE->defaultLifecycleObserver.onPause(source)Lifecycle.Event.ON_STOP->defaultLifecycleObserver.onStop(source)Lifecycle.Event.ON_DESTROY->defaultLifecycleObserver.onDestroy(source)Lifecycle.Event.ON_ANY->throwIllegalArgumentException("ON_ANY must not been send by anybody")}lifecycleEventObserver?.onStateChanged(source,event)}}