自定义流式布局搜索框+购物车

package com.example.hp.wbyuekaomoni.adapter;

import android.content.Context;
import android.content.DialogInterface;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.hp.wbyuekaomoni.R;
import com.example.hp.wbyuekaomoni.bean.CarBean;
import com.example.hp.wbyuekaomoni.bean.DeleteBean;
import com.example.hp.wbyuekaomoni.parsenter.MyPresenter;
import com.example.hp.wbyuekaomoni.parsenter.MyPresenter2;
import com.example.hp.wbyuekaomoni.view.CustomJiajian;
import com.example.hp.wbyuekaomoni.view.MyViewCallBack;
import com.example.hp.wbyuekaomoni.view.MyViewCallBack2;
import com.facebook.drawee.backends.pipeline.Fresco;

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

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class RecyAdapter extends RecyclerView.Adapter<RecyAdapter.MyViewHolder> implements MyViewCallBack2,MyViewCallBack {
    MyPresenter myPresenter;
    //创建大的集合
    private List<CarBean.DataBean.ListBean> list;
    //存放商家的id和商家的名称的map集合
    private Map<String,String> map = new HashMap<>();

    MyPresenter2 myPresenter2 ;
    Context context;
    public RecyAdapter(Context context) {
        this.context = context;
        myPresenter = new MyPresenter(this);
        myPresenter2 = new MyPresenter2(this);
        //初始化fresco
        Fresco.initialize(context);
    }
    public void add(CarBean cartBean) {
        if(list==null){
            list = new ArrayList<>();
        }

        if(cartBean!=null) {
            for (CarBean.DataBean shop : cartBean.getData()) {
                map.put(shop.getSellerid(), shop.getSellerName());
                //第二层遍历里面的商品
                for (int i = 0; i < shop.getList().size(); i++) {
                    //添加到list集合里
                    list.add(shop.getList().get(i));
                }
            }
            //调用方法 设置显示或隐藏 商铺名
            setFirst(list);

        }    notifyDataSetChanged();
    }

    /**
     * 设置数据源,控制是否显示商家
     * */
    private void setFirst(List<CarBean.DataBean.ListBean> list) {
        if(list.size()>0){
            list.get(0).setIsFirst(1);
            //从第二条开始遍历
            for (int i=1;i<list.size();i++){
                //如果和前一个商品是同一家商店的
                if (list.get(i).getSellerid() == list.get(i-1).getSellerid()){
                    //设置成2不显示商铺
                    list.get(i).setIsFirst(2);
                }else{//设置成1显示商铺
                    list.get(i).setIsFirst(1);
                    //如果当前条目选中,把当前的商铺也选中
                    if (list.get(i).isItem_check()==true){
                        list.get(i).setShop_check(list.get(i).isItem_check());
                    }
                }
            }
        }
    }


    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.recy_cart_item,null);
        MyViewHolder myViewHolder = new MyViewHolder(view);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, final int position) {
        /**
         * 设置商铺的 shop_checkbox和商铺的名字 显示或隐藏
         * */
        if(list.get(position).getIsFirst()==1){
            //显示商家
            holder.shop_checkbox.setVisibility(View.VISIBLE);
            holder.shop_name.setVisibility(View.VISIBLE);
            //设置shop_checkbox的选中状态
            holder.shop_checkbox.setChecked(list.get(position).isShop_check());
            holder.shop_name.setText(map.get(String.valueOf(list.get(position).getSellerid()))+" >");
        }else{//2
            //隐藏商家
            holder.shop_name.setVisibility(View.GONE);
            holder.shop_checkbox.setVisibility(View.GONE);
        }

        //拆分images字段
        String[] split = list.get(position).getImages().split("\\|");
        //设置商品的图片
        holder.item_face.setImageURI(Uri.parse(split[0]));
        // ImageLoader.getInstance().displayImage(split[0],holder.item_face);
        //控制商品的item_checkbox,,根据字段改变
        holder.item_checkbox.setChecked(list.get(position).isItem_check());
        holder.item_name.setText(list.get(position).getTitle());
        holder.item_price.setText(list.get(position).getPrice()+"");
        //调用customjiajian里面的方法设置 加减号中间的数字
        holder.customJiaJian.setEditText(list.get(position).getNum());

        holder.item_bianji.setTag(1);
        //点击item编辑才显示 自定义加减框
        holder.item_bianji.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int tag= (int) holder.item_bianji.getTag();

                if(tag==1) {
                    //加减号显示
                    holder.item_bianji.setText("完成");
                    holder.customJiaJian.setVisibility(View.VISIBLE);
                    //商品的名称隐藏
                    holder.item_name.setVisibility(View.GONE);
                    holder.item_yansechima.setVisibility(View.VISIBLE);
                    holder.item_price.setVisibility(View.GONE);
                    holder.item_delete.setVisibility(View.VISIBLE);
                    holder.item_bianji.setTag(2);
                }else{
                    //相反的 隐藏的显示,显示的隐藏
                    //加减号显示
                    holder.item_bianji.setText("编辑");
                    holder.customJiaJian.setVisibility(View.GONE);
                    //商品的名称隐藏
                    holder.item_name.setVisibility(View.VISIBLE);
                    holder.item_yansechima.setVisibility(View.GONE);
                    holder.item_price.setVisibility(View.VISIBLE);
                    holder.item_delete.setVisibility(View.GONE);
                    holder.item_bianji.setTag(1);
                }
            }
        });
        //设置点击多选框
        //商铺的shop_checkbox点击事件 ,控制商品的item_checkbox
        holder.shop_checkbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //先改变数据源中的shop_check
                list.get(position).setShop_check(holder.shop_checkbox.isChecked());

                for (int i=0;i<list.size();i++){
                    //如果是同一家商铺的 都给成相同状态
                    if(list.get(position).getSellerid()==list.get(i).getSellerid()){
                        //当前条目的选中状态 设置成 当前商铺的选中状态
                        list.get(i).setItem_check(holder.shop_checkbox.isChecked());
                    }
                }
                //刷新适配器
                notifyDataSetChanged();
                //调用求和的方法
                sum(list);
            }
        });

        //商品的item_checkbox点击事件,控制商铺的shop_checkbox
        holder.item_checkbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //先改变数据源中的item_checkbox
                list.get(position).setItem_check(holder.item_checkbox.isChecked());

                //反向控制商铺的shop_checkbox
                for (int i=0;i<list.size();i++){
                    for (int j=0;j<list.size();j++){
                        //如果两个商品是同一家店铺的 并且 这两个商品的item_checkbox选中状态不一样
                        if(list.get(i).getSellerid()==list.get(j).getSellerid() && !list.get(j).isItem_check()){
                            //就把商铺的shop_checkbox改成false
                            list.get(i).setShop_check(false);
                            break;
                        }else{
                            //同一家商铺的商品 选中状态都一样,就把商铺shop_checkbox状态改成true
                            list.get(i).setShop_check(true);
                        }
                    }
                }

                //更新适配器
                notifyDataSetChanged();
                //调用求和的方法
                sum(list);
            }
        });

        //删除条目的点击事件
        holder.item_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                list.remove(position);//移除集合中的当前数据
                //删除完当前的条目 重新判断商铺的显示隐藏
                setFirst(list);

                //调用重新求和
                sum(list);
                notifyDataSetChanged();
            }
        });

        //加减号的监听,
        holder.customJiaJian.setCustomListener(new CustomJiajian.CustomListener() {
            @Override
            public void jiajian(int count) {
                //改变数据源中的数量
                list.get(position).setNum(count);
                notifyDataSetChanged();
                sum(list);
            }

            @Override
            //输入值 求总价
            public void shuRuZhi(int count) {
                list.get(position).setNum(count);
                notifyDataSetChanged();
                sum(list);
            }
        });
    }

    //批量删除的按钮
    public void shanChu() {
        //存储删除的id
        final List<Integer> delete_listid = new ArrayList<>();
        for (int i=0;i<list.size();i++){
            if(list.get(i).isItem_check()){
                //将要删除的pid添加到这个集合里
                delete_listid.add(list.get(i).getPid());
            }
        }
        if (delete_listid.size()==0){
            //如果没有要删除的,就吐司提示
            Toast.makeText(context, "请选中至少一个商品后再删除", Toast.LENGTH_SHORT).show();
            return;
        }
        //弹框
        final AlertDialog.Builder dialog = new AlertDialog.Builder(context);
        dialog.setTitle("操作提示");
        dialog.setMessage("你确定要删除这"+delete_listid.size()+"个商品?");
        dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                //使用接口删除
                String a  = "";
                for(int j=0;j<delete_listid.size();j++) {

                    // a+=delete_listid.get(j)+"";
                    Integer integer = delete_listid.get(j);
                    String pid = String.valueOf(integer);
                    myPresenter2.delete(pid);
                    // list.remove(j);
                }
                //  Toast.makeText(context, a,Toast.LENGTH_SHORT).show();

            }
        }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
        }).create().show();
    }

    //view层调用这个方法, 点击quanxuan按钮的操作
    public void quanXuan(boolean checked) {
        for (int i=0;i<list.size();i++){
            list.get(i).setShop_check(checked);
            list.get(i).setItem_check(checked);

        }
        notifyDataSetChanged();
        sum(list);
    }

    private void sum(List<CarBean.DataBean.ListBean> list) {
        int totalNum = 0;
        float totalMoney = 0.0f;
        boolean allCheck = true;
        for (int i=0;i<list.size();i++){
            if (list.get(i).isItem_check()){
                totalNum += list.get(i).getNum();
                totalMoney += list.get(i).getNum() * list.get(i).getPrice();
            }else{
                //如果有个未选中,就标记为false
                allCheck = false;
            }
        }
        //接口回调出去 把总价 总数量 和allcheck 传给view层
        updateListener.setTotal(totalMoney+"",totalNum+"",allCheck);
    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    @Override
    public void success(DeleteBean deleteBean) {
        //调用第一个presenter的方法 重新查询数据
        myPresenter.select();

    }

    @Override
    public void success(CarBean cartBean) {
        list.clear();
        add(cartBean);
    }

    @Override
    public void failure() {
        System.out.println("网不好");
        Toast.makeText(context, "adapter网有点慢", Toast.LENGTH_SHORT).show();
    }


    public static class MyViewHolder extends RecyclerView.ViewHolder{
        private final CheckBox shop_checkbox;
        private final TextView shop_name;
        private final CheckBox item_checkbox;
        private final TextView item_name;
        private final TextView item_price;
        private final CustomJiajian customJiaJian;
        //private final ImageView item_delete;
        private final TextView item_delete;
        private final ImageView item_face;
        private final TextView item_bianji;
        private final TextView item_yansechima;


        public MyViewHolder(View itemView) {
            super(itemView);
            //拿到控件
            shop_checkbox = itemView.findViewById(R.id.shop_checkbox);
            shop_name =  itemView.findViewById(R.id.shop_name);
            item_checkbox = itemView.findViewById(R.id.item_checkbox);
            item_name = itemView.findViewById(R.id.item_name);
            item_price =  itemView.findViewById(R.id.item_price);
            customJiaJian = itemView.findViewById(R.id.custom_jiajian);
            //item_delete = (ImageView) itemView.findViewById(R.id.item_delete);
            item_delete = itemView.findViewById(R.id.item_delete);

            item_face =  itemView.findViewById(R.id.item_face);
            item_bianji = itemView.findViewById(R.id.item_bianji);
            item_yansechima = itemView.findViewById(R.id.item_yansechima);

        }
    }


    UpdateListener updateListener;
    public void setUpdateListener(UpdateListener updateListener){
        this.updateListener = updateListener;
    }
    //接口
    public interface UpdateListener{
        public void setTotal(String total, String num, boolean allCheck);
    }

}

