MVP实现分页加载

本文探讨了如何在MVP架构中实现分页加载功能,通过这种方式提升了代码的解耦性和可维护性。
摘要由CSDN通过智能技术生成

使用MVP达到了代码的解耦性


view层

public interface IGoods {
    //搜索商品 回调结果
    void GetGoods(List<ShopBean.DataBean> dlist);

}
 
//model层的接口
/**
 * 1. 类的用途
 * 2. @author chensi
 * 3. @date 2017/10/14 11:08
 */

public interface IGoodsModel {

    void getGoods(Context context, IGoods iGoods, String name, int page);
}

//继承model接口
/**
 * 1. 类的用途
 * 2. @author chensi
 * 3. @date 2017/10/14 11:09
 */

public class GoodsModel implements IGoodsModel{

    Context context;
    IGoods iGoods;
    private List<ShopBean.DataBean> data;

    public GoodsModel(Context context, IGoods iGoods) {
        this.context = context;
        this.iGoods = iGoods;
    }


    @Override
    public void getGoods(Context context, IGoods iGoods, String name,int page) {
        //请求网路数据
        if(name!=null&&!"".equals(name)){
            getHttpGoods(name,page);
        }else{
            Toast.makeText(context,"输入不能为空",Toast.LENGTH_SHORT).show();
        }
    }

    private void getHttpGoods(String name,int page) {
        Map<String,String> map=new HashMap<>();
        map.put("keywords",name);
        map.put("page",page+
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值