-
Notifications
You must be signed in to change notification settings - Fork 913
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
kotlin可以避免每个子Activity都调attachView吗 #31
Comments
@wmjwmj828 可以的,你可以试下,下面是伪代码,不过也可以用 dagger2 实现
|
@git-xuhao 这样子类还要传View,好麻烦,哎如果as BaseView还编译不过 |
用dagger都不用方法注入view了,还是先不用dagger的方法实现,更容易理解 |
楼主解决了没,我项目也遇到这个问题,改成kotlin了,结果泛型这边和java有点不同,编译不过,暂时BaseActivity的基类都还是java,不知道如何转kotlin(BaseActivity明明已经实现了BaseView,mPresenter却不能attach(this)) |
同求解决办法 @wmjwmj828 @wangyuan0217 我现在基类也是java |
不知道欸 |
@zhupengxiang @wangyuan0217 上面不是提供的有方案吗?有试过么? |
我之前在把mvp从java转到kotlin时,碰到基类里调用attachView(this)这里编译不过,看了你的源码,你是在每个子view里都调用一遍attachView
CategoryDetailActivity:
init {
mPresenter.attachView(this)
}
如果基类调用,kotlin会出现 Type mismatch,在基类中有解决方法吗,不是用Java解决
abstract class MvpActivity<P : IPresenter<*>> : RxAppCompatActivity(), IView {
The text was updated successfully, but these errors were encountered: