I have a problem and can't resolve it. I have an interface Presenter which is generic and take any subtype of interface MvpView
interface Presenter<in V : MvpView> {
fun attachView(view: V)
fun detachView()
}
Then I have another
abstract class BasePresenter which is subtype of Presenter
abstract class BasePresenter<V : MvpView> : Presenter<V> {
protected var mvpView: V? = null
protected get
override fun attachView(view: V) {
this.mvpView = view
}
override fun detachView() {
mvpView = null
}
}
And I have a class
abstract class BaseMvpActivity<P : BasePresenter<T>, T : MvpView> : BaseActivity(), MvpView {
@Inject lateinit protected var presenter: P
protected abstract fun inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
inject()
initPresenter(savedInstanceState)
}
protected fun initPresenter(savedInstanceState: Bundle?) {
presenter.attachView(this)
}
override fun onDestroy() {
presenter.detachView()
super.onDestroy()
}
}
And there I have an error when try to call presenter.attachView(this)
Type mismatch: inferred type is BaseMvpActivity<P, T> but T was expected
I also tried to do like this abstract class BaseMvpActivity<P : BasePresenter<*>> : BaseActivity() but also have an error like Type mismatch: inferred type is BaseMvpActivity<P> but Nothing was expected
How can I solve this problem? Thank you.