android.arch.lifecycle.GenericLifecycleObserver Java Examples
The following examples show how to use
android.arch.lifecycle.GenericLifecycleObserver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoopBanner.java From LoopBanner with Apache License 2.0 | 5 votes |
/** * 綁定當前Activity或Fragment的生命周期 * * @param owner LifecycleOwner */ public void bindLifecycle(LifecycleOwner owner) { Tools.checkNotNull(owner); owner.getLifecycle().addObserver(new GenericLifecycleObserver() { @Override public void onStateChanged(LifecycleOwner source, Lifecycle.Event event) { Tools.logI(TAG, "onStateChanged " + event); if (event.equals(Lifecycle.Event.ON_START)) { startInternal(false); } else if (event.equals(Lifecycle.Event.ON_STOP)) { stopInternal(); } } }); }
Example #2
Source File: LifecycleViewHolder.java From NIM_Android_UIKit with MIT License | 5 votes |
public LifecycleViewHolder(ViewGroup parent, int layoutId, LifecycleOwner outerLifecycleOwner) { super(parent, layoutId); outerLifecycleOwner.getLifecycle().addObserver(new GenericLifecycleObserver() { @Override public void onStateChanged(LifecycleOwner source, Lifecycle.Event event) { if (event == Lifecycle.Event.ON_DESTROY) { if (mLifecycle != null) { mLifecycle.markState(Lifecycle.State.DESTROYED); } } } }); }