package com.example.hp.wbyuekaomoni.bean;

import java.util.List;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class CarBean {


    /**
     * msg : 请求成功
     * code : 0
     * data : [{"list":[{"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","num":4,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"}],"sellerName":"商家2","sellerid":"2"},{"list":[{"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","num":1,"pid":62,"price":15999,"pscid":40,"selected":0,"sellerid":6,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家6","sellerid":"6"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":5,"pid":1,"price":118,"pscid":1,"selected":0,"sellerid":17,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家17","sellerid":"17"}]
     */

    private String msg;
    private String code;
    private List<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 List<DataBean> getData() {
        return data;
    }

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

    public static class DataBean {
        /**
         * list : [{"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","num":4,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"}]
         * sellerName : 商家2
         * sellerid : 2
         */

        private String sellerName;
        private String sellerid;
        private List<ListBean> 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<ListBean> getList() {
            return list;
        }

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

        public static class ListBean {
            /**
             * bargainPrice : 11800.0
             * 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
             * num : 4
             * pid : 58
             * price : 6399.0
             * pscid : 40
             * selected : 0
             * sellerid : 2
             * subhead : 升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!
             * title : 联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)
             */

            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;

            private int isFirst = 1;//1为显示商铺
            private boolean item_check;//每个商品的选中状态
            private boolean shop_check;//商店的选中状态
            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;
            }
            public int getIsFirst() {
                return isFirst;
            }

            public void setIsFirst(int isFirst) {
                this.isFirst = isFirst;
            }

            public boolean isItem_check() {
                return item_check;
            }

            public void setItem_check(boolean item_check) {
                this.item_check = item_check;
            }

            public boolean isShop_check() {
                return shop_check;
            }

            public void setShop_check(boolean shop_check) {
                this.shop_check = shop_check;
            }
        }
    }
}



