Closed akbarsha03 closed 8 years ago
Hi, in general every View should have exactly one Presenter. Usually when you run in such a situation this is an indicator that you should split your big one view with one big presenter into multiple smaller Views having a Presenter each.
Basically your search view has a SearchPresenter, your Activity has its own Presenter.
i.e. you could create a SearchFragment with his own SearchPresenter that will be inside your Activity, but has nothing in common with the Activity and your Activity's Presenter.
If you want to use the SerachView UI widget, then you can do this too. Mosby provides support for averything that extends from android.view.View
like any kind of ViewGroup
(like FrameLayout) or also SearchView
. So basically you could make a class MySearchView extends SerachView implements MvpView, MvpDelegateCallback{}
and then you can create Presenters / ViewState with the same API as you do with any arbitary MvpActivity
or MvpFrament
. Some ViewGroup
implementations are already provided by Mosby like MvpFrameLayout
etc.
How can I implement multiple presenters? Say for example I want to have a separate presenter for search view and a separate presenter for the activity which has the search view.