12/06/2016, 7:40 AM
Hi, could someone fill me in on Generics? I came across a starter project which uses a different approach in terms of MVP. It looks like this
Copy code
abstract class BaseFragment<View: BaseView, out Presenter : BasePresenter<View>>
    protected abstract fun getPassiveView(): View
    protected abstract fun getPresenter(): Presenter
Say I create
Copy code
interface MyView : BaseView{}
MyPresenter : BasePresenter<MyView>{}

class MyFragment : BaseFragment<MyView, MyPresenter>() {

    override fun getPassiveView(): MainBaseView {
        return view as MainBaseView       //Is this correct?

    override fun getPresenter(): MainPresenter {
        //How would I do this, I still need to inject the presenter into the fragment no?
I'm a bit rusty on the generics approach Before I've just done something like
Copy code
class SomeFragment : BaseFragment(), SomeView{

        @Inject lateinit var mPresenter : SomePresenterImpl


      //In the presenter[
              var view... on bind
             doSomething() -> view.updateSomething()