package com.example.hp.wbyuekaomoni.bean;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class DeleteBean {

    /**
     * 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;
    }
}



package com.example.hp.wbyuekaomoni.bean;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class UpdateBean {

}



package com.example.hp.wbyuekaomoni.http;

import com.google.gson.Gson;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public abstract class AbstractObserver<T> implements Observer<String> {
    public abstract void onSuccess(T t);
    public abstract void onFailure();
    @Override
    public void onSubscribe(Disposable d) {

    }

    @Override
    public void onNext(String result) {

        Type type = getClass().getGenericSuperclass();
        Type[] types = ((ParameterizedType) type).getActualTypeArguments();
        Class clazz = (Class) types[0];

        Gson gson = new Gson();
        T t = (T) gson.fromJson(result,clazz);


        onSuccess(t);
    }

    @Override
    public void onError(Throwable e) {
        try {
            onFailure();

        }catch (Exception e1){
            e.printStackTrace();
        }
    }

    @Override
    public void onComplete() {

    }
}


package com.example.hp.wbyuekaomoni.http;

import java.util.Map;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class APIFactory {
    private static APIFactory factory = null;

    public static APIFactory getInstance(){
        if(factory==null){
            synchronized (APIFactory.class){
                if(factory==null){
                    factory = new APIFactory();

                }
            }
        }
        return factory;
    }

    //查询购物车的方法
    public void select(String url, Map<String,String> map, Observer<String> observer){
        //调用retrofit工具类
        RetrofitUtils.getInstance().select(url,map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    //删除购物车的方法
    public void delete(String url, Map<String,String> map, Observer<String> observer){
        //调用retrofit工具类
        RetrofitUtils.getInstance().select(url,map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }
}


package com.example.hp.wbyuekaomoni.http;

import java.util.Map;

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

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public interface IGetService {

    @GET
    Observable<String> select(@Url String url, @QueryMap Map<String, String> map);


    @GET
    Observable<String> delete(@Url String url, @QueryMap Map<String, String> map);


    @GET
    Observable<String> update(@Url String url, @QueryMap Map<String, String> map);
}


package com.example.hp.wbyuekaomoni.http;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class OkHttpUtils {
    private static OkHttpClient client = null;

    public static OkHttpClient getInstance(){
        if(client==null){
            synchronized (OkHttpUtils.class){
                if(client==null){
                    client = new OkHttpClient.Builder()
                            .connectTimeout(2000, TimeUnit.SECONDS)
                            .writeTimeout(2000,TimeUnit.SECONDS)
                            .readTimeout(2000,TimeUnit.SECONDS)
                            .build();
                }
            }
        }
        return client;
    }
}



package com.example.hp.wbyuekaomoni.http;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class RetrofitUtils {
    private static IGetService service = null;

    //http://api.tianapi.com/nba/?key=71e58b5b2f930eaf1f937407acde08fe&num=10
    //单例模式
    public static IGetService getInstance(){
        if(service==null){
            synchronized (RetrofitUtils.class){
                if(service==null){
                    Retrofit retrofit = new Retrofit.Builder()
                            .baseUrl("http://120.27.23.105")
                            .addConverterFactory(ScalarsConverterFactory.create())
                            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                            .client(OkHttpUtils.getInstance())
                            .build();

                    service = retrofit.create(IGetService.class);
                }
            }
        }
        return service;
    }
}



package com.example.hp.wbyuekaomoni.model;


import com.example.hp.wbyuekaomoni.bean.CarBean;
import com.example.hp.wbyuekaomoni.http.APIFactory;
import com.example.hp.wbyuekaomoni.http.AbstractObserver;

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

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class MyModel {
    public void select(final MyModelCallBack myModelCallBack) {

        final Map<String,String> map = new HashMap<>();
        map.put("source","android");
        map.put("uid","1650");

        //调用apifactory里面的方法
        APIFactory.getInstance().select("/product/getCarts", map, new AbstractObserver<CarBean>() {
            @Override
            public void onSuccess(CarBean cartBean) {
                myModelCallBack.success(cartBean);
            }

            @Override
            public void onFailure() {
                myModelCallBack.failure();
            }
        });
    }
}



package com.example.hp.wbyuekaomoni.model;


import com.example.hp.wbyuekaomoni.bean.DeleteBean;
import com.example.hp.wbyuekaomoni.http.APIFactory;
import com.example.hp.wbyuekaomoni.http.AbstractObserver;

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

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class MyModel2 {
    public void delete(String pid,final MyModelCallBack2 myModelCallBack2) {

        final Map<String,String> map = new HashMap<>();
        map.put("source","android");
        map.put("pid",pid);
        map.put("uid","1650");

        //调用apifactory里面的方法
        APIFactory.getInstance().delete("/product/deleteCart", map, new AbstractObserver<DeleteBean>() {
            @Override
            public void onSuccess(DeleteBean deleteBean) {
                myModelCallBack2.success(deleteBean);
            }

            @Override
            public void onFailure() {
                myModelCallBack2.failure();
            }
        });
    }
}


package com.example.hp.wbyuekaomoni.model;


import com.example.hp.wbyuekaomoni.bean.CarBean;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public interface MyModelCallBack {
    public void success(CarBean cartBean);
    public void failure();
}



package com.example.hp.wbyuekaomoni.model;


import com.example.hp.wbyuekaomoni.bean.DeleteBean;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public interface MyModelCallBack2 {
    public void success(DeleteBean deleteBean);
    public void failure();
}



package com.example.hp.wbyuekaomoni.parsenter;

import com.example.hp.wbyuekaomoni.bean.CarBean;
import com.example.hp.wbyuekaomoni.model.MyModel;
import com.example.hp.wbyuekaomoni.model.MyModelCallBack;
import com.example.hp.wbyuekaomoni.view.MyViewCallBack;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class MyPresenter {
    MyModel myModel;
    MyViewCallBack myViewCallBack;
    public MyPresenter(MyViewCallBack myViewCallBack) {
        this.myViewCallBack = myViewCallBack;
        this.myModel = new MyModel();
    }


    public void select() {
        myModel.select(new MyModelCallBack() {
            @Override
            public void success(CarBean cartBean) {
                myViewCallBack.success(cartBean);
            }

            @Override
            public void failure() {
                myViewCallBack.failure();
            }
        });
    }

    public void detach() {
        this.myViewCallBack = null;
    }
}



package com.example.hp.wbyuekaomoni.parsenter;

import com.example.hp.wbyuekaomoni.bean.DeleteBean;
import com.example.hp.wbyuekaomoni.model.MyModel2;
import com.example.hp.wbyuekaomoni.model.MyModelCallBack2;
import com.example.hp.wbyuekaomoni.view.MyViewCallBack2;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class MyPresenter2 {
    MyModel2 myModel2;
    MyViewCallBack2 myViewCallBack2;
    public MyPresenter2(MyViewCallBack2 myViewCallBack2) {
        this.myViewCallBack2 = myViewCallBack2;
        this.myModel2 = new MyModel2();
    }


    public void delete(String pid) {
        myModel2.delete(pid,new MyModelCallBack2() {
            @Override
            public void success(DeleteBean deleteBean) {
                myViewCallBack2.success(deleteBean);
            }

            @Override
            public void failure() {
                myViewCallBack2.failure();
            }
        });
    }

    public void detach() {
        this.myViewCallBack2 = null;
    }
}


package com.example.hp.wbyuekaomoni.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.hp.wbyuekaomoni.R;


/**
 * Created by 因为有个你i on 2018/5/30.
 */

public class CustomJiajian extends LinearLayout {

    private Button reverse;
    private Button add;
    private EditText countEdit;
    private int mCount =1;
    public CustomJiajian(Context context) {
        super(context);
    }

    public CustomJiajian(final Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view=View.inflate(context, R.layout.custom_jiajian,this);
        reverse = view.findViewById(R.id.reverse);
        add = view.findViewById(R.id.add);
        countEdit = view.findViewById(R.id.count);

        reverse.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String content = countEdit.getText().toString().trim();
                int count = Integer.valueOf(content);

                if(count>1){
                    mCount = count-1;
                    countEdit.setText(mCount+"");
                    //回调给adapter里面
                    if(customListener!=null){
                        customListener.jiajian(mCount);
                    }
                }else{
                    Toast.makeText(context, "最小数量为1", Toast.LENGTH_SHORT).show();
                }
            }
        });

        add.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String content = countEdit.getText().toString().trim();
                int count = Integer.valueOf(content)+1;
                mCount = count;

                countEdit.setText(mCount+"");

                //接口回调给adapter
                if(customListener!=null){
                    customListener.jiajian(mCount);
                }
            }
        });
    }


    public CustomJiajian(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    CustomListener customListener;
    public void setCustomListener(CustomListener customListener){
        this.customListener = customListener;
    }

    //加减的接口
    public interface CustomListener{
        public void jiajian(int count);
        public void shuRuZhi(int count);
    }

    public void setEditText(int num) {
        if(countEdit!=null){
            countEdit.setText(num+"");
        }
    }
}


package com.example.hp.wbyuekaomoni.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

public class Liushi extends ViewGroup {

    //存储所有子View
    private List<List<View>> mAllChildViews = new ArrayList<>();
    //每一行的高度
    private List<Integer> mLineHeight = new ArrayList<>();

    public Liushi(Context context) {
        super(context);
    }

    public Liushi(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public Liushi(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        //父控件传进来的宽度和高度以及对应的测量模式
        int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);
        int modeWidth = MeasureSpec.getMode(widthMeasureSpec);
        int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);
        int modeHeight = MeasureSpec.getMode(heightMeasureSpec);
        //如果当前ViewGroup的宽高为wrap_content的情况
        int width = 0;//自己测量的 宽度
        int height = 0;//自己测量的高度
        //记录每一行的宽度和高度
        int lineWidth = 0;
        int lineHeight = 0;

        //获取子view的个数
        int childCount = getChildCount();
        for(int i = 0;i < childCount; i ++){
            View child = getChildAt(i);
            //测量子View的宽和高
            measureChild(child, widthMeasureSpec, heightMeasureSpec);
            //得到LayoutParams
            MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
            //子View占据的宽度
            int childWidth = child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
            //子View占据的高度
            int childHeight = child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
            //换行时候
            if(lineWidth + childWidth > sizeWidth){
                //对比得到最大的宽度
                width = Math.max(width, lineWidth);
                //重置lineWidth
                lineWidth = childWidth;
                //记录行高
                height += lineHeight;
                lineHeight = childHeight;
            }else{//不换行情况
                //叠加行宽
                lineWidth += childWidth;
                //得到最大行高
                lineHeight = Math.max(lineHeight, childHeight);
            }
            //处理最后一个子View的情况
            if(i == childCount -1){
                width = Math.max(width, lineWidth);
                height += lineHeight;
            }
        }
        //wrap_content
        setMeasuredDimension(modeWidth == MeasureSpec.EXACTLY ? sizeWidth : width,
                modeHeight == MeasureSpec.EXACTLY ? sizeHeight : height);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onLayout(boolean b, int l, int i1, int i2, int i3) {
        mAllChildViews.clear();
        mLineHeight.clear();
        //获取当前ViewGroup的宽度
        int width = getWidth();

        int lineWidth = 0;
        int lineHeight = 0;
        //记录当前行的view
        List<View> lineViews = new ArrayList<View>();
        int childCount = getChildCount();
        for(int i = 0;i < childCount; i ++){
            View child = getChildAt(i);
            MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
            int childWidth = child.getMeasuredWidth();
            int childHeight = child.getMeasuredHeight();

            //如果需要换行
            if(childWidth + lineWidth + lp.leftMargin + lp.rightMargin > width){
                //记录LineHeight
                mLineHeight.add(lineHeight);
                //记录当前行的Views
                mAllChildViews.add(lineViews);
                //重置行的宽高
                lineWidth = 0;
                lineHeight = childHeight + lp.topMargin + lp.bottomMargin;
                //重置view的集合
                lineViews = new ArrayList();
            }
            lineWidth += childWidth + lp.leftMargin + lp.rightMargin;
            lineHeight = Math.max(lineHeight, childHeight + lp.topMargin + lp.bottomMargin);
            lineViews.add(child);
        }
        //处理最后一行
        mLineHeight.add(lineHeight);
        mAllChildViews.add(lineViews);

        //设置子View的位置
        int left = 0;
        int top = 0;
        //获取行数
        int lineCount = mAllChildViews.size();
        for(int i = 0; i < lineCount; i ++){
            //当前行的views和高度
            lineViews = mAllChildViews.get(i);
            lineHeight = mLineHeight.get(i);
            for(int j = 0; j < lineViews.size(); j ++){
                View child = lineViews.get(j);
                //判断是否显示
                if(child.getVisibility() == View.GONE){
                    continue;
                }
                MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
                int cLeft = left + lp.leftMargin;
                int cTop = top + lp.topMargin;
                int cRight = cLeft + child.getMeasuredWidth();
                int cBottom = cTop + child.getMeasuredHeight();
                //进行子View进行布局
                child.layout(cLeft, cTop, cRight, cBottom);
                left += child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
            }
            left = 0;
            top += lineHeight;
        }
    }
    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        // TODO Auto-generated method stub

        return new MarginLayoutParams(getContext(), attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN:
                //Toast.makeText(getContext(),mAllChildViews.toString(), Toast.LENGTH_SHORT).show();
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_UP:
                break;
        }
        return true;
    }
}


package com.example.hp.wbyuekaomoni.view;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.hp.wbyuekaomoni.R;
import com.example.hp.wbyuekaomoni.adapter.RecyAdapter;
import com.example.hp.wbyuekaomoni.bean.CarBean;
import com.example.hp.wbyuekaomoni.parsenter.MyPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity implements MyViewCallBack {
    @BindView(R.id.bianji)
    TextView bianji;
    @BindView(R.id.recycler_View)
    RecyclerView recyclerView;
    @BindView(R.id.quanxuan)
    CheckBox quanxuan;
    @BindView(R.id.total_price)
    TextView totalPrice;
    @BindView(R.id.total_num)
    TextView totalNum;
    @BindView(R.id.quzhifu)
    TextView quzhifu;
    @BindView(R.id.shanchu)
    TextView shanchu;
    @BindView(R.id.linear_shanchu)
    LinearLayout linearShanchu;

    private MyPresenter myPresenter;
    private RecyAdapter recyAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        bianji.setTag(1);//编辑设置tag
        quanxuan.setTag(1);//1为不选中
        LinearLayoutManager manager = new LinearLayoutManager(MainActivity.this,LinearLayoutManager.VERTICAL,false);

        myPresenter = new MyPresenter(this);
        recyAdapter = new RecyAdapter(this);
        //进入页面查询购物车的数据
        myPresenter.select();

        recyclerView.setLayoutManager(manager);
        recyclerView.setAdapter(recyAdapter);

        //调用recyAdapter里面的接口,设置 全选按钮 总价 总数量
        recyAdapter.setUpdateListener(new RecyAdapter.UpdateListener() {
            @Override
            public void setTotal(String total, String num, boolean allCheck) {
                //设置ui的改变
                totalNum.setText("共"+num+"件商品");//总数量
                totalPrice.setText("总价 :¥"+total+"元");//总价
                if(allCheck){
                    quanxuan.setTag(2);
                    quanxuan.setBackgroundResource(R.drawable.shopcart_unselected);
                }else{
                    quanxuan.setTag(1);
                    quanxuan.setBackgroundResource(R.drawable.shopcart_unselected);
                }
                quanxuan.setChecked(allCheck);
            }
        });

        //这里只做ui更改, 点击全选按钮,,调到adapter里面操作
        quanxuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //调用adapter里面的方法 ,,把当前quanxuan状态传递过去

                int tag = (int) quanxuan.getTag();
                if(tag==1){
                    quanxuan.setTag(2);
                    quanxuan.setBackgroundResource(R.drawable.shopcart_unselected);
                }else{
                    quanxuan.setTag(1);
                    quanxuan.setBackgroundResource(R.drawable.shopcart_unselected);
                }

                recyAdapter.quanXuan(quanxuan.isChecked());
            }
        });

        //点击批量删除的按钮
        shanchu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                recyAdapter.shanChu();
            }
        });

        //点击编辑按钮,
        bianji.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int tag = (int) bianji.getTag();
                if(tag==1){
                    bianji.setText("完成");
                    bianji.setTag(2);
                    quzhifu.setVisibility(View.GONE);
                    linearShanchu.setVisibility(View.VISIBLE);
                }else{
                    bianji.setText("编辑");
                    bianji.setTag(1);
                    quzhifu.setVisibility(View.VISIBLE);
                    linearShanchu.setVisibility(View.GONE);
                }
            }
        });

    }

    @Override
    public void success(CarBean cartBean) {
        if(cartBean!=null) {
            //System.out.println(cartBean.getData().get(0).getList().get(0).getTitle());
            //将返回的数据 添加到适配器里
            recyAdapter.add(cartBean);
        }
    }

    @Override
    public void failure() {
        System.out.println("网不好");
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(MainActivity.this, "网有点慢", Toast.LENGTH_SHORT).show();
            }
        });

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        //调用p层的解除绑定
        myPresenter.detach();
    }

}


