登录+注册+商品列表+商品详情+购物车+删除

*

效果图片:

**

登录+注册+商品列表+商品详情+购物车+删除_第1张图片
登录+注册+商品列表+商品详情+购物车+删除_第2张图片
登录+注册+商品列表+商品详情+购物车+删除_第3张图片
登录+注册+商品列表+商品详情+购物车+删除_第4张图片

首先我们先导依赖



 compile 'io.reactivex.rxjava2:rxjava:+'
    compile 'io.reactivex.rxjava2:rxandroid:+'
    compile 'com.squareup.retrofit2:adapter-rxjava2:+'
    compile 'com.squareup.retrofit2:retrofit:+'
    compile 'com.squareup.retrofit2:converter-gson:+'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.facebook.fresco:fresco:0.12.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'



网络权限:



    <uses-permission android:name="android.permission.INTERNET" />


注意的事项:

登录+注册+商品列表+商品详情+购物车+删除_第5张图片

主布局activity_week3:



<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.a1510bdianshang2_master.Week3"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        >

        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:src="@drawable/jd_buy_icon"/>

    RelativeLayout>

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

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

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

        <CheckBox
            android:id="@+id/cb_mima"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="记住密码"
            />

        <TextView
            android:id="@+id/login_zhuce"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新用户注册"
            android:layout_alignBaseline="@+id/cb_mima"
            android:layout_alignBottom="@+id/cb_mima"
            android:layout_alignParentEnd="true" />


    RelativeLayout>


    <Button
        android:id="@+id/login_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:background="#fa843f"
        android:layout_gravity="center_horizontal"
        android:text="登录" />


LinearLayout>



activity_shop


"http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    .support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/rlv_shop"
        >.support.v7.widget.RecyclerView>






activity_shop_xq



<LinearLayout
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">



    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="391dp"
        android:id="@+id/shopxq_rlv"
        >android.support.v7.widget.RecyclerView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >

    <Button
        android:id="@+id/btn_jiaru"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="加入购物车"
        />
    <Button
        android:id="@+id/btn_goumai"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="立即购买"
        />
    LinearLayout>
LinearLayout>


activity_caractivity


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:gravity="center"
            android:text="购物车" />

        <TextView
            android:id="@+id/tv_bianji"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="编辑" />

    RelativeLayout>

    <ExpandableListView
        android:id="@+id/exlist"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">
    ExpandableListView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal"
        android:padding="10dp">

        <CheckBox
            android:id="@+id/check_all"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center_vertical"
            android:text="全选"
            android:textSize="15dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:gravity="center_vertical"
            android:text="总价:"
            android:textSize="15dp" />

        <TextView
            android:id="@+id/tv_zjprice"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:gravity="center_vertical"
            android:text="0"
            android:textSize="15dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:gravity="center_vertical"
            android:text="数量:"
            android:textSize="15dp" />

        <TextView
            android:id="@+id/tv_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="0"
            android:textSize="15dp" />

        <Button
            android:id="@+id/btn_js"
            android:layout_width="80dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:background="#fc0109"
            android:text="结算"
            android:textSize="15dp" />
    LinearLayout>

LinearLayout>



adddelete.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/tv_delete"
        android:layout_width="31dp"
        android:layout_height="31dp"
        android:background="#999999"
        android:gravity="center"
        android:text="-" />

    <EditText
        android:id="@+id/ed_num"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:background="@null"
        android:gravity="center" />

    <TextView
        android:id="@+id/tv_add"
        android:layout_width="31dp"
        android:layout_height="31dp"
        android:background="#999999"
        android:gravity="center"
        android:text="+" />

LinearLayout>

gwc_goods_item.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="10dp">

    <CheckBox
        android:id="@+id/check_gwc_goods"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_centerVertical="true"
        android:gravity="center_vertical" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv_gwc_goods"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="title" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tv_gwc_price"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="价格:"
                android:textColor="#fa0000" />
        LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.example.a1510bdianshang2_master.car.view.AddDeleteView
                android:id="@+id/add_delete"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:layout_centerVertical="true"
                android:layout_marginRight="5dp"
                app:left_item="-"
                app:middle_item="1"
                app:right_item="+" />

            <Button
                android:id="@+id/btn_gwc_delete"
                android:layout_width="110dp"
                android:layout_height="40dp"
                android:layout_alignParentRight="true"
                android:background="#f70496"
                android:gravity="center"
                android:text="删除"
                android:textColor="#ffffff" />

        RelativeLayout>
    LinearLayout>

    <ImageView
        android:id="@+id/img_gwc_goods"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:src="@mipmap/ic_launcher" />
LinearLayout>


gwc_group_item.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#999999"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <CheckBox
        android:id="@+id/check_gwc_group"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_centerVertical="true"
        android:layout_marginLeft="20dp" />

    <TextView
        android:id="@+id/tv_gwc_group"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="title"
        android:textSize="20dp" />


LinearLayout>


item_shop.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent">


    <com.facebook.drawee.view.SimpleDraweeView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:id="@+id/shop_img"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/shop_price"
            />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/shop_title"
            />

    LinearLayout>

LinearLayout>


shopxq_item.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">



    <com.facebook.drawee.view.SimpleDraweeView
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:id="@+id/shpxq_img"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/shopxq_title"
        android:textSize="20dp"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/shopxq_price"
        android:textSize="30dp"
        android:textColor="#ff0000"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/shopxq_name"
        android:textSize="20dp"
        />

LinearLayout>



在avlues里创建一个attrs,xml



<resources>
    <declare-styleable name="AddDeleteView">
        <attr name="left_item" format="string">attr>
        <attr name="right_item" format="string">attr>
        <attr name="middle_item" format="string">attr>
    declare-styleable>
resources>

主页面Week3类


  public class Week3 extends AppCompatActivity implements LoginView{

       @InjectView(R.id.login_name)
       EditText loginName;
       @InjectView(R.id.login_user)
       EditText loginUser;
       @InjectView(R.id.login_login)
       Button loginLogin;
       @InjectView(R.id.login_zhuce)
       TextView loginZhuce;
       private LoginPresenter loginPresenter;
       private CheckBox rem_pw;
       private SharedPreferences sp;
       private SharedPreferences.Editor editor;


       @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_week3);

           ButterKnife.inject(this);
           sp = this.getSharedPreferences("userInfo", MODE_PRIVATE);
           loginPresenter = new LoginPresenter(this);
           rem_pw = (CheckBox) findViewById(R.id.cb_mima);

           //判断记住密码多选框的状态
           if (sp.getBoolean("ISCHECK",false)){
               //设置默认是记录密码状态
               rem_pw.setChecked(true);
               loginName.setText(sp.getString("USER_NAME", ""));
               loginUser.setText(sp.getString("PASSWORD", ""));

           }


           //监听记住密码多选框按钮事件
           rem_pw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
               public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                   if (rem_pw.isChecked()) {

                       System.out.println("记住密码已选中");
                       sp.edit().putBoolean("ISCHECK", true).commit();

                   }else {

                       System.out.println("记住密码没有选中");
                       sp.edit().putBoolean("ISCHECK", false).commit();

                   }

               }
           });
    }

       @Override
       public void LoginSuccess(Login_Bean login_bean) {
           Toast.makeText(this, login_bean.getMsg(), Toast.LENGTH_SHORT).show();

          if ("0".equals(login_bean.getCode())){
              editor.putInt("uid",login_bean.getData().getUid());
              editor.commit();
              Intent intent=new Intent(Week3.this,ShopActivity.class);
              startActivity(intent);
              finish();
          }

       }

       @Override
       public void LoginFaild(Throwable throwable) {
           Toast.makeText(this, throwable.getMessage().toString(), Toast.LENGTH_SHORT).show();
       }

       @Override
       public String getname() {
           return loginName.getText().toString().trim();
       }

       @Override
       public String getpwd() {
           return loginUser.getText().toString().trim();
       }

       @OnClick({R.id.login_login, R.id.login_zhuce})
       public void onViewClicked(View view) {
           switch (view.getId()) {
               case R.id.login_login:
                   String name = loginName.getText().toString().trim();
                   String pwd = loginUser.getText().toString().trim();
                   //记住用户名、密码、
                   editor = sp.edit();
                   editor.putString("USER_NAME", name);
                   editor.putString("PASSWORD",pwd);
                   editor.commit();
                   loginPresenter.login();


                   break;
               case R.id.login_zhuce:
                   break;
           }
       }


}


ShopXQActivity类




public class ShopXQActivity extends AppCompatActivity implements ShopXQView {

    @InjectView(R.id.shopxq_rlv)
    RecyclerView shopxqRlv;
    @InjectView(R.id.btn_jiaru)
    Button btnJiaru;
    @InjectView(R.id.btn_goumai)
    Button btnGoumai;
    private ShopXQPresenter shopXQPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_xq);
        ButterKnife.inject(this);
        shopxqRlv.setLayoutManager(new LinearLayoutManager(this));
        shopXQPresenter = new ShopXQPresenter(this);
        shopXQPresenter.shopxq();
    }

    @Override
    public void ShopXQSuccess(ShopXQBean shopXQBean) {
        ShopXQAdapter shopXQAdapter = new ShopXQAdapter(this, shopXQBean);
        shopxqRlv.setAdapter(shopXQAdapter);
    }

    @Override
    public void ShopXQFaild(Throwable throwable) {

    }

    @OnClick({R.id.btn_jiaru, R.id.btn_goumai})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_jiaru:
                Map map=new HashMap<>();
                map.put("uid","1600");
                map.put("pid","2");
                map.put("source","android");
                TJApi tjApi = RetrofitManager.getinstance().create(TJApi.class);
                Observable tjshop = tjApi.tjshop(map);
                tjshop.subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new Consumer() {
                            @Override
                            public void accept(TJShopBean tjShopBean) throws Exception {
                                Toast.makeText(ShopXQActivity.this,tjShopBean.getMsg(),Toast.LENGTH_SHORT).show();
                            }
                        });
                break;
            case R.id.btn_goumai:
                Intent intent=new Intent(ShopXQActivity.this,Caractivity.class);
                startActivity(intent);
                finish();
                break;
        }
    }


}



ShopActivity类



public class ShopActivity extends AppCompatActivity implements ShopView {

    @InjectView(R.id.rlv_shop)
    RecyclerView rlvShop;
    private ShopPresenter shopPresenter;
    private ShopAdapter shopAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);
        ButterKnife.inject(this);

        shopPresenter = new ShopPresenter(this);
        shopPresenter.shop();
        rlvShop.setLayoutManager(new LinearLayoutManager(this));

    }

    @Override
    public void ShopSuccess(ShopBean shopBean) {
        List data = shopBean.getData();
        shopAdapter = new ShopAdapter(ShopActivity.this, data);

        shopAdapter.setShopAdapter(new ShopAdapter.OnShopClick() {
            @Override
            public void OnShopClick(View view, int position) {

                Intent intent=new Intent(ShopActivity.this,ShopXQActivity.class);
                startActivity(intent);
                finish();
            }
        });

        rlvShop.setAdapter(shopAdapter);
    }

    @Override
    public void ShopFaild(Throwable throwable) {

    }
}


