Retrofit购物车

//工具类


import java.util.List;

/**购物车
 * Created by dell on 2018/1/8.
 */

public class MyDateGouWU {

    /**
     * msg : 请求成功
     * code : 0
     * data : [{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","num":2,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家1","sellerid":"1"},{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","num":1,"pid":27,"price":488,"pscid":2,"selected":0,"sellerid":4,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":22.9,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","num":1,"pid":35,"price":10,"pscid":2,"selected":0,"sellerid":12,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家12","sellerid":"12"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":78,"price":999,"pscid":40,"selected":0,"sellerid":22,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家22","sellerid":"22"}]
     */

    private String msg;
    private String code;
    private List data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List getData() {
        return data;
    }

    public void setData(List data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * list : [{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","num":2,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}]
         * sellerName : 商家1
         * sellerid : 1
         */

        private String sellerName;
        private String sellerid;
        private List list;

        public String getSellerName() {
            return sellerName;
        }

        public void setSellerName(String sellerName) {
            this.sellerName = sellerName;
        }

        public String getSellerid() {
            return sellerid;
        }

        public void setSellerid(String sellerid) {
            this.sellerid = sellerid;
        }

        public List getList() {
            return list;
        }

        public void setList(List list) {
            this.list = list;
        }

        public static class ListBean {
            /**
             * bargainPrice : 22.9
             * createtime : 2017-10-14T21:48:08
             * detailUrl : https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends
             * images : https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg
             * num : 2
             * pid : 24
             * price : 288.0
             * pscid : 2
             * selected : 0
             * sellerid : 1
             * subhead : 三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》
             * title : 三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋
             */

            private double bargainPrice;
            private String createtime;
            private String detailUrl;
            private String images;
            private int num;
            private int pid;
            private double price;
            private int pscid;
            private int selected;
            private int sellerid;
            private String subhead;
            private String title;

            public double getBargainPrice() {
                return bargainPrice;
            }

            public void setBargainPrice(double bargainPrice) {
                this.bargainPrice = bargainPrice;
            }

            public String getCreatetime() {
                return createtime;
            }

            public void setCreatetime(String createtime) {
                this.createtime = createtime;
            }

            public String getDetailUrl() {
                return detailUrl;
            }

            public void setDetailUrl(String detailUrl) {
                this.detailUrl = detailUrl;
            }

            public String getImages() {
                return images;
            }

            public void setImages(String images) {
                this.images = images;
            }

            public int getNum() {
                return num;
            }

            public void setNum(int num) {
                this.num = num;
            }

            public int getPid() {
                return pid;
            }

            public void setPid(int pid) {
                this.pid = pid;
            }

            public double getPrice() {
                return price;
            }

            public void setPrice(double price) {
                this.price = price;
            }

            public int getPscid() {
                return pscid;
            }

            public void setPscid(int pscid) {
                this.pscid = pscid;
            }

            public int getSelected() {
                return selected;
            }

            public void setSelected(int selected) {
                this.selected = selected;
            }

            public int getSellerid() {
                return sellerid;
            }

            public void setSellerid(int sellerid) {
                this.sellerid = sellerid;
            }

            public String getSubhead() {
                return subhead;
            }

            public void setSubhead(String subhead) {
                this.subhead = subhead;
            }

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }
        }
    }
}


/**商品及店铺
 * Created by dell on 2018/1/8.
 */

public class MyDeteBean {

    /**
     * msg :
     * seller : {"description":"我是商家4","icon":"http://120.27.23.105/images/icon.png","name":"商家4","productNums":999,"score":5,"sellerid":4}
     * code : 0
     * data : {"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","itemtype":1,"pid":27,"price":488,"pscid":2,"salenum":666,"sellerid":4,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}
     */

    private String msg;
    private SellerBean seller;
    private String code;
    private DataBean data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public SellerBean getSeller() {
        return seller;
    }

    public void setSeller(SellerBean seller) {
        this.seller = seller;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class SellerBean {
        /**
         * description : 我是商家4
         * icon : http://120.27.23.105/images/icon.png
         * name : 商家4
         * productNums : 999
         * score : 5.0
         * sellerid : 4
         */

        private String description;
        private String icon;
        private String name;
        private int productNums;
        private double score;
        private int sellerid;

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getIcon() {
            return icon;
        }

        public void setIcon(String icon) {
            this.icon = icon;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getProductNums() {
            return productNums;
        }

        public void setProductNums(int productNums) {
            this.productNums = productNums;
        }

        public double getScore() {
            return score;
        }

        public void setScore(double score) {
            this.score = score;
        }

        public int getSellerid() {
            return sellerid;
        }

        public void setSellerid(int sellerid) {
            this.sellerid = sellerid;
        }
    }

    public static class DataBean {
        /**
         * bargainPrice : 22.9
         * createtime : 2017-10-14T21:38:26
         * detailUrl : https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends
         * images : https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg
         * itemtype : 1
         * pid : 27
         * price : 488.0
         * pscid : 2
         * salenum : 666
         * sellerid : 4
         * subhead : 三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》
         * title : 三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋
         */

        private double bargainPrice;
        private String createtime;
        private String detailUrl;
        private String images;
        private int itemtype;
        private int pid;
        private double price;
        private int pscid;
        private int salenum;
        private int sellerid;
        private String subhead;
        private String title;

        public double getBargainPrice() {
            return bargainPrice;
        }

        public void setBargainPrice(double bargainPrice) {
            this.bargainPrice = bargainPrice;
        }

        public String getCreatetime() {
            return createtime;
        }

        public void setCreatetime(String createtime) {
            this.createtime = createtime;
        }

        public String getDetailUrl() {
            return detailUrl;
        }

        public void setDetailUrl(String detailUrl) {
            this.detailUrl = detailUrl;
        }

        public String getImages() {
            return images;
        }

        public void setImages(String images) {
            this.images = images;
        }

        public int getItemtype() {
            return itemtype;
        }

        public void setItemtype(int itemtype) {
            this.itemtype = itemtype;
        }

        public int getPid() {
            return pid;
        }

        public void setPid(int pid) {
            this.pid = pid;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public int getPscid() {
            return pscid;
        }

        public void setPscid(int pscid) {
            this.pscid = pscid;
        }

        public int getSalenum() {
            return salenum;
        }

        public void setSalenum(int salenum) {
            this.salenum = salenum;
        }

        public int getSellerid() {
            return sellerid;
        }

        public void setSellerid(int sellerid) {
            this.sellerid = sellerid;
        }

        public String getSubhead() {
            return subhead;
        }

        public void setSubhead(String subhead) {
            this.subhead = subhead;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}
/**登陆
 * Created by dell on 2018/1/11.
 */

public class MyDeteDeng {

    /**
     * msg : 登录成功
     * code : 0
     * data : {"age":null,"appkey":"48384ec73a7ba2e7","appsecret":"4C515101CE7490D365824E4703513871","createtime":"2018-01-10T08:51:39","email":null,"fans":null,"follow":null,"gender":null,"icon":null,"latitude":null,"longitude":null,"mobile":"13456565566","money":null,"nickname":null,"password":"CC9A08B0EB9F02AFDA07D24BF9DFB0F3","praiseNum":null,"token":"A5F6240BAE036F370EEC5F7F7520DE1A","uid":3907,"userId":null,"username":"13456565566"}
     */

    private String msg;
    private String code;
    private DataBean data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * age : null
         * appkey : 48384ec73a7ba2e7
         * appsecret : 4C515101CE7490D365824E4703513871
         * createtime : 2018-01-10T08:51:39
         * email : null
         * fans : null
         * follow : null
         * gender : null
         * icon : null
         * latitude : null
         * longitude : null
         * mobile : 13456565566
         * money : null
         * nickname : null
         * password : CC9A08B0EB9F02AFDA07D24BF9DFB0F3
         * praiseNum : null
         * token : A5F6240BAE036F370EEC5F7F7520DE1A
         * uid : 3907
         * userId : null
         * username : 13456565566
         */

        private Object age;
        private String appkey;
        private String appsecret;
        private String createtime;
        private Object email;
        private Object fans;
        private Object follow;
        private Object gender;
        private Object icon;
        private Object latitude;
        private Object longitude;
        private String mobile;
        private Object money;
        private Object nickname;
        private String password;
        private Object praiseNum;
        private String token;
        private int uid;
        private Object userId;
        private String username;

        public Object getAge() {
            return age;
        }

        public void setAge(Object age) {
            this.age = age;
        }

        public String getAppkey() {
            return appkey;
        }

        public void setAppkey(String appkey) {
            this.appkey = appkey;
        }

        public String getAppsecret() {
            return appsecret;
        }

        public void setAppsecret(String appsecret) {
            this.appsecret = appsecret;
        }

        public String getCreatetime() {
            return createtime;
        }

        public void setCreatetime(String createtime) {
            this.createtime = createtime;
        }

        public Object getEmail() {
            return email;
        }

        public void setEmail(Object email) {
            this.email = email;
        }

        public Object getFans() {
            return fans;
        }

        public void setFans(Object fans) {
            this.fans = fans;
        }

        public Object getFollow() {
            return follow;
        }

        public void setFollow(Object follow) {
            this.follow = follow;
        }

        public Object getGender() {
            return gender;
        }

        public void setGender(Object gender) {
            this.gender = gender;
        }

        public Object getIcon() {
            return icon;
        }

        public void setIcon(Object icon) {
            this.icon = icon;
        }

        public Object getLatitude() {
            return latitude;
        }

        public void setLatitude(Object latitude) {
            this.latitude = latitude;
        }

        public Object getLongitude() {
            return longitude;
        }

        public void setLongitude(Object longitude) {
            this.longitude = longitude;
        }

        public String getMobile() {
            return mobile;
        }

        public void setMobile(String mobile) {
            this.mobile = mobile;
        }

        public Object getMoney() {
            return money;
        }

        public void setMoney(Object money) {
            this.money = money;
        }

        public Object getNickname() {
            return nickname;
        }

        public void setNickname(Object nickname) {
            this.nickname = nickname;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public Object getPraiseNum() {
            return praiseNum;
        }

        public void setPraiseNum(Object praiseNum) {
            this.praiseNum = praiseNum;
        }

        public String getToken() {
            return token;
        }

        public void setToken(String token) {
            this.token = token;
        }

        public int getUid() {
            return uid;
        }

        public void setUid(int uid) {
            this.uid = uid;
        }

        public Object getUserId() {
            return userId;
        }

        public void setUserId(Object userId) {
            this.userId = userId;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }
    }
}
import java.util.List;

/**分类列表
 * Created by dell on 2018/1/13.
 */

public class MyDeteLieBiao {

    /**
     * msg : 查询成功
     * code : 0
     * data : [{"bargainPrice":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg","itemtype":0,"pid":57,"price":5199,"pscid":40,"salenum":4343,"sellerid":1,"subhead":"【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统","title":"小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银\r\n"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","itemtype":1,"pid":58,"price":6399,"pscid":40,"salenum":545,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"},{"bargainPrice":5599,"createtime":"2017-10-10T17:30:32","detailUrl":"https://item.m.jd.com/product/4824715.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n12/jfs/t7768/184/1153704394/148460/f42e1432/599a930fN8a85626b.jpg!q70.jpg","itemtype":0,"pid":59,"price":5599,"pscid":40,"salenum":675,"sellerid":3,"subhead":"游戏本选择4G独显,拒绝掉帧】升级版IPS全高清防眩光显示屏,WASD方向键颜色加持,三大出风口立体散热!","title":"戴尔DELL灵越游匣15PR-6648B GTX1050 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 128GSSD+1T 4G独显 IPS)黑"},{"bargainPrice":11800,"createtime":"2017-10-14T21:48:08","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":2,"pid":60,"price":13888,"pscid":40,"salenum":466,"sellerid":4,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":1,"pid":61,"price":14999,"pscid":40,"salenum":5535,"sellerid":5,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":0,"pid":62,"price":15999,"pscid":40,"salenum":43,"sellerid":6,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":1,"pid":63,"price":10000,"pscid":40,"salenum":3232,"sellerid":7,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-03T23:43:53","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":0,"pid":64,"price":11000,"pscid":40,"salenum":0,"sellerid":8,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:48:08","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":2,"pid":65,"price":12000,"pscid":40,"salenum":868,"sellerid":9,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":1,"pid":66,"price":13000,"pscid":40,"salenum":7676,"sellerid":10,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}]
     * page : 1
     */

    private String msg;
    private String code;
    private String page;
    private List data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public List getData() {
        return data;
    }

    public void setData(List data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * bargainPrice : 11800.0
         * createtime : 2017-10-10T17:33:37
         * detailUrl : https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends
         * images : https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg
         * itemtype : 0
         * pid : 57
         * price : 5199.0
         * pscid : 40
         * salenum : 4343
         * sellerid : 1
         * subhead : 【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统
         * title : 小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银

         */

        private double bargainPrice;
        private String createtime;
        private String detailUrl;
        private String images;
        private int itemtype;
        private int pid;
        private double price;
        private int pscid;
        private int salenum;
        private int sellerid;
        private String subhead;
        private String title;

        public double getBargainPrice() {
            return bargainPrice;
        }

        public void setBargainPrice(double bargainPrice) {
            this.bargainPrice = bargainPrice;
        }

        public String getCreatetime() {
            return createtime;
        }

        public void setCreatetime(String createtime) {
            this.createtime = createtime;
        }

        public String getDetailUrl() {
            return detailUrl;
        }

        public void setDetailUrl(String detailUrl) {
            this.detailUrl = detailUrl;
        }

        public String getImages() {
            return images;
        }

        public void setImages(String images) {
            this.images = images;
        }

        public int getItemtype() {
            return itemtype;
        }

        public void setItemtype(int itemtype) {
            this.itemtype = itemtype;
        }

        public int getPid() {
            return pid;
        }

        public void setPid(int pid) {
            this.pid = pid;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public int getPscid() {
            return pscid;
        }

        public void setPscid(int pscid) {
            this.pscid = pscid;
        }

        public int getSalenum() {
            return salenum;
        }

        public void setSalenum(int salenum) {
            this.salenum = salenum;
        }

        public int getSellerid() {
            return sellerid;
        }

        public void setSellerid(int sellerid) {
            this.sellerid = sellerid;
        }

        public String getSubhead() {
            return subhead;
        }

        public void setSubhead(String subhead) {
            this.subhead = subhead;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}
/**查询  添加 修改 
* Created by dell on 2018/1/8.
 */

public class MyUpDateBean {

    /**
     * msg : 加购成功
     * code : 0
     */

    private String msg;
    private String code;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
//模型层

import com.google.gson.Gson;

import java.util.Map;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**模型层
 * Created by dell on 2018/1/8.
 */

public class Model implements ModelPort {
    PresenterPort pr;

    public Model(PresenterPort pr) {
        this.pr = pr;
    }

    @Override
    public void addste(String url, Map map) {
        NetWorkOkHttp.getNetWorkPort().getadd(url, map)
        .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String s) {
                       pr.add(s);

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    @Override
    public void xiangQing(String url, Map map) {
        NetWorkOkHttp.getNetWorkPort().getadd(url, map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String s) {
                        Gson gson=new Gson();
                        MyDeteBean myDeteBean = gson.fromJson(s, MyDeteBean.class);
                        pr.xiangQing(myDeteBean);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    @Override
    public void selectGouwu(String url, Map map) {
        NetWorkOkHttp.getNetWorkPort().getadd(url, map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String s) {
                        Gson gson=new Gson();
                        MyDateGouWU myDateGouWU = gson.fromJson(s, MyDateGouWU.class);
                        pr.selectGou(myDateGouWU);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    @Override
    public void dengLu(String url, Map map) {
        NetWorkOkHttp.getNetWorkPort().getadd(url, map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String s) {
                        Gson gson=new Gson();
                        MyDeteDeng myDateGouWU = gson.fromJson(s, MyDeteDeng.class);
                        pr.dengLu(myDateGouWU);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

}
//接口

import java.util.Map;

/**
 * Created by dell on 2018/1/8.
 */

public interface ModelPort {
    public void addste(String url, Map map);
    public void xiangQing(String url, Map map);
    public void selectGouwu(String url, Map map);
    public void dengLu(String url, Map map);
}
//模型层1
import com.google.gson.Gson;

import java.util.Map;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by dell on 2018/1/8.
 */

public class Model1 implements ModelPort1 {
    PresenterPort1 pr;

    public Model1(PresenterPort1 pr) {
        this.pr = pr;
    }

    @Override
    public void addste(String url, Map map) {
        NetWorkOkHttp.getNetWorkPort().getadd(url, map)
        .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String s) {
                     Gson gson=new Gson();
                        MyDeteLieBiao myDeteLieBiao = gson.fromJson(s, MyDeteLieBiao.class);
                        pr.lieBiao(myDeteLieBiao);

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }


}
//接口

import java.util.Map;

/**
 * Created by dell on 2018/1/8.
 */

public interface ModelPort1 {
    public void addste(String url, Map map);

}
//NetWork网络

import android.os.Environment;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import okhttp3.Cache;
import okhttp3.FormBody;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by dell on 2018/1/8.
 */

public class NetWorkOkHttp {
    public static OkHttpClient okHttpClient;
    public static NetWorkPort netWorkPort;
    static {
        getOkHttpClient();
    }

    public static OkHttpClient getOkHttpClient(){
     if(okHttpClient==null){
         synchronized (NetWorkOkHttp.class){
             File fileDir = new File(Environment.getExternalStorageDirectory(), "cache");
             long fileSize = 10 * 1024 * 1024;
             okHttpClient=new OkHttpClient.Builder()
                     .connectTimeout(20,TimeUnit.SECONDS)
                     .readTimeout(20,TimeUnit.SECONDS)
                     .writeTimeout(20,TimeUnit.SECONDS)
                     .addInterceptor(new CommonParamsInterceptor())
                     .cache(new Cache(fileDir,fileSize))
                     .build();
         }

     }
     return okHttpClient;
    }
public static NetWorkPort getNetWorkPort(){
    if(netWorkPort==null){
        synchronized (NetWorkOkHttp.class){
            netWorkPort=comApiT(NetWorkPort.class);
        }
    }
    return netWorkPort;

}
        public static  <T>T comApiT(Class<T> map){
            T t=new Retrofit.Builder()
                    .baseUrl("https://www.zhaoapi.cn/product/")
                    .client(okHttpClient)
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .addConverterFactory(ScalarsConverterFactory.create())
                    .build()
                    .create(map);
            return t;
        }




    private static class CommonParamsInterceptor implements Interceptor {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            String method = request.method();
            String oldUrl = request.url().toString();
            Map map = new HashMap<>();
            map.put("source","android");

            if ("GET".equals(method)){
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append(oldUrl);
                if (oldUrl.contains("?")){
                    if (oldUrl.indexOf("?") == oldUrl.length()-1){
                    }else {
                        stringBuilder.append("&");
                    }
                }else {
                    stringBuilder.append("?");
                }
                for (Map.Entry entry: map.entrySet()) {
                    stringBuilder.append(entry.getKey())
                            .append("=")
                            .append(entry.getValue())
                            .append("&");
                }
                if (stringBuilder.indexOf("&") != -1){
                    stringBuilder.deleteCharAt(stringBuilder.lastIndexOf("&"));
                }
                String newUrl = stringBuilder.toString();
                request = request.newBuilder()
                        .url(newUrl)
                        .build();
            }else if ("POST".equals(method)){
                RequestBody oldRequestBody = request.body();
                if (oldRequestBody instanceof FormBody){
                    FormBody oldBody = (FormBody) oldRequestBody;
                    FormBody.Builder builder = new FormBody.Builder();
                    for (int i=0;ifor (Map.Entry entry:map.entrySet()) {
                        builder.add(entry.getKey(),entry.getValue());
                    }
                    FormBody newBody = builder.build();
                    request = request.newBuilder()
                            .url(oldUrl)
                            .post(newBody)
                            .build();
                }
            }
            Response response = chain.proceed(request);
            return response;
        }
    }
}
//接口网络port

import java.util.Map;

import io.reactivex.Observable;
import retrofit2.http.FieldMap;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;

/**
 * Created by dell on 2018/1/8.
 */

public interface NetWorkPort {
    @GET
    public Observable getadd(@Url String url, @QueryMap Map map);
    @POST
    public Observable getPostadd(@Url String url, @FieldMap Map map);



}
//Presenter类
import android.util.Log;

import com.example.dell.wanghao20fengzhuang.Model.base.MyDateGouWU;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteBean;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteDeng;
import com.example.dell.wanghao20fengzhuang.Model.model1.Model;
import com.example.dell.wanghao20fengzhuang.Model.model1.ModelPort;
import com.example.dell.wanghao20fengzhuang.view.port.Main1;

import java.util.Map;

/**
 * Created by dell on 2018/1/8.
 */

public class Presenter implements PresenterPort {
    Main1 ma;
    ModelPort mo;

    public Presenter(Main1 ma) {
        this.ma = ma;
        mo=new Model(this);
    }
    public void getadd(String url, Map map){
     mo.addste(url,map);
    }
    public void getSelect(String url, Map map){
        mo.selectGouwu(url,map);
    }
    public void getXiangQing(String url, Map map){
        mo.xiangQing(url,map);
    }
    public void getDeangLu(String url, Map map){
        mo.dengLu(url,map);
    }

    @Override
    public void add(String myUpDateBean) {
    ma.add(myUpDateBean);
    }

    @Override
    public void selectGou(MyDateGouWU myDateGouWU) {
        ma.selectGou(myDateGouWU);
    }

    @Override
    public void xiangQing(MyDeteBean myDeteBean) {
        Log.d("----/*******","----------*****"+myDeteBean.getMsg());

        ma.xiangQing(myDeteBean);
    }

    @Override
    public void dengLu(MyDeteDeng myDeteBean) {
        ma.dengLu(myDeteBean);
    }

    //解除绑定
    public void getdelte( ){
        ma=null;
    }

}
//接口

/**
 * Created by dell on 2018/1/8.
 */

public interface PresenterPort {

    public void add(String st);

    public void selectGou(MyDateGouWU myDateGouWU);

    public void xiangQing(MyDeteBean myDeteBean);
    public void dengLu(MyDeteDeng myDeteBean);
}

//Presenter1

import java.util.Map;

/**
 * Created by dell on 2018/1/8.
 */

public class Presenter1 implements PresenterPort1 {
    Main2 ma;
    ModelPort1 mo;

    public Presenter1(Main2 ma) {
        this.ma = ma;
        mo=new Model1(this);
    }
    public void getSelect(String url, Map map){
     mo.addste(url,map);
    }

    //解除绑定
    public void getdelte( ){
        ma=null;
    }

    @Override
    public void lieBiao(MyDeteLieBiao myDeteLieBiao) {
        ma.lieBiao(myDeteLieBiao);
    }
}
//接口

/**
 * Created by dell on 2018/1/8.
 */

public interface PresenterPort1 {

    public void lieBiao(MyDeteLieBiao myDeteLieBiao);
}
//view

/**
 * Created by dell on 2018/1/8.
 */

public interface Main1 {
    public void add(String myUpDateBean);

    public void selectGou(MyDateGouWU myDateGouWU);

    public void xiangQing(MyDeteBean myDeteBean);
    public void dengLu(MyDeteDeng myDeteBean);
}
/**
 * Created by dell on 2018/1/13.
 */

public interface Main2 {
    public void lieBiao(MyDeteLieBiao myDeteLieBiao);
}
 
  
//布局文件
 
  
android:orientation="vertical"
>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:orientation="horizontal"
    >
    <CheckBox
        android:id="@+id/gxuan"
        android:layout_width="40dp"
        android:layout_height="30dp" />
    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:id="@+id/gdianpu"/>
    <TextView
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:text="编辑"
        android:id="@+id/gbian"/>
LinearLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/grecy"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">android.support.v7.widget.RecyclerView>
//listView适配器
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.example.dell.wanghao20fengzhuang.MainActivity;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDateGouWU;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteBean;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteDeng;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.presenter.presenter.Presenter;
import com.example.dell.wanghao20fengzhuang.view.fragment.gouwu.FragmentGouWu;
import com.example.dell.wanghao20fengzhuang.view.port.Main1;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by dell on 2018/1/8.
 */

public class Adeperts extends BaseAdapter implements Main1 {
    private final Presenter pr;
    List data;
    Context context;
    private int t;


    public Adeperts(Context context, List data) {
        this.context = context;
        this.data=data;
        pr = new Presenter(this);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        final ViewHodels hd;
        final MainActivity ma= (MainActivity) context;
        final FragmentGouWu fr=new FragmentGouWu();
        final MyDateGouWU.DataBean dataBean = data.get(i);
        if(view==null){
            view=View.inflate(context, R.layout.dianpus,null);
            hd=new ViewHodels();
            hd.xuan= (CheckBox) view.findViewById(R.id.gxuan);
            hd.dianpu= (TextView) view.findViewById(R.id.gdianpu);
            hd.recy=(RecyclerView)view.findViewById(R.id.grecy);
            view.setTag(hd);
        }else{
            hd=(ViewHodels) view.getTag();
        }
        hd.dianpu.setText(data.get(i).getSellerName());
        RecyGouWu re=new RecyGouWu(context,data.get(i).getList(),data);
        hd.recy.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false));
        hd.recy.setAdapter(re);
        for(int j=0;j<data.get(i).getList().size();j++){
            MyDateGouWU.DataBean.ListBean listBean = dataBean.getList().get(j);
            if(listBean.getSelected()!=1){
                hd.xuan.setChecked(false);
                break;
            }else{
                hd.xuan.setChecked(true);
            }
        }

        hd.xuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean ck = hd.xuan.isChecked();

                if(ck){
                    for(int j=0;j<data.get(i).getList().size();j++){
                        t=1;
                        MyDateGouWU.DataBean.ListBean list = dataBean.getList().get(j);
                        getup(list,t);
                    }} else{
                    for(int j=0;j<data.get(i).getList().size();j++){
                        t= 0;
                        MyDateGouWU.DataBean.ListBean list = dataBean.getList().get(j);
                        getup(list,t);
                    }
                }
                ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,fr).commit();
            }

        });
        return view;
    }

    @Override
    public void add(String myUpDateBean) {

    }

    @Override
    public void selectGou(MyDateGouWU myDateGouWU) {

    }

    @Override
    public void xiangQing(MyDeteBean myDeteBean) {

    }

    @Override
    public void dengLu(MyDeteDeng myDeteBean) {

    }

    public void getup(MyDateGouWU.DataBean.ListBean list,int t){
        Map map=new HashMap();
        map.put("uid","3907");
        map.put("num",list.getNum()+"");
        map.put("sellerid",list.getSellerid()+"");
        map.put("uid","3907");
        map.put("selected",t+"");
        map.put("pid",list.getPid()+"");
        pr.getadd("https://www.zhaoapi.cn/product/updateCarts",map);
    }
    class ViewHodels{
        CheckBox xuan;
        TextView dianpu;
        RecyclerView recy;


    }
}
//布局文件
<CheckBox
    android:id="@+id/sxuan"
    android:layout_width="40dp"
    android:layout_height="100dp" />
<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/simg"
    android:layout_width="70dp"
    android:layout_height="100dp" />
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:id="@+id/stele"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:orientation="horizontal">
        <TextView
            android:layout_width="60dp"
            android:layout_weight="1"
            android:gravity="fill"
            android:layout_height="wrap_content"

            android:id="@+id/spric"/>

        <LinearLayout
            android:layout_weight="1"
            android:gravity="right"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <Button
                android:id="@+id/sjian"
                android:layout_width="60dp"
                android:layout_height="40dp"
                android:text="-"/>
            <TextView
                android:id="@+id/snum"
                android:layout_width="60dp"
                android:layout_height="40dp"
                android:text="1"/>
            <Button
                android:id="@+id/sjia"
                android:layout_width="60dp"
                android:layout_height="40dp"
                android:text="+"/>






        LinearLayout>
    LinearLayout>


LinearLayout>
//Viewhodel
import com.facebook.drawee.view.SimpleDraweeView;

/**
 * Created by dell on 2018/1/8.
 */

public class ViewHodelGou extends RecyclerView.ViewHolder {

    public final TextView spric;
    public final SimpleDraweeView simg;
    public final Button sjian;
    public final Button sjia;
    public final CheckBox sxuan;
    public final TextView snum;
    public final TextView tele;

    public ViewHodelGou(View itemView) {
        super(itemView);
        sjia = (Button) itemView.findViewById(R.id.sjia);
        sjian = (Button) itemView.findViewById(R.id.sjian);
        simg = (SimpleDraweeView) itemView.findViewById(R.id.simg);
        spric = (TextView) itemView.findViewById(R.id.spric);
        sxuan = (CheckBox) itemView.findViewById(R.id.sxuan);
        snum = (TextView) itemView.findViewById(R.id.snum);
        tele = (TextView) itemView.findViewById(R.id.stele);
    }
}

//Recy适配器
//布局
 
  
//代码
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.dell.wanghao20fengzhuang.MainActivity;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDateGouWU;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteBean;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteDeng;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.presenter.presenter.Presenter;
import com.example.dell.wanghao20fengzhuang.view.fragment.gouwu.FragmentGouWu;
import com.example.dell.wanghao20fengzhuang.view.port.Main1;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.AbstractDraweeController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by dell on 2018/1/8.
 */

public class RecyGouWu extends RecyclerView.Adapter implements Main1 {
    List data;
    List list;
    Context context;
    private final Presenter pr;
    public RecyGouWu(Context context, List list, List data) {
        this.context = context;
        this.data=data;
        this.list=list;
        pr = new Presenter(this);
    }

    @Override
    public ViewHodelGou onCreateViewHolder(ViewGroup parent, int viewType) {
        RecyclerView.ViewHolder hd;
        View view = LayoutInflater.from(context).inflate(R.layout.shangpingou, parent, false);
        hd=new ViewHodelGou(view);
        return (ViewHodelGou) hd;
    }

    @Override
    public void onBindViewHolder(final ViewHodelGou holder, final int position) {
        holder.tele.setText(list.get(position).getTitle());
        holder.spric.setText("¥"+list.get(position).getBargainPrice());
        String[] sp = list.get(position).getImages().split("\\!");
      //  Glide.with(context).load().into(holder.simg);
        AbstractDraweeController build =  Fresco.newDraweeControllerBuilder().setUri(sp[0]).setAutoPlayAnimations(true).build();
        holder.simg.setController(build);

        holder.snum.setText(list.get(position).getNum()+"");
        final MainActivity ma= (MainActivity) context;
        final FragmentGouWu fr=new FragmentGouWu();

        int se = list.get(position).getSelected();
        if(se==1){
            holder.sxuan.setChecked(true);
        }else{
            holder.sxuan.setChecked(false);
        }
        holder.sxuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean checked = holder.sxuan.isChecked();
                if(checked){
                    Map map=new HashMap();
                    map.put("uid","3907");
                    map.put("num",list.get(position).getNum()+"");
                    map.put("sellerid",list.get(position).getSellerid()+"");
                    map.put("uid","3907");
                    map.put("selected","1");
                    map.put("pid",list.get(position).getPid()+"");
                    pr.getadd("https://www.zhaoapi.cn/product/updateCarts",map);
                }else{
                    Map map=new HashMap();
                    map.put("uid","3907");
                    map.put("num",list.get(position).getNum()+"");
                    map.put("sellerid",list.get(position).getSellerid()+"");
                    map.put("uid","3907");
                    map.put("selected","0");
                    map.put("pid",list.get(position).getPid()+"");
                    pr.getadd("https://www.zhaoapi.cn/product/updateCarts",map);
                   }
                ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,fr).commit();
            }
        });


        holder.sjia.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int in = list.get(position).getNum() + 1;
                boolean checked = holder.sxuan.isChecked();

                if(checked){
                    Map map=new HashMap();
                    map.put("uid","3907");
                    map.put("num",in+"");
                    map.put("sellerid",list.get(position).getSellerid()+"");
                    map.put("selected","1");
                    map.put("pid",list.get(position).getPid()+"");
                    pr.getadd("https://www.zhaoapi.cn/product/updateCarts",map);
                }else{
                    Map map=new HashMap();
                    map.put("uid","3907");
                    map.put("num",in+"");
                    map.put("sellerid",list.get(position).getSellerid()+"");
                    map.put("uid","3907");
                    map.put("selected","0");
                    map.put("pid",list.get(position).getPid()+"");
                    pr.getadd("https://www.zhaoapi.cn/product/updateCarts",map);
                }
                ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,fr).commit();
            }
        });
        holder.sjian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int in = 1;
                if(list.get(position).getNum()>1){
                    in=list.get(position).getNum() -1;
                }else{
                    Toast.makeText(context,"对不起商品数量唯一",Toast.LENGTH_LONG).show();
                }

                boolean checked = holder.sxuan.isChecked();

                if(checked){
                    Map map=new HashMap();
                    map.put("uid","3907");
                    map.put("num",in+"");
                    map.put("sellerid",list.get(position).getSellerid()+"");
                    map.put("uid","3907");
                    map.put("selected","0");
                    map.put("pid",list.get(position).getPid()+"");
                    pr.getadd("https://www.zhaoapi.cn/product/updateCarts",map);

                }else{
                    Map map=new HashMap();
                    map.put("uid","3907");
                    map.put("num",in+"");
                    map.put("sellerid",list.get(position).getSellerid()+"");
                    map.put("uid","3907");
                    map.put("selected","0");
                    map.put("pid",list.get(position).getPid()+"");
                    pr.getadd("https://www.zhaoapi.cn/product/updateCarts",map);
                }

                ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,fr).commit();
            }
        });

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    @Override
    public void add(String myUpDateBean) {

    }

    @Override
    public void selectGou(MyDateGouWU myDateGouWU) {

    }

    @Override
    public void xiangQing(MyDeteBean myDeteBean) {

    }

    @Override
    public void dengLu(MyDeteDeng myDeteBean) {

    }
}
//登陆
//布局
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="登陆"/>

    LinearLayout>
    <EditText
        android:id="@+id/tel"
        android:hint="请输入手机号"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <EditText
        android:id="@+id/pas"
        android:hint="请输入密码"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:gravity="center"
        android:orientation="horizontal">
        <Button
            android:id="@+id/wang"
            android:gravity="left"
            android:background="#ffffff"
            android:layout_marginTop="30dp"
            android:layout_marginLeft="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="忘记密码"/>

        <Button
            android:gravity="right"
            android:background="#ffffff"
            android:id="@+id/zhu"
            android:layout_marginTop="30dp"
            android:layout_marginRight="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="新用户注册"/>


    LinearLayout>

    <Button
        android:id="@+id/deng"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登陆"/>

LinearLayout>

//代码
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.dell.wanghao20fengzhuang.MainActivity;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDateGouWU;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteBean;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteDeng;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.presenter.presenter.Presenter;
import com.example.dell.wanghao20fengzhuang.view.fragment.FragmentFenLei;
import com.example.dell.wanghao20fengzhuang.view.port.Main1;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dell on 2018/1/10.
 */

