这里是我对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);
}
现在我想使用 Moxy 。
所以这里改变活动
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);
}
但现在我如何将params (context, offerId)
传递给Presenter?
答案 0 :(得分:5)
答案 1 :(得分:0)
@ProvidePresenter
应该做到这一点。看看这个例子:
https://github.com/Arello-Mobile/Moxy/wiki/Custom-Presenter-constuructor