Caractivity类




public class Caractivity extends AppCompatActivity implements Car1View {
    View inflate;
    @InjectView(R.id.tv_bianji)
    TextView tvBianji;
    @InjectView(R.id.exlist)
    ExpandableListView exlist;
    @InjectView(R.id.check_all)
    public CheckBox checkAll;
    @InjectView(R.id.tv_zjprice)
    TextView price;
    TextView tvZjprice;
    @InjectView(R.id.tv_count)
    TextView counts;
    TextView tvCount;
    @InjectView(R.id.btn_js)
    Button btnJs;
    private CarPresenter carPresenter;

    private boolean flagedit = true;
    ArrayList groupBeen = new ArrayList<>();
    ArrayList> goods = new ArrayList<>();
    private CarAdapter carAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_caractivity);
        ButterKnife.inject(this);
        carPresenter = new CarPresenter(this);
        carPresenter.selectCar();
        carAdapter = new CarAdapter(Caractivity.this, groupBeen, goods, this);
        exlist.setAdapter(carAdapter);
        for (int i = 0; i < carAdapter.getGroupCount(); i++) {
            exlist.expandGroup(i);
        }
        carAdapter.notifyDataSetChanged();
    }
    @OnClick({R.id.tv_bianji, R.id.check_all, R.id.btn_js})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_bianji:
                String trim = tvBianji.getText().toString().trim();
                if (trim.equals("编辑")) {
                    tvBianji.setText("完成");
                } else {
                    tvBianji.setText("编辑");
                }
                for (List i1 : goods) {
                    for (int r = 0; r < i1.size(); r++) {
                        i1.get(r).setBtn(flagedit);
                    }
                }
                flagedit = !flagedit;
                carAdapter.notifyDataSetChanged();
                break;
            case R.id.check_all:
                boolean checked = checkAll.isChecked();
                for (int i = 0; i < groupBeen.size(); i++) {
                    groupBeen.get(i).setGroupcheck(checked);
                }
                for (int q = 0; q < goods.size(); q++) {
                    ArrayList goodsBeen = goods.get(q);
                    for (int j = 0; j < goodsBeen.size(); j++) {
                        goodsBeen.get(j).setGoodscheck(checked);
                    }
                }
                changesum(goods);
                carAdapter.notifyDataSetChanged();
                break;
            case R.id.btn_js:
                int index = 0;
                for (int q = 0; q < goods.size(); q++) {
                    ArrayList goodsBeen = goods.get(q);
                    for (int j = 0; j < goodsBeen.size(); j++) {
                        boolean goodscheck = goodsBeen.get(j).isGoodscheck();
                        if (goodscheck) {
                            index++;
                        }
                    }
                }
                if (index == 0) {
                    Toast.makeText(this, "请选择商品,谢谢", Toast.LENGTH_SHORT).show();
                } else {
//                    Intent intent = new Intent(this, Payd.class);
//                    startActivity(intent);

                }
                break;
        }
    }

    @Override
    public void CarSuccess(CarBean carBean) {
        List data = carBean.getData();
        for (int i = 0; i < data.size(); i++) {
            groupBeen.add(new GroupBean(false, data.get(i).getSellerName(), data.get(i).getSellerid()));
            List list = data.get(i).getList();
            ArrayList goodsBeen = new ArrayList<>();
            for (int j = 0; j < list.size(); j++) {
                goodsBeen.add(new GoodsBean(false, list.get(j).getBargainPrice(), list.get(j).getImages(), list.get(j).getTitle(), list.get(j).getSubhead(), list.get(j).getNum(), list.get(j).getPid()));
            }
            goods.add(goodsBeen);
        }
        for (int i = 0; i < carAdapter.getGroupCount(); i++) {
            exlist.expandGroup(i);
        }
        carAdapter.notifyDataSetChanged();
    }

    @Override
    public void CarFaild(Throwable throwable) {

    }

    @Override
    public int getuid() {
        return Caractivity.this.getSharedPreferences("userInfo",Caractivity.this.MODE_PRIVATE).getInt("uid",0);
    }
    //用于格式化十进制数字。
    DecimalFormat df = new DecimalFormat("######0.00");
    //计算总价和数量的方法
    public void changesum(ArrayList> childBeen) {
        int count = 0;
        double sum = 0;
        for (List i1 : childBeen) {
            for (int r = 0; r < i1.size(); r++) {
                boolean childCb1 = i1.get(r).isGoodscheck();
                if (childCb1) {
                    double price = i1.get(r).getBargainPrice();
                    int num = i1.get(r).getNum();
                    sum += price * num;
                    count++;
                }
            }
        }
        price.setText("¥" + df.format(sum));
        counts.setText(count + "");
    }
    public void deleteShop(int pid) {
        Toast.makeText(this, "aadas", Toast.LENGTH_SHORT).show();
    }
}


创建一个utils包,包里面创建两个类
ImageloderUtils类



public class ImageloderUtils extends Application{

    @Override
    public void onCreate() {
        super.onCreate();
        Fresco.initialize(this);
    }
}


RetrofitManager类




public class RetrofitManager {

    private static final String URL="http://120.27.23.105/";

   private static Retrofit mRetrofit;

    public static class Shop_Holder{
        public static final RetrofitManager instance=new RetrofitManager(URL);
    }

    public RetrofitManager(String url) {
        mRetrofit=buildRetrofit();
    }

    public static RetrofitManager getinstance() {
        return Shop_Holder.instance;
    }

    //OkHttpClient
    private OkHttpClient buildOkHttpClient(){
        return new OkHttpClient.Builder()
                .connectTimeout(10000, TimeUnit.MILLISECONDS)
                .build();
    }

    //Retrofit
    private Retrofit buildRetrofit(){
        return new Retrofit.Builder()
                .client(buildOkHttpClient())
                .baseUrl(URL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
    }

    public  T create(Class tClass){
        return mRetrofit.create(tClass);
    }
}


view层

Car1View类



public interface Car1View extends Car2View, IView {
    void CarSuccess(CarBean carBean);
    void CarFaild(Throwable throwable);
    int getuid();
}



Car2View类



public interface Car2View {

}



AddDeleteView类



public class AddDeleteView extends LinearLayout {
    private OnAddDelClickListener listener;
    private EditText etNumber;
    //对外提供一个点击的回调接口
    public interface OnAddDelClickListener {
        void onAddClick(View v);

        void onDelClick(View v);
    }
    public void setOnAddDelClickListener(OnAddDelClickListener listener) {
        if (listener != null) {
            this.listener = listener;
        }
    }


    public AddDeleteView(Context context) {
        this(context, null);
    }

    public AddDeleteView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public AddDeleteView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context, attrs, defStyleAttr);
    }

    private void initView(Context context, AttributeSet attrs, int defStyleAttr) {

        View.inflate(context, R.layout.adddelete, this);
        TextView txtDelete = (TextView) findViewById(R.id.tv_delete);
        TextView txtAdd = (TextView) findViewById(R.id.tv_add);
        etNumber = (EditText) findViewById(R.id.ed_num);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AddDeleteView);

        String leftText = typedArray.getString(R.styleable.AddDeleteView_left_item);
        String rightText = typedArray.getString(R.styleable.AddDeleteView_right_item);
        String middleText = typedArray.getString(R.styleable.AddDeleteView_middle_item);

        txtDelete.setText(leftText);
        txtAdd.setText(rightText);
        etNumber.setText(middleText);

        //回收
        typedArray.recycle();
        txtDelete.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onDelClick(view);
            }
        });

        txtAdd.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onAddClick(view);
            }
        });
    }
    //对外提供一个修改数字的方法
    public void setNumber(int number) {
        if (number > 0) {
            etNumber.setText(number + "");
        }
    }
    //对外提供一个获取当前数字的方法
    public int getNumber() {
        String string = etNumber.getText().toString();
        int i = Integer.parseInt(string);
        return i;
    }
}


IView类


public interface IView {

}


LoginView类


public interface LoginView extends IView{
    void LoginSuccess(Login_Bean login_bean);
    void LoginFaild(Throwable throwable);

    String getname();
    String getpwd();
}


ShopXQView类


public interface ShopXQView extends XQView{

    void ShopXQSuccess(ShopXQBean shopXQBean);
    void ShopXQFaild(Throwable throwable);
}


XQView类


public interface XQView {

}


ShopView类



public interface ShopView extends SPView {
    void ShopSuccess(ShopBean shopBean);
    void ShopFaild(Throwable throwable);
}

SPView类



public interface SPView {

}


在创建一个bean包

Login_Bean



    /**
     * msg : 登录成功
     * code : 0
     * data : {"age":null,"appkey":"8157cea74c894b5c","appsecret":"3E075303BFAD6E7521E278B90A455FBF","createtime":"2018-01-13T08:59:31","email":null,"fans":null,"follow":null,"gender":null,"icon":"https://www.zhaoapi.cn/images/151575551828852d4ae27f2029.jpg","latitude":null,"longitude":null,"mobile":"17301393946","money":null,"nickname":"哈哈哈","password":"8F669074CAF5513351A2DE5CC22AC04C","praiseNum":null,"token":"57C40FDDB9D537A09B46FD83BC088ACC","uid":1600,"userId":null,"username":"17301393946"}
     */

    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 : 8157cea74c894b5c
         * appsecret : 3E075303BFAD6E7521E278B90A455FBF
         * createtime : 2018-01-13T08:59:31
         * email : null
         * fans : null
         * follow : null
         * gender : null
         * icon : https://www.zhaoapi.cn/images/151575551828852d4ae27f2029.jpg
         * latitude : null
         * longitude : null
         * mobile : 17301393946
         * money : null
         * nickname : 哈哈哈
         * password : 8F669074CAF5513351A2DE5CC22AC04C
         * praiseNum : null
         * token : 57C40FDDB9D537A09B46FD83BC088ACC
         * uid : 1600
         * userId : null
         * username : 17301393946
         */

        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 String icon;
        private Object latitude;
        private Object longitude;
        private String mobile;
        private Object money;
        private String 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 String getIcon() {
            return icon;
        }

        public void setIcon(String 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 String getNickname() {
            return nickname;
        }

        public void setNickname(String 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;
        }
    }




CarBean类




public class CarBean {

    /**
     * msg : 请求成功
     * code : 0
     * data : [{"list":[{"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","num":2,"pid":57,"price":5199,"pscid":40,"selected":0,"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":99,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/4345173.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6037/35/2944615848/95178/6cd6cff0/594a3a10Na4ec7f39.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6607/258/1025744923/75738/da120a2d/594a3a12Ne3e6bc56.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6370/292/1057025420/64655/f87644e3/594a3a12N5b900606.jpg!q70.jpg","num":6,"pid":45,"price":2999,"pscid":39,"selected":0,"sellerid":1,"subhead":"高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!","title":"一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机"}],"sellerName":"商家1","sellerid":"1"},{"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":1,"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":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":26,"price":88,"pscid":2,"selected":0,"sellerid":3,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家3","sellerid":"3"},{"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":11,"pid":1,"price":118,"pscid":1,"selected":0,"sellerid":17,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家17","sellerid":"17"},{"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":7,"pid":2,"price":299,"pscid":1,"selected":0,"sellerid":18,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家18","sellerid":"18"}]
     */

    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":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","num":2,"pid":57,"price":5199,"pscid":40,"selected":0,"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":99,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/4345173.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6037/35/2944615848/95178/6cd6cff0/594a3a10Na4ec7f39.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6607/258/1025744923/75738/da120a2d/594a3a12Ne3e6bc56.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6370/292/1057025420/64655/f87644e3/594a3a12N5b900606.jpg!q70.jpg","num":6,"pid":45,"price":2999,"pscid":39,"selected":0,"sellerid":1,"subhead":"高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!","title":"一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机"}]
         * 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 : 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
             * num : 2
             * pid : 57
             * price : 5199.0
             * pscid : 40
             * selected : 0
             * 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 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;
            }
        }
    }
}


GoodsBean类



public class GoodsBean {
    private boolean goodscheck;
    private double bargainPrice;
    private String images;
    private String title;
    private String subhead;
    private int num;
    private boolean btn;
    private int pid;

    public GoodsBean(boolean goodscheck, double bargainPrice, String images, String title, String subhead, int num, boolean btn) {
        this.goodscheck = goodscheck;
        this.bargainPrice = bargainPrice;
        this.images = images;
        this.title = title;
        this.subhead = subhead;
        this.num = num;
        this.btn = btn;
    }

    public GoodsBean(boolean goodscheck, double bargainPrice, String images, String title, String subhead, int num, int pid) {
        this.goodscheck = goodscheck;
        this.bargainPrice = bargainPrice;
        this.images = images;
        this.title = title;
        this.subhead = subhead;
        this.num = num;
        this.pid = pid;
    }

    public int getPid() {
        return pid;
    }

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

    public boolean isBtn() {
        return btn;
    }

    public void setBtn(boolean btn) {
        this.btn = btn;
    }

    public int getNum() {
        return num;
    }

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

    public boolean isGoodscheck() {
        return goodscheck;
    }

    public void setGoodscheck(boolean goodscheck) {
        this.goodscheck = goodscheck;
    }

    public double getBargainPrice() {
        return bargainPrice;
    }

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

    public String getImages() {
        return images;
    }

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

    public String getTitle() {
        return title;
    }

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

    public String getSubhead() {
        return subhead;
    }

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

    @Override
    public String toString() {
        return "GoodsBean{" +
                "goodscheck=" + goodscheck +
                ", bargainPrice=" + bargainPrice +
                ", images='" + images + '\'' +
                ", title='" + title + '\'' +
                ", subhead='" + subhead + '\'' +
                ", num=" + num +
                ", btn=" + btn +
                '}';
    }
}


GroupBean类



public class GroupBean {
    private boolean groupcheck;
    private String sellerName;
    private String sellerid;

    public GroupBean(boolean groupcheck, String sellerName, String sellerid) {
        this.groupcheck = groupcheck;
        this.sellerName = sellerName;
        this.sellerid = sellerid;
    }

    public boolean isGroupcheck() {
        return groupcheck;
    }

    public void setGroupcheck(boolean groupcheck) {
        this.groupcheck = groupcheck;
    }

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

    @Override
    public String toString() {
        return "GroupBean{" +
                "groupcheck=" + groupcheck +
                ", sellerName='" + sellerName + '\'' +
                ", sellerid=" + sellerid +
                '}';
    }
}


LoginModel类




public class Login_Bean {

    /**
     * msg : 登录成功
     * code : 0
     * data : {"age":null,"appkey":"8157cea74c894b5c","appsecret":"3E075303BFAD6E7521E278B90A455FBF","createtime":"2018-01-13T08:59:31","email":null,"fans":null,"follow":null,"gender":null,"icon":"https://www.zhaoapi.cn/images/151575551828852d4ae27f2029.jpg","latitude":null,"longitude":null,"mobile":"17301393946","money":null,"nickname":"哈哈哈","password":"8F669074CAF5513351A2DE5CC22AC04C","praiseNum":null,"token":"57C40FDDB9D537A09B46FD83BC088ACC","uid":1600,"userId":null,"username":"17301393946"}
     */

    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 : 8157cea74c894b5c
         * appsecret : 3E075303BFAD6E7521E278B90A455FBF
         * createtime : 2018-01-13T08:59:31
         * email : null
         * fans : null
         * follow : null
         * gender : null
         * icon : https://www.zhaoapi.cn/images/151575551828852d4ae27f2029.jpg
         * latitude : null
         * longitude : null
         * mobile : 17301393946
         * money : null
         * nickname : 哈哈哈
         * password : 8F669074CAF5513351A2DE5CC22AC04C
         * praiseNum : null
         * token : 57C40FDDB9D537A09B46FD83BC088ACC
         * uid : 1600
         * userId : null
         * username : 17301393946
         */

        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 String icon;
        private Object latitude;
        private Object longitude;
        private String mobile;
        private Object money;
        private String 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 String getIcon() {
            return icon;
        }

        public void setIcon(String 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 String getNickname() {
            return nickname;
        }

        public void setNickname(String 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;
        }
    }
}


ShopBean类



public class ShopBean {

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

TJSopBean类



public class TJShopBean {

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


JRShopBean类



public class JRShopBean {

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


ShopXQBean类




public class ShopXQBean {

    /**
     * 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":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"}
     */

    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 : 11800.0
         * 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.0
         * pscid : 40
         * salenum : 466
         * sellerid : 4
         * subhead : 购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)
         * title : 全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G
         */

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


model层

CarModel类




public class CarModel implements IModel{
    public Observable selectCar(Map map){
        CarApi carApi = RetrofitManager.getinstance().create(CarApi.class);

        return carApi.seleteCar(map);
    }
}



IModl类


public interface IModel {
}


IModel类


public interface IModel {
}


LoginModel类


public class LoginModel implements IModel{

    public Observable login(Map map){
        LoginApi loginApi = RetrofitManager.getinstance().create(LoginApi.class);
        return loginApi.login(map);
    }
}



ShopModel类


public class ShopModel implements SPModel{

    public Observable shop(){
        ShopApi shopApi = RetrofitManager.getinstance().create(ShopApi.class);
        return shopApi.shop("40");
    }
}


SPModel类


public interface SPModel {
}


ShopXQMOdel类


public class ShopXQModel {

    public Observable shopxq(){
        ShopxqApi shopxqApi = RetrofitManager.getinstance().create(ShopxqApi.class);
        return shopxqApi.shopxq();
    }
}


presenter层

CarPresenter类




public class CarPresenter extends IPresenter{

    private CarModel carModel;

    public CarPresenter(Car1View view) {
        super(view);
    }

    @Override
    protected void inti() {
        carModel=new CarModel();
    }
    //查询购物车
    public  void selectCar(){
        Map map=new HashMap<>();
        int getuid = view.getuid();
        map.put("uid",getuid+"");
        map.put("source","android");
        Observable selectcar=carModel.selectCar(map);
        selectcar.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                               @Override
                               public void accept(CarBean carBean) throws Exception {
                                   view.CarSuccess(carBean);
                               }
                           }
                        , new Consumer() {
                            @Override
                            public void accept(Throwable throwable) throws Exception {
                                view.CarFaild(throwable);
                            }
                        }
                );
    }
}


IPresenter类




public abstract  class IPresenter<T extends IView> {
    protected  T view;

    public IPresenter(T view) {
        this.view = view;
        inti();
    }

    protected abstract void inti();
}


IPresenter类



public abstract class IPresenter  <T extends IView> {
    protected T view;

    public IPresenter(T view) {
        this.view = view;
        inti();
    }

    protected abstract void inti();
}

LoginPresenter类



public class LoginPresenter extends IPresenter{

    private LoginModel loginModel;

    public LoginPresenter(LoginView view) {
        super(view);
    }

    @Override
    protected void inti() {
        loginModel=new LoginModel();
    }
    //登录
    public void login( ){
        Map map=new HashMap<>();
        String name = view.getname();
        String getpwd = view.getpwd();
        map.put("mobile",name);
        map.put("password",getpwd);
        Observable login = loginModel.login(map);
        login.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                               @Override
                               public void accept(Login_Bean login_bean) throws Exception {
                                   view.LoginSuccess(login_bean);
                               }
                           }
                        , new Consumer() {
                            @Override
                            public void accept(Throwable throwable) throws Exception {
                                view.LoginFaild(throwable);
                            }
                        }
                );
    }
}

ShopPresenter类



public class ShopPresenter extends SPPresenter{
    private ShopModel shopModel;
    public ShopPresenter(ShopView view) {
        super(view);
    }

    @Override
    protected void inti() {
        shopModel=new ShopModel();
    }


    //商品列表

    public void shop(){
        Observable shop = shopModel.shop();

        shop.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                               @Override
                               public void accept(ShopBean shopBean) throws Exception {
                                   view.ShopSuccess(shopBean);
                               }
                           }
                        , new Consumer() {
                            @Override
                            public void accept(Throwable throwable) throws Exception {
                                view.ShopFaild(throwable);
                            }
                        }
                );
    }
}

SPPresenter类



public abstract class SPPresenter <T extends SPView>{
    protected T view;

    public SPPresenter(T view) {
        this.view = view;
        inti();
    }

    protected abstract void inti();
}


ShopXQPresenter类



public class ShopXQPresenter extends SPXQPrensenter{

    private ShopXQModel shopXQModel;

    public ShopXQPresenter(ShopXQView view) {
        super(view);
    }

    @Override
    protected void init() {
        shopXQModel=new ShopXQModel();
    }
    //商品详情
    public void  shopxq(){
        Observable shopxq = shopXQModel.shopxq();
        shopxq.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                               @Override
                               public void accept(ShopXQBean shopXQBean) throws Exception {
                                   view.ShopXQSuccess(shopXQBean);
                               }
                           }
                        , new Consumer() {
                            @Override
                            public void accept(Throwable throwable) throws Exception {
                                view.ShopXQFaild(throwable);
                            }
                        }
                );
    }
}