package com.example.hp.wbyuekaomoni.view;


import com.example.hp.wbyuekaomoni.bean.CarBean;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public interface MyViewCallBack {
    public void success(CarBean cartBean);
    public void failure();
}


package com.example.hp.wbyuekaomoni.view;


import com.example.hp.wbyuekaomoni.bean.DeleteBean;

/**
 * Created by 因为有个你i on 2018/5/30.
 */

public interface MyViewCallBack2 {
    public void success(DeleteBean deleteBean);
    public void failure();
}


package com.example.hp.wbyuekaomoni.view;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;


import com.example.hp.wbyuekaomoni.R;

import java.util.ArrayList;
import java.util.List;

public class SerachActivity extends AppCompatActivity {

    private String mNames[] = {
            "男装","电脑","手机","apple",
            "男神范","经典跑车",
            "超级跑车","阿迪短袖","迪凯斯男装",
            "男士皮鞋"
    };

    private EditText editText;
    private String sname;
    private List<String> list = new ArrayList<>();
    private ListView lv;
    private ArrayList<String> list2 = new ArrayList<>();
    private String string;
    private Liushi mFlowLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.flow_layout);
        editText = findViewById(R.id.edname);

        lv = findViewById(R.id.lv);

        initChildViews();

    }
    //流式布局
    private void initChildViews() {

        mFlowLayout = findViewById(R.id.flowlayout);
        ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(

                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.leftMargin = 5;
        lp.rightMargin = 5;
        lp.topMargin = 5;
        lp.bottomMargin = 5;
        for( int i = 0; i < mNames.length; i ++){
            final TextView view1 = new TextView(this);
            view1.setText(mNames[i]);
            view1.setTextColor(Color.RED);
            view1.setBackgroundDrawable(getResources().getDrawable(R.drawable.textview_bg));
            mFlowLayout.addView(view1,lp);


        }


    }


    public void serach(View view) {
        startActivity(new Intent(SerachActivity.this,MainActivity.class));
    }
}




