In MVP, the View has Context to start another view, which is either a different Fragment or Activity , so any transition between your Fragments must be through the View. In your case, you have:
View1 (drawer fragment) <- β Presenter1
View2 (main snippet) <- β Presenter2
You click on the widget on View1 and want to go to some screen on View2 using MVP. You can do it like this:
---------------------- View 1 ---------------------
view1Item.setOnClickListener(new OnClickListener({ presenter1.doWhenItem1IsClicked(); }))
---------------------- Presenter 1 ----------------
public void doWhenItem1IsClicked(){ mView.showRelevantPageOnMainScreen() }
---------------------- View 1 ---------------------
public void showRelevantPageOnMainScreen(){ View2 view2=new View2();
---------------------- View 2 ---------------------
public void onCreate(){ super.onCreate(); presenter2=new Presenter2(this); } . . .
I wrote the MVP library here, you may find it useful.
Ali Nem
source share