public class FragmentDeng extends Fragment implements Main1 {

    private View view;
    private EditText pas;
    private EditText tel;
    private SharedPreferences uu;
    private Button zhu;
    private Button deng;
    private Presenter pr;
    private MainActivity ma;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragmentdeng,container,false);
        tel =view. findViewById(R.id.tel);
        pas =view. findViewById(R.id.pas);
        uu = getActivity().getSharedPreferences("uu", getActivity().MODE_PRIVATE);
        deng = view.findViewById(R.id.deng);
        pr = new Presenter(this);
        ma = (MainActivity) getActivity();
        zhu = view.findViewById(R.id.zhu);
        ma= (MainActivity) getActivity();


        return view;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
       boolean de = uu.getBoolean("de", false);
        if(de){

        }
        deng.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String s = tel.getText().toString();
                String s1 = pas.getText().toString();
                if(s!=null&&s!=""&&s1!=null&&s1!=""){
                    selct(s,s1);
                      }
            }
        });
            zhu.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentZhuCe()).commit();
                }
            });
    }

    @Override
    public void add(String myUpDateBean) {

    }

    @Override
    public void selectGou(MyDateGouWU myDateGouWU) {

    }

    @Override
    public void xiangQing(MyDeteBean myDeteBean) {

    }

    @Override
    public void dengLu(MyDeteDeng myDeteBean) {

        if("0".equals(myDeteBean.getCode())){
            String s = tel.getText().toString();
            String s1 = pas.getText().toString();
          SharedPreferences.Editor edit = uu.edit();
            edit.putBoolean("de",true);
            edit.putString("tel",myDeteBean.getData().getMobile());
            edit.putString("token",myDeteBean.getData().getToken());
            edit.commit();

            ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentFenLei()).commit();
           Toast.makeText(getActivity(),""+myDeteBean.getMsg(),Toast.LENGTH_LONG).show();

        }
    }

    @Override
    public void onDestroy() {
        if(pr !=null){
            pr.getdelte();
        }
        super.onDestroy();
    }

    public void  selct(String s,String s1){
        Map map=new HashMap();
        map.put("mobile",s);
        map.put("password",s1);
        pr.getDeangLu("http://120.27.23.105/user/login",map);
    }

}
//注册
//布局
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">
        <Button
            android:id="@+id/fan"
            android:layout_width="30dp"
            android:layout_height="50dp"
            android:text="<"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="注册"/>

    LinearLayout>
    <EditText
        android:id="@+id/tel1"
        android:hint="请输入手机号"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <EditText
        android:id="@+id/pas1"
        android:hint="请输入密码"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <EditText
        android:id="@+id/pa1"
        android:hint="请输入确认密码"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center"
        android:orientation="horizontal">


        <Button
            android:id="@+id/zhu1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="立即注册"/>


    LinearLayout>



