1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package androidx.lifecycle 17 18 /** 19 * Callback interface for listening to [LifecycleOwner] state changes. If a class implements both 20 * this interface and [LifecycleEventObserver], then methods of `DefaultLifecycleObserver` will be 21 * called first, and then followed by the call of [LifecycleEventObserver.onStateChanged] 22 * 23 * If a class implements this interface and in the same time uses [OnLifecycleEvent], then 24 * annotations will be ignored. 25 */ 26 public interface DefaultLifecycleObserver : LifecycleObserver { 27 /** 28 * Notifies that `ON_CREATE` event occurred. 29 * 30 * This method will be called after the [LifecycleOwner]'s `onCreate` method returns. 31 * 32 * @param owner the component, whose state was changed 33 */ onCreatenull34 public fun onCreate(owner: LifecycleOwner) {} 35 36 /** 37 * Notifies that `ON_START` event occurred. 38 * 39 * This method will be called after the [LifecycleOwner]'s `onStart` method returns. 40 * 41 * @param owner the component, whose state was changed 42 */ onStartnull43 public fun onStart(owner: LifecycleOwner) {} 44 45 /** 46 * Notifies that `ON_RESUME` event occurred. 47 * 48 * This method will be called after the [LifecycleOwner]'s `onResume` method returns. 49 * 50 * @param owner the component, whose state was changed 51 */ onResumenull52 public fun onResume(owner: LifecycleOwner) {} 53 54 /** 55 * Notifies that `ON_PAUSE` event occurred. 56 * 57 * This method will be called before the [LifecycleOwner]'s `onPause` method is called. 58 * 59 * @param owner the component, whose state was changed 60 */ onPausenull61 public fun onPause(owner: LifecycleOwner) {} 62 63 /** 64 * Notifies that `ON_STOP` event occurred. 65 * 66 * This method will be called before the [LifecycleOwner]'s `onStop` method is called. 67 * 68 * @param owner the component, whose state was changed 69 */ onStopnull70 public fun onStop(owner: LifecycleOwner) {} 71 72 /** 73 * Notifies that `ON_DESTROY` event occurred. 74 * 75 * This method will be called before the [LifecycleOwner]'s `onDestroy` method is called. 76 * 77 * @param owner the component, whose state was changed 78 */ onDestroynull79 public fun onDestroy(owner: LifecycleOwner) {} 80 } 81