本文整理了Java中androidx.lifecycle.Lifecycle.removeObserver()
方法的一些代码示例,展示了Lifecycle.removeObserver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lifecycle.removeObserver()
方法的具体详情如下:
包路径:androidx.lifecycle.Lifecycle
类名称:Lifecycle
方法名:removeObserver
[英]Removes the given observer from the observers list.
If this method is called while a state change is being dispatched,
代码示例来源:origin: trello/RxLifecycle
@OnLifecycleEvent(Lifecycle.Event.ON_ANY)
void onEvent(LifecycleOwner owner, Lifecycle.Event event) {
lifecycleSubject.onNext(event);
if (event == Lifecycle.Event.ON_DESTROY) {
owner.getLifecycle().removeObserver(this);
}
}
}
代码示例来源:origin: chat-sdk/chat-sdk-android
public void setEnabled (boolean enabled) {
if (enabled == this.enabled) {
return;
}
this.enabled = enabled;
if(enabled) {
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}
else {
ProcessLifecycleOwner.get().getLifecycle().removeObserver(this);
}
}
代码示例来源:origin: skydoves/ColorPickerView
/**
* removes this color picker observer from the the {@link LifecycleOwner}.
*
* @param lifecycleOwner {@link LifecycleOwner}.
*/
public void removeLifecycleOwner(LifecycleOwner lifecycleOwner) {
lifecycleOwner.getLifecycle().removeObserver(this);
}
内容来源于网络,如有侵权,请联系作者删除!