LinearLayout>
//代码
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.dell.wanghao20fengzhuang.MainActivity;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDateGouWU;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteBean;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteDeng;
import com.example.dell.wanghao20fengzhuang.Model.base.MyUpDateBean;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.presenter.presenter.Presenter;
import com.example.dell.wanghao20fengzhuang.view.port.Main1;
import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dell on 2018/1/11.
 */

public class FragmentZhuCe extends Fragment implements Main1 {

    private View view;
    private EditText pas;
    private EditText tel;
    private Button zhu;
    private Button fan;
    private Presenter pr;
    private MainActivity ma;
    private EditText  pa;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragmentzhuce,container,false);
        zhu = view.findViewById(R.id.zhu1);
        tel = view. findViewById(R.id.tel1);
        pas = view. findViewById(R.id.pas1);
        pa = view. findViewById(R.id.pa1);
        fan = view.findViewById(R.id.fan);
        pr = new Presenter(this);
        ma = (MainActivity) getActivity();
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        //註冊用戶
        zhu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String s = tel.getText().toString();
                String s1 = pas.getText().toString();
                String s2 = pa.getText().toString();
                if(s!=null&&s!=""&&s1!=null&&s1!=""&&s2!=null&&s2!=""){
                    if(s1.equals(s2)){
                        selct(s,s1);
                    }else{
                        Toast.makeText(getActivity(),"密码不正确",Toast.LENGTH_LONG).show();
                    }
                }else{
                    Toast.makeText(getActivity(),"格式不正确",Toast.LENGTH_LONG).show();
                }
            }
        });
        //返回
        fan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentDeng()).commit();
            }
        });



    }

    @Override
    public void add(String myUpDateBean) {
        Gson g=new Gson();
        MyUpDateBean myUp = g.fromJson(myUpDateBean, MyUpDateBean.class);
        if("0".equals(myUp.getCode())){
           Toast.makeText(getActivity(),""+myUp.getMsg(),Toast.LENGTH_LONG).show();
            ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentDeng()).commit();
        }
    }

    @Override
    public void selectGou(MyDateGouWU myDateGouWU) {

    }

    @Override
    public void xiangQing(MyDeteBean myDeteBean) {

    }

    @Override
    public void dengLu(MyDeteDeng myDeteBean) {

    }
    @Override
    public void onDestroy() {
        if(pr !=null){
            pr.getdelte();
        }
        super.onDestroy();
    }
    public void  selct(String s,String s1){
        Map map=new HashMap();
        map.put("mobile",s);
        map.put("password",s1);
        pr.getadd("http://120.27.23.105/user/reg",map);
    }
}
//购物车
//布局
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:orientation="horizontal">
        <TextView
            android:text="购物车"
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="30dp" />
        <ImageView
            android:id="@+id/bianji"
            android:layout_width="80dp"
            android:layout_height="30dp"
            android:src="@mipmap/ic_launcher"/>

    LinearLayout>
    <LinearLayout

        android:id="@+id/linn"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:orientation="horizontal">
            <Button
                android:id="@+id/denglu"
                android:text="登陆"
                android:layout_marginLeft="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView
                android:text="登录后同步电脑到手机购物车中商品"
                android:gravity="center_vertical"
                android:layout_width="match_parent"
                android:layout_height="40dp" />
        LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:gravity="center">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="购物车是空的"/>

        LinearLayout>
        <LinearLayout
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <Button
                android:id="@+id/miaosha"
                android:text="逛逛秒杀"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <Button
                android:id="@+id/guanzhu"
                android:text="看看关注"
                android:textColor="#FF00"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        LinearLayout>
    LinearLayout>
    <LinearLayout
        android:visibility="gone"
        android:id="@+id/lins"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <ListView
            android:id="@+id/glv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">ListView>
    LinearLayout>





LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:orientation="horizontal"
    android:background="#FFFF"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true">
    <CheckBox
        android:id="@+id/quan"
        android:layout_width="70dp"
        android:layout_weight="1"
        android:layout_height="40dp"
        android:text="全选"/>
    <TextView
        android:id="@+id/heji"
        android:layout_weight="2"
        android:layout_width="wrap_content"
        android:gravity="center_vertical"
        android:layout_height="40dp"
        android:text="合计:¥0.00"/>

    <Button
        android:id="@+id/jiesuan"
        android:layout_weight="1"
        android:background="#FF00"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="去结算(0)"/>
    <Button
        android:id="@+id/shanchu"
        android:layout_weight="1"
        android:background="#FF00"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="删除"/>

LinearLayout>

//代码
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.dell.wanghao20fengzhuang.MainActivity;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDateGouWU;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteBean;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteDeng;
import com.example.dell.wanghao20fengzhuang.Model.network.NetWorkOkHttp;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.presenter.presenter.Presenter;
import com.example.dell.wanghao20fengzhuang.view.basedpetr.Adeperts;
import com.example.dell.wanghao20fengzhuang.view.port.Main1;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by dell on 2018/1/8.
 */

public class FragmentGouWu extends Fragment implements Main1 {

    private View view;
    private ImageView img;
    private Button miaosha;
    private Button guanzhu;
    private Button denglu;
    public CheckBox quan;
    private Button jiesuan;
    private TextView heji;
    private ListView lv;
    private LinearLayout lins;
    private LinearLayout linn;
    double precto=0;
    boolean suo=true;
    private SharedPreferences xuan;
    private MainActivity ma;