<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <padding android:top="10dp"
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"/>
    <corners android:radius="4dp"/>

    <stroke android:color="#ebebeb"
        android:width="1dp"/>

</shape>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".view.MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="20dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="<"
            android:textSize="23sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="购物车"
            android:textSize="23sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/bianji"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:text="编辑"
            android:textSize="20sp" />
    </RelativeLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="5dp"
        android:background="#D4D4D4" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_View"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <CheckBox
            android:id="@+id/quanxuan"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:background="@drawable/shopcart_unselected"
            android:button="@null" />

        <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="40dp"
            android:text="全选"
            android:textSize="23sp"
            android:textStyle="bold" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="70dp"
            android:orientation="vertical">

            <TextView

                android:id="@+id/total_price"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="总价 : ¥0元"
                android:textColor="#e53e42"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/total_num"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/total_price"
                android:text="共0件商品"
                android:textSize="20sp" />

        </LinearLayout>

        <TextView
            android:id="@+id/quzhifu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:background="#FC7903"
            android:gravity="center"
            android:padding="30dp"
            android:text="去支付"
            android:textColor="#fff"
            android:textSize="22sp" />

        <LinearLayout
            android:id="@+id/linear_shanchu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="30dp"
            android:orientation="horizontal"
            android:visibility="gone">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:background="#FC7903"
                android:gravity="center"
                android:padding="20dp"
                android:paddingLeft="30dp"
                android:paddingRight="30dp"
                android:text="分享宝贝"
                android:textColor="#fff"
                android:textSize="20sp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:background="#FC7903"
                android:gravity="center"
                android:padding="20dp"
                android:paddingLeft="30dp"
                android:paddingRight="30dp"
                android:text="移到收藏夹"
                android:textColor="#fff"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/shanchu"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:background="#DC143C"
                android:gravity="center"
                android:padding="30dp"
                android:paddingLeft="30dp"
                android:paddingRight="30dp"
                android:text="删除"
                android:textColor="#fff"
                android:textSize="20sp" />
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:orientation="horizontal"
    android:gravity="center_vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:background="#F2F1F1"
        android:textSize="20sp"
        android:id="@+id/reverse"
        android:text="一"
        android:layout_width="40dp"
        android:layout_height="40dp" />

    <EditText
        android:gravity="center"
        android:background="#FAFAFA"
        android:textStyle="bold"
        android:textSize="23sp"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:text="1"
        android:id="@+id/count"
        />

    <Button
        android:id="@+id/add"
        android:background="#F2F1F1"
        android:textSize="25sp"
        android:text="+"
        android:layout_width="40dp"
        android:layout_height="40dp" />

</LinearLayout>



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/line"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edname"
            android:layout_width="0dp"
            android:layout_height="45dp"
            android:layout_weight="3"
            android:hint="请输入搜索"
            android:singleLine="true" />

        <Button
            android:layout_width="0dp"
            android:layout_height="45dp"
            android:layout_weight="1"
            android:background="#f89"
            android:onClick="serach"
            android:text="搜索" />
    </LinearLayout>

    <com.example.hp.wbyuekaomoni.view.Liushi
        android:id="@+id/flowlayout"
        android:layout_width="match_parent"
        android:layout_height="100dp">
    </com.example.hp.wbyuekaomoni.view.Liushi>

    <TextView
        android:id="@+id/jilu"
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:layout_below="@id/line"
        android:gravity="center"
        android:text="历史记录" />

    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/jilu">
    </ListView>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:onClick="delete"
            android:text="全部清除" />
    </RelativeLayout>

</LinearLayout>


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:fresco="http://schemas.android.com/apk/res-auto">
    <RelativeLayout
        android:padding="5dp"
        android:background="#FFFFFF"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <CheckBox
            android:layout_centerVertical="true"
            android:id="@+id/shop_checkbox"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/shopcart_unselected"
            android:button="@null"/>

        <TextView
            android:layout_centerVertical="true"
            android:layout_marginLeft="35dp"
            android:text="良品铺子"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="23sp"
            android:textStyle="bold"
            android:id="@+id/shop_name"
            />
        <TextView
            android:id="@+id/item_bianji"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:textSize="20sp"
            android:text="编辑"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </RelativeLayout>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#D4D4D4"/>
    <LinearLayout
        android:background="#F2F2F2"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <CheckBox
            android:id="@+id/item_checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/shopcart_unselected"
            android:button="@null"/>

        <com.facebook.drawee.view.SimpleDraweeView
            fresco:failureImage="@mipmap/ic_launcher"
            fresco:placeholderImage="@mipmap/ic_launcher"
            android:id="@+id/item_face"
            android:src="@mipmap/ic_launcher"
            android:layout_width="140dp"
            android:layout_height="140dp" />

        <LinearLayout
            android:layout_marginLeft="10dp"
            android:orientation="vertical"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/item_name"
                android:textSize="20sp"
                android:text="三只松鼠"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_height="0dp"
                />

            <TextView
                android:textColor="#f00"
                android:id="@+id/item_price"
                android:textSize="23sp"
                android:text="299"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1"
                />


            <com.example.hp.wbyuekaomoni.view.CustomJiajian
                android:visibility="gone"
                android:id="@+id/custom_jiajian"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1"
                />

            <TextView
                android:textSize="20sp"
                android:visibility="gone"
                android:id="@+id/item_yansechima"
                android:text="颜色 : 黑色 ; 尺码: 29"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>

        <!-- <ImageView
             android:visibility="gone"
             android:id="@+id/item_delete"
             android:layout_marginRight="10dp"
             android:src="@drawable/shopcart_delete"
             android:layout_width="30dp"
             android:layout_height="30dp" />-->

        <TextView
            android:visibility="gone"
            android:id="@+id/item_delete"
            android:padding="20dp"
            android:background="#FC7903"
            android:textColor="#fff"
            android:textSize="23sp"
            android:gravity="center"
            android:text="删除"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#D4D4D4"/>

</LinearLayout>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值