SPXQPrensenter类



public abstract class SPXQPrensenter <T extends XQView>{

    protected T view;

    public SPXQPrensenter(T view) {
        this.view = view;
        init();
    }

    protected abstract void init();
}


canstant层

CarApi类



public interface CarApi {

    @GET("product/getCarts")
    Observable seleteCar(@QueryMap Map map);
}



LoginApi类



public interface LoginApi {

    @GET("user/login")
    Observable login(@QueryMap Map map);
}


ShopApi类



public interface ShopApi {

    @GET("product/getProducts")
    Observable shop(@Query("pscid") String pscid);
}


ShopxqApi类


public interface ShopxqApi {

        @GET ("product/getProductDetail?pid=1&source=android")
        Observable shopxq();
}

TJApi类


public interface TJApi {

    @GET("product/addCart")
    Observable tjshop(@QueryMap Map map);
}


adapter层

CarAdapter类




public class CarAdapter extends BaseExpandableListAdapter{
    Context context;
    List grouplist;
    ArrayList> goodslist;
    Caractivity carActivity;

    public CarAdapter(Context context, List grouplist, ArrayList> goodslist, Caractivity carActivity) {
        this.context = context;
        this.grouplist = grouplist;
        this.goodslist = goodslist;
        this.carActivity = carActivity;
    }

    @Override
    public int getGroupCount() {
        return grouplist.size();
    }

    @Override
    public int getChildrenCount(int i) {
        return goodslist.get(i).size();
    }

    @Override
    public Object getGroup(int i) {
        return grouplist.get(i);
    }

    @Override
    public Object getChild(int i, int i1) {
        return goodslist.get(i).get(i1);
    }

    @Override
    public long getGroupId(int i) {
        return i;
    }

    @Override
    public long getChildId(int i, int i1) {
        return i1;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    //父布局
    @Override
    public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
        View group_view = View.inflate(context, R.layout.gwc_group_item, null);
        final CheckBox check_group = group_view.findViewById(R.id.check_gwc_group);
        TextView group = group_view.findViewById(R.id.tv_gwc_group);
        check_group.setChecked(grouplist.get(i).isGroupcheck());
        group.setText(grouplist.get(i).getSellerName());
        check_group.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                GroupBean groupBean = grouplist.get(i);
                groupBean.setGroupcheck(check_group.isChecked());
                for (int j = 0; j get(j).isGroupcheck();
                    if (!groupcheck){
                        carActivity.checkAll.setChecked(false);
                        break;
                    }else {
                        carActivity.checkAll.setChecked(true);
                    }
                }
                ArrayList goodsBeen = goodslist.get(i);
                for (int i = 0; i get(i).setGoodscheck(check_group.isChecked());
                }
                //计算价格
                carActivity.changesum(goodslist);
                notifyDataSetChanged();
            }
        });
        return group_view;
    }

    //子布局

    @Override
    public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        View view = View.inflate(context, R.layout.gwc_goods_item, null);
        TextView tv_goods = (TextView) view.findViewById(R.id.tv_gwc_goods);
        TextView price = (TextView) view.findViewById(R.id.tv_gwc_price);
        final CheckBox check_goods = (CheckBox) view.findViewById(R.id.check_gwc_goods);
        ImageView img_goods = (ImageView) view.findViewById(R.id.img_gwc_goods);
        Button btn_delete = (Button) view.findViewById(R.id.btn_gwc_delete);
        final AddDeleteView adv = (AddDeleteView) view.findViewById(R.id.add_delete);
        tv_goods.setText(goodslist.get(groupPosition).get(childPosition).getTitle());
        price.setText(goodslist.get(groupPosition).get(childPosition).getBargainPrice() + "");
        check_goods.setChecked(goodslist.get(groupPosition).get(childPosition).isGoodscheck());
        String images = goodslist.get(groupPosition).get(childPosition).getImages();
        String[] split = images.split("\\|");
        Glide.with(img_goods.getContext()).load(split[0]).into(img_goods);
        adv.setNumber(goodslist.get(groupPosition).get(childPosition).getNum());
        adv.setNumber(goodslist.get(groupPosition).get(childPosition).getNum());
        if (goodslist.get(groupPosition).get(childPosition).isBtn()) {
            btn_delete.setVisibility(View.VISIBLE);
        } else {
            btn_delete.setVisibility(View.INVISIBLE);
        }
        adv.setOnAddDelClickListener(new AddDeleteView.OnAddDelClickListener() {
            @Override
            public void onAddClick(View v) {
                int number = adv.getNumber();
                number++;
                adv.setNumber(number);
                goodslist.get(groupPosition).get(childPosition).setNum(number);
                carActivity.changesum(goodslist);
            }

            @Override
            public void onDelClick(View v) {
                int number = adv.getNumber();
                if (number > 1) {
                    number--;
                }
                adv.setNumber(number);
                goodslist.get(groupPosition).get(childPosition).setNum(number);
                carActivity.changesum(goodslist);
            }
        });
        btn_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                carActivity.deleteShop(goodslist.get(groupPosition).get(childPosition).getPid());
                int size = goodslist.get(groupPosition).size();
                if (goodslist.get(groupPosition).get(childPosition).isGoodscheck()) {
                    if (size == 1) {
                        goodslist.remove(groupPosition);
                        grouplist.remove(groupPosition);
                    } else {
                        goodslist.get(groupPosition).remove(childPosition);
                    }
                    carActivity.changesum(goodslist);
                    notifyDataSetChanged();
                } else {
                    Toast.makeText(context, "请选择商品。。。", Toast.LENGTH_SHORT).show();
                }
            }
        });
        check_goods.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //定义一个默认flag
                boolean flag = false;
                //获得当前二级列表复选框的状态
                boolean cchecked = check_goods.isChecked();
                //把当前状态存储到二级列表List集合里面
                goodslist.get(groupPosition).get(childPosition).setGoodscheck(cchecked);

                //循环遍历二级列表List集合
                for (List i1 : goodslist) {
                    // 按照所有二级列表的item的个数进行循环遍历
                    for (int r = 0; r < i1.size(); r++) {
                        //获取当前二级列表的状态
                        boolean childCb1 = i1.get(r).isGoodscheck();
                        //取反设置 如果为true改为false 如果为false改为true
                        if (!childCb1) {
                            //如果当前二级列表中有一条复选框是false  全选为false
                            carActivity.checkAll.setChecked(false);
                            //如果当前二级列表中有一条复选框是false  一级列表为false
                            grouplist.get(groupPosition).setGroupcheck(false);
                            //flag为true跳出循环
                            flag = true;
                            break;
                        } else {
                            //如果所有的二级列表都为true  全选为true
                            carActivity.checkAll.setChecked(true);
                            //如果所有的二级列表都为true  一级列表为true
                            grouplist.get(groupPosition).setGroupcheck(true);
                        }
                    }
                    //falg为true时跳出循环
                    if (flag) {
                        break;
                    }
                }
                //当前二级列表的总长度
                int size = goodslist.get(groupPosition).size();
                //按照当前二级列表的总长度循环
                for (int x = 0; x < size; x++) {
                    //获得当前二级列表中每一个item的选中状态
                    boolean childCb1 = goodslist.get(groupPosition).get(x).isGoodscheck();
                    //判断
                    if (!childCb1) {
                        //有一个flase 一级列表就设置false  跳出循环
                        grouplist.get(groupPosition).setGroupcheck(false);
                        break;
                    } else {
                        grouplist.get(groupPosition).setGroupcheck(true);
                    }
                }
                //计算价格
                carActivity.changesum(goodslist);
                //刷新适配器
                notifyDataSetChanged();
            }
        });
        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return true;
    }
}