    private Presenter pr;

    Handler han=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentGouWu()).commit();
        }
    };
    private Button shanchu;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.fragmentgouwu, container, false);
        pr = new Presenter(this);
        img = (ImageView) view.findViewById(R.id.bianji);
        miaosha = (Button) view.findViewById(R.id.miaosha);
        guanzhu = (Button) view.findViewById(R.id.guanzhu);
        denglu = (Button) view.findViewById(R.id.denglu);
        shanchu = view.findViewById(R.id.shanchu);
        lv = (ListView)view.findViewById(R.id.glv);
        heji = (TextView)view.findViewById(R.id.heji);
        jiesuan = (Button) view.findViewById(R.id.jiesuan);
        lins = (LinearLayout)view.findViewById(R.id.lins);
        linn = (LinearLayout)view.findViewById(R.id.linn);
        quan = (CheckBox)view.findViewById(R.id.quan);
        pr = new Presenter(this);
        ma = (MainActivity) getActivity();
        xuan = getActivity().getSharedPreferences("xuan", getActivity().MODE_PRIVATE);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        selct();
        linn.setVisibility(View.GONE);
        lins.setVisibility(View.VISIBLE);
        //删除的点击事件
        shanchu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
    }
    @Override
    public void add(String  myUpDateBean) {
    }
    private  int n;
    @Override
    public void selectGou(final MyDateGouWU myDateGouWU) {
        List data = myDateGouWU.getData();
                    if("0".equals(myDateGouWU.getCode())){
                        //判断商品是否全部选中
                        for(int i=0;iif(!suo){
                                break;
                            }
                            List list = data.get(i).getList();
                            for(int j=0;jif(list.get(j).getSelected()!=1){
                                    quan.setChecked(false);
                                    suo=false;
                                    break;
                                }else{
                                    suo=true;
                                    quan.setChecked(true);
                                }
                            }
                        }
                        //全选状态
                        quan.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                boolean ck = quan.isChecked();
                                SharedPreferences.Editor edit = xuan.edit();
                                if(ck){
                                    edit.putString("name","全选");
                                }else{
                                    edit.putString("name","全不选");
                                }
                                edit.commit();
                              sta(myDateGouWU);
                                  }
                        });
                        //listView适配器
                        Adeperts ad = new Adeperts(getActivity(), data);
                        lv.setAdapter(ad);
                        //计算价格
                        for(int i=0;i list = data.get(i).getList();
                            for(int j=0;jif(list.get(j).getSelected()==1){
                                    MyDateGouWU.DataBean.ListBean ban = list.get(j);
                                    precto = ban.getNum() * ban.getBargainPrice()+precto;
                                }
                            }
                        }
                        //计算价格
                        if(precto!=0){

                            heji.setText("合计:¥"+precto);
                        }else{

                            heji.setText("合计:¥0.00");
                        }
                        //点击结算
                        jiesuan.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                Toast.makeText(getActivity(),"金额"+precto,Toast.LENGTH_LONG).show();
                            }
                        });
                    }else{

                        linn.setVisibility(View.VISIBLE);
                        lins.setVisibility(View.GONE);
                        Toast.makeText(getActivity(),"秦秋失败",Toast.LENGTH_LONG).show();
                    }
    }

    @Override
    public void xiangQing(MyDeteBean myDeteBean) {

    }

    @Override
    public void dengLu(MyDeteDeng myDeteBean) {

    }

    //查询购物车
    public void  selct(){
        Map map=new HashMap();
        map.put("uid","3907");
        map.put("token","A5F6240BAE036F370EEC5F7F7520DE1A");
        pr.getSelect("https://www.zhaoapi.cn/product/getCarts",map);
    }


    public void supdate(MyDateGouWU.DataBean.ListBean list,int t){


    }
private  int cont=0;
    public void sta(MyDateGouWU myDateGouWU){
            linn.setVisibility(View.GONE);
            List data = myDateGouWU.getData();
            String xu =xuan.getString("name",null);
            //判断状态全选和反选
            if(xu!=null){
                cont=0;
                if(xu.equals("全不选")){
                    for(int i=0;i list = data.get(i).getList();
                        for(int j=0;jn=0;
                            cont=cont+1;
                            supdate(ban,n);
                        }
                    }
                    cu(myDateGouWU,cont,n);
                }else if(xu.equals("全选")){
                    cont=0;
                    for(int i=0;i list = data.get(i).getList();
                        for(int j=0;jn=1;
                            cont=cont+1;
                            supdate(ban,n);
                        }
                    }
                    cu(myDateGouWU,cont,n);
                }
                SharedPreferences.Editor edit = xuan.edit();
                edit.putString("name",null);
                edit.commit();
            }
    }


    public  void cu(MyDateGouWU myDateGouWU,int k,int n){
        int p=0;
        Observable[] ob=new Observable[k];
        for(int i=0;i list = myDateGouWU.getData().get(i).getList();
            for(int j=0;j map=new HashMap();
                map.put("uid","3907");
                map.put("num",bean.getNum()+"");
                map.put("sellerid",bean.getSellerid()+"");
                map.put("uid","3907");
                map.put("selected",n+"");
                map.put("pid",bean.getPid()+"");
                Log.d("sss-*****--","-------------"+p);
                ob[p]=NetWorkOkHttp.getNetWorkPort().getadd("https://www.zhaoapi.cn/product/updateCarts",map);
                p++;

            }
        }
        Observable.mergeArray(ob)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer() {
            @Override
            public void onSubscribe(@NonNull Disposable d) {

            }

            @Override
            public void onNext(@NonNull Object o) {
            }

            @Override
            public void onError(@NonNull Throwable e) {

            }

            @Override
            public void onComplete() {
           // Toast.makeText(getActivity(),"--------"+"结束",Toast.LENGTH_LONG).show();
                getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentGouWu()).commit();
            }
        });
    }

    @Override
    public void onDestroy() {
        if(pr!=null){
            pr.getdelte();
        }

        super.onDestroy();
    }

}
//分类详情
//布局
<android.support.v7.widget.RecyclerView
    android:id="@+id/liebiao"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">android.support.v7.widget.RecyclerView>

//代码
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteLieBiao;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.presenter.presenter1.Presenter1;
import com.example.dell.wanghao20fengzhuang.view.fragment.xiangqing.baseRecy.RecyLie;
import com.example.dell.wanghao20fengzhuang.view.port.Main2;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by dell on 2018/1/13.
 */

public class FragmentFenLei extends Fragment implements Main2 {

