package bawei.com.fjb.moni2.presenter;
import bawei.com.fjb.moni2.comment.ShopCartContract;
import bawei.com.fjb.moni2.entity.ShopCartBean;
import bawei.com.fjb.moni2.model.ShopCartModel;;
public class ShopCartPresenter implements ShopCartContract.IShopCartPresenter {
private ShopCartModel shopCartModel;
private ShopCartContract.IShopCarView iShopCarView;
public ShopCartPresenter(ShopCartContract.IShopCarView iShopCarView) {
this.iShopCarView = iShopCarView;
this.shopCartModel=new ShopCartModel();
}
@Override
public void getShops(int uid) {
shopCartModel.requestShops(uid, new ShopCartContract.IShopCartModel.OnRequestListenter() {
@Override
public void onSortSuccess(ShopCartBean shopCartBeanBean) {
iShopCarView.onsuccess(shopCartBeanBean);
}
});
}
}
M
package bawei.com.fjb.moni2.model;
import bawei.com.fjb.moni2.comment.ShopCartContract;
import bawei.com.fjb.moni2.common.ApiInterface;
import bawei.com.fjb.moni2.entity.ShopCartBean;
import bawei.com.fjb.moni2.utils.RetrofitUtils;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
public class ShopCartModel implements ShopCartContract.IShopCartModel {
private ApiInterface api;
@Override
public void requestShops(int uid, final ShopCartContract.IShopCartModel.OnRequestListenter onRequestListenter) {
api = RetrofitUtils.getInstance().Api();
Observable<ShopCartBean> shopCartBean = api.getShopCartBean(uid);
shopCartBean.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ShopCartBean>() {
@Override
public void accept(ShopCartBean shopCartBean) throws Exception {
onRequestListenter.onSortSuccess(shopCartBean);
}
});
}
}
P
package bawei.com.fjb.moni2.presenter;
import bawei.com.fjb.moni2.comment.ShopCartContract;
import bawei.com.fjb.moni2.entity.ShopCartBean;
import bawei.com.fjb.moni2.model.ShopCartModel;;
public class ShopCartPresenter implements ShopCartContract.IShopCartPresenter {
private ShopCartModel shopCartModel;
private ShopCartContract.IShopCarView iShopCarView;
public ShopCartPresenter(ShopCartContract.IShopCarView iShopCarView) {
this.iShopCarView = iShopCarView;
this.shopCartModel=new ShopCartModel();
}
@Override
public void getShops(int uid) {
shopCartModel.requestShops(uid, new ShopCartContract.IShopCartModel.OnRequestListenter() {
@Override
public void onSortSuccess(ShopCartBean shopCartBeanBean) {
iShopCarView.onsuccess(shopCartBeanBean);
}
});
}
}