ShopAdapter类



public class ShopAdapter extends RecyclerView.Adapter<ShopAdapter.ShopViewHolder>{

    Context context;
    List list;

     OnShopClick onShopClick;
    public   interface  OnShopClick{
        void OnShopClick(View view, final int position);
    }

    public void setShopAdapter(OnShopClick onShopClick) {
        this.onShopClick = onShopClick;
    }

    public ShopAdapter(Context context, List list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public ShopViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate = View.inflate(context, R.layout.item_shop, null);
        ShopViewHolder shopViewHolder = new ShopViewHolder(inflate);
        return shopViewHolder;
    }

    @Override
    public void onBindViewHolder(ShopViewHolder holder, final int position) {
        holder.shop_price.setText(list.get(position).getBargainPrice()+"");
        holder.shop_title.setText(list.get(position).getTitle());
        String images = list.get(position).getImages();
        String[] split = images.split("\\|");
        holder.shop_img.setImageURI(split[0]);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onShopClick.OnShopClick(view,position);
            }
        });
    }

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

    class ShopViewHolder extends RecyclerView.ViewHolder{
        SimpleDraweeView shop_img;
        TextView shop_price;
        TextView shop_title;
        public ShopViewHolder(View itemView) {
            super(itemView);
            shop_img=itemView.findViewById(R.id.shop_img);
            shop_price=itemView.findViewById(R.id.shop_price);
            shop_title=itemView.findViewById(R.id.shop_title);
        }
    }
}


ShopXQAdapter类



public class ShopXQAdapter  extends RecyclerView.Adapter<ShopXQAdapter.ShopXQViewHolder>{
    Context context;
    ShopXQBean shopXQBean;

    public ShopXQAdapter(Context context, ShopXQBean shopXQBean) {
        this.context = context;
        this.shopXQBean = shopXQBean;
    }

    @Override
    public ShopXQViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate = View.inflate(context, R.layout.shopxq_item, null);
        ShopXQViewHolder shopXQViewHolder = new ShopXQViewHolder(inflate);
        return shopXQViewHolder;
    }

    @Override
    public void onBindViewHolder(ShopXQViewHolder holder, int position) {
        holder.shopxq_title.setText(shopXQBean.getData().getTitle());
        holder.shopxq_price.setText(shopXQBean.getData().getPrice()+"");
        holder.shopxq_name.setText(shopXQBean.getSeller().getName());
        String images = shopXQBean.getData().getImages();
        String[] split = images.split("\\|");
        holder.shopxq_img.setImageURI(split[0]);
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    class ShopXQViewHolder extends RecyclerView.ViewHolder{
        SimpleDraweeView shopxq_img;
        TextView shopxq_title;
        TextView shopxq_price;
        TextView shopxq_name;
        public ShopXQViewHolder(View itemView) {
            super(itemView);
            shopxq_img=itemView.findViewById(R.id.shpxq_img);
            shopxq_title=itemView.findViewById(R.id.shopxq_title);
            shopxq_price=itemView.findViewById(R.id.shopxq_price);
            shopxq_name=itemView.findViewById(R.id.shopxq_name);
        }
    }
}

你可能感兴趣的:(登录+注册+商品列表+商品详情+购物车+删除)