    private View view;
    private RecyclerView lie;
    private Presenter1 pr;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragmentliebiao, container, false);
        lie = view.findViewById(R.id.liebiao);
        pr = new Presenter1(this);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Map map=new HashMap();
        map.put("keywords","笔记本");
        map.put("page","1");
        pr.getSelect("https://www.zhaoapi.cn/product/searchProducts",map);
    }

    @Override
    public void lieBiao(MyDeteLieBiao myDeteLieBiao) {

                if("0".equals( myDeteLieBiao.getCode())){
                    lie.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false));
                    List data = myDeteLieBiao.getData();
                    RecyLie re=new RecyLie(data,getActivity());
                    lie.setAdapter(re);


                }
    }
}
//详情页
//布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/sid"
            android:layout_width="match_parent"
            android:layout_height="200dp" />
<TextView
    android:id="@+id/qing"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/jiage1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/shangjia1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:orientation="horizontal"
        android:background="#FFFF"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true">
        <Button
            android:id="@+id/addgou"
            android:layout_weight="1"
            android:background="#FF00"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="加入購物車"/>

        <Button
            android:id="@+id/liding"
            android:layout_weight="1"
            android:background="#FF00"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="立即購買"/>


    LinearLayout>
RelativeLayout>
//代码
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.dell.wanghao20fengzhuang.MainActivity;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDateGouWU;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteBean;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteDeng;
import com.example.dell.wanghao20fengzhuang.Model.base.MyUpDateBean;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.presenter.presenter.Presenter;
import com.example.dell.wanghao20fengzhuang.view.fragment.gouwu.FragmentGouWu;
import com.example.dell.wanghao20fengzhuang.view.port.Main1;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.AbstractDraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dell on 2018/1/11.
 */

public class FragmentXiangQing extends Fragment implements Main1 {

    private Presenter pr;
    private View view;
    private MainActivity ma;
    private SharedPreferences shan;
    private TextView qing;
    private TextView shang;
    private TextView jia;
    private SimpleDraweeView sim;
    private Button g;
    private Button li;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragmentxiangqing,container,false);
        pr = new Presenter(this);
        ma = (MainActivity) getActivity();
        jia = view.findViewById(R.id.jiage1);
        sim = view.findViewById(R.id.sid);
        shang = view.findViewById(R.id.shangjia1);
        qing = view.findViewById(R.id.qing);
        g = view.findViewById(R.id.addgou);
        li = view.findViewById(R.id.liding);
        shan = getActivity().getSharedPreferences("shan", ma.MODE_PRIVATE);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        final String pid = shan.getString("pid", null);
      //  Toast.makeText(getActivity(),""+pid,Toast.LENGTH_LONG).show();
        Map map=new HashMap();
        map.put("pid",pid);
        map.put("token","A5F6240BAE036F370EEC5F7F7520DE1A");
        pr.getXiangQing("https://www.zhaoapi.cn/product/getProductDetail",map);
        g.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Map map=new HashMap();
                map.put("uid","3907");
                map.put("pid",pid);
                map.put("token","A5F6240BAE036F370EEC5F7F7520DE1A");
                pr.getadd("https://www.zhaoapi.cn/product/addCart",map);
            }
        });
        li.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentGouWu()).commit();
            }
        });
    }

    @Override
    public void add(String myUpDateBean) {
            Gson gson=new Gson();
        MyUpDateBean myUp = gson.fromJson(myUpDateBean, MyUpDateBean.class);
        if("0".equals(myUp.getCode())){
            Toast.makeText(getActivity(),""+myUp.getMsg(),Toast.LENGTH_LONG).show();
        }

    }

    @Override
    public void selectGou(MyDateGouWU myDateGouWU) {

    }

    @Override
    public void xiangQing(MyDeteBean myDeteBean) {
        Toast.makeText(getActivity(),""+myDeteBean.getMsg(),Toast.LENGTH_LONG).show();
            if("0".equals(myDeteBean.getCode())){
                String[] sp = myDeteBean.getData().getImages().split("\\!");
                AbstractDraweeController build = Fresco.newDraweeControllerBuilder().setUri(sp[0]).setAutoPlayAnimations(true).build();
                sim.setController(build);
                qing.setText(myDeteBean.getData().getTitle());
                jia.setText(myDeteBean.getData().getBargainPrice()+"");
                shang.setText(myDeteBean.getSeller().getDescription());
            }
    }

    @Override
    public void dengLu(MyDeteDeng myDeteBean) {

    }
}
//recy
//布局
  android:orientation="horizontal"
    >
    <LinearLayout
        android:id="@+id/lins"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/sip"
        android:layout_width="100dp"
        android:layout_height="100dp" />
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >
    <TextView
        android:id="@+id/xjia"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/sxiang"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/sqing"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

LinearLayout>
LinearLayout>

//代码
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.dell.wanghao20fengzhuang.MainActivity;
import com.example.dell.wanghao20fengzhuang.Model.base.MyDeteLieBiao;
import com.example.dell.wanghao20fengzhuang.R;
import com.example.dell.wanghao20fengzhuang.view.fragment.xiangqing.FragmentXiangQing;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.AbstractDraweeController;

import java.util.List;

/**
 * Created by dell on 2018/1/13.
 */

public class RecyLie extends RecyclerView.Adapter {
    List data;
    Context context;

    public RecyLie(List data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public ViewHodelLie onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.recy, parent, false);
        ViewHodelLie v=new ViewHodelLie(view);
        return v;
    }
    @Override
    public void onBindViewHolder(ViewHodelLie holder, final int position) {
        String[] sp = data.get(position).getImages().split("\\!");
        holder.spric.setText("¥"+data.get(position).getPrice());
        holder.tele.setText(data.get(position).getTitle());
        holder.snum.setText(data.get(position).getSubhead());
        AbstractDraweeController build =  Fresco.newDraweeControllerBuilder().setUri(sp[0]).setAutoPlayAnimations(true).build();
        holder.simg.setController(build);

        final MainActivity ma= (MainActivity) context;
        holder.lin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SharedPreferences shan = context.getSharedPreferences("shan", ma.MODE_PRIVATE);
                SharedPreferences.Editor edit = shan.edit();
                edit.putString("pid",""+data.get(position).getPid());
                ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,new FragmentXiangQing()).commit();
                edit.commit();
            }
        });
    }
    @Override
    public int getItemCount() {
        return data.size();
    }
}
viewhodel
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.dell.wanghao20fengzhuang.R;
import com.facebook.drawee.view.SimpleDraweeView;

/**
 * Created by dell on 2018/1/8.
 */

public class ViewHodelLie extends RecyclerView.ViewHolder {

    public final TextView spric;
    public final SimpleDraweeView simg;
    public final TextView snum;
    public final TextView tele;
    public final LinearLayout lin;

    public ViewHodelLie(View itemView) {
        super(itemView);
        lin = itemView.findViewById(R.id.lins);
        simg = (SimpleDraweeView) itemView.findViewById(R.id.sip);
        spric = (TextView) itemView.findViewById(R.id.xjia);
        snum = (TextView) itemView.findViewById(R.id.sxiang);
        tele = (TextView) itemView.findViewById(R.id.sqing);
    }
}

 
  

你可能感兴趣的:(IT)