Here my implementation of MVP:
public class OfferDetailsPdfActivity extends AppCompatActivity implements OnPageChangeListener, OfferDetailsPdfMvp.View {
private PdfPresenterImpl presenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int offerId = 0;
if (extras != null) {
offerId = extras.getInt(Offer.ID);
}
presenter = PdfPresenterImpl.getInstance(this, offerId);
}
Now I want to use Moxy.
So here change on Activity
public class OfferDetailsPdfActivity extends MvpAppCompatActivity implements OnPageChangeListener, OfferDetailsPdfMvp.View {
@InjectPresenter
PdfPresenterImpl presenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int offerId = 0;
if (extras != null) {
offerId = extras.getInt(Offer.ID);
}
// how pass parameter to presenter?
// presenter = PdfPresenterImpl.getInstance(this, offerId);
}
But now how I can pass params (context, offerId)
to Presenter?
Moxy has special annotation @ProvidePreseter
for make Presenter by custom constructor. There is more info and example. Also, I strongly recommended to not pass context to presenter. Because then context may leak.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With