androidmvpandroid-mvp

MVP - How to make network call in menu inflated by fragment?


I have a menu that is inflated by my fragment. enter image description here

Inside that popupmenu I want to make a network call. How do I make the network call using MVP structure with the FragmentPresenter? Is it correct to pass the presenter to the popupmenu?

Popupmenu menu = new Popupmenu(Context, mPresenter); <-- not sure if correct way to do it


Solution

  • It's absolutely not correct send the presenter to the pop-up, what you can do is create a pop-up which have a callback for the buttons. So you can be notified in the fragment when the user click some button inside the pop-up.

    It's a good practice separate the network calls from the presenter as well. Create another class to perform the network call.