Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mView为什么持有LifecycleOwner? #16

Closed
wangxp423 opened this issue Sep 27, 2018 · 1 comment
Closed

mView为什么持有LifecycleOwner? #16

wangxp423 opened this issue Sep 27, 2018 · 1 comment

Comments

@wangxp423
Copy link

override fun attachView(mView: V) { mCompositeDisposable = CompositeDisposable() this.mView = mView if (mView is LifecycleOwner) { (mView as LifecycleOwner).lifecycle.addObserver(this) } if (useEventBus()) { EventBus.getDefault().register(this) } }

刚接触lifecycle我很好奇的是,这个地方的mView为什么会是一个LifecycleOwer呢?还请指点一下。

@iceCola7
Copy link
Owner

@wangxp423 AppCompatActivity 最终会继承 SupportActivitySupportActivity 实现了 LifecycleOwner 接口。

SupportActivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants