使用Retrofit和Rxjava实现商品分类和商品购物车

使用的依赖和权限

implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'io.reactivex.rxjava2:rxjava:2.1.13'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'com.google.dagger:dagger:2.8'
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.facebook.fresco:fresco:0.12.0'
// 支持 GIF 动图,需要添加
implementation 'com.facebook.fresco:animated-gif:0.12.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.sunfusheng:marqueeview:1.3.3'
implementation 'com.jcodecraeer:xrecyclerview:1.3.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.youth.banner:banner:1.4.10'
implementation 'com.android.support:design:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
//刷新
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-7'
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />

activity_main

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  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=".MainActivity">
    <RadioGroup
        android:id="@+id/rg"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_height="60dp">
        <RadioButton
            android:id="@+id/rbHomepage"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:background="@drawable/tab_homepage"
            android:button="@null"
            android:layout_height="match_parent"/>
        <RadioButton
            android:id="@+id/rbClass"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:background="@drawable/tab_class"
            android:button="@null"
            android:layout_height="match_parent"/>
        <RadioButton
            android:id="@+id/rbFind"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:background="@drawable/tab_find"
            android:button="@null"
            android:layout_height="match_parent"/>
        <RadioButton
            android:id="@+id/rbShopCar"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:background="@drawable/tab_shopcar"
            android:button="@null"
            android:layout_height="match_parent"/>
        <RadioButton
            android:id="@+id/rbMine"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:background="@drawable/tab_mine"
            android:button="@null"
            android:layout_height="match_parent"/>
    </RadioGroup>

    <FrameLayout
        android:id="@+id/flContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/rg" />

</RelativeLayout>

activity_login

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".myfragment.LoginActivity">
    <RelativeLayout
        android:id="@+id/login_title_relative"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp">

        <ImageView
            android:id="@+id/cha"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:src="@drawable/cha"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="京东登录"/>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/login_title_relative"
        android:layout_margin="10dp"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="账号"/>

            <EditText
                android:id="@+id/mobile"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="密码"/>

            <EditText
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>

        <Button
            android:id="@+id/btLogin"
            android:text="登录"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

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

            <TextView
                android:id="@+id/text_regist"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="手机快速注册"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="忘记密码"/>
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

activity_regist

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".myfragment.RegistActivity">
    <RelativeLayout
        android:id="@+id/login_title_relative"
        android:padding="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ImageView
            android:id="@+id/cha_iamge"
            android:src="@drawable/cha"
            android:layout_width="20dp"
            android:layout_height="20dp" />

        <TextView
            android:text="注册"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/login_title_relative"
        android:layout_margin="10dp"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="账号"/>

            <EditText
                android:id="@+id/mobile"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="密码"/>

            <EditText
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>

        <Button
            android:id="@+id/bt"
            android:layout_margin="10dp"
            android:text="注册"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</RelativeLayout>

activity_shop_cart

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:orientation="vertical"
    tools:context=".shopfragment.ShopCartActivity">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center"
        android:text="购物车"/>

    <ExpandableListView
        android:id="@+id/elv"
        android:groupIndicator="@null"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">
    </ExpandableListView>

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

        <CheckBox
            android:id="@+id/cbAll"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="全选"/>

        <TextView
            android:id="@+id/tvMoney"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@id/cbAll"
            android:text="合计:"/>

        <TextView
            android:id="@+id/tvTotal"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:textColor="#ffffff"
            android:background="#ff0000"
            android:gravity="center"
            android:layout_marginLeft="10dp"
            android:text="去结算:"/>
    </RelativeLayout>
</LinearLayout>

add_sub_view

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignBottom="@+id/child_image"
    android:layout_marginRight="5dp"
    android:layout_toLeftOf="@+id/child_text_delete"
    android:orientation="horizontal">
    <TextView
        android:id="@+id/child_text_jian"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/cart_biankuang"
        android:padding="5dp"
        android:text="-"/>

    <TextView
        android:id="@+id/child_text_num"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/cart_biankuang"
        android:paddingBottom="5dp"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:paddingTop="5dp"/>

    <TextView
        android:id="@+id/child_text_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/cart_biankuang"
        android:padding="5dp"
        android:text="+"/>
</LinearLayout>

elv_rv

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </android.support.v7.widget.RecyclerView>
</LinearLayout>

fragment_class

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#b4b4b4"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/ivZxing"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_marginLeft="15dp"
            android:background="@drawable/a_s"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_weight="1"
            android:background="@drawable/shape_search">
            <ImageView
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_marginTop="5dp"
                android:layout_marginLeft="330dp"
                android:src="@drawable/root"/>
        </LinearLayout>

        <ImageView
            android:id="@+id/message"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="15dp"
            android:background="@drawable/my_msg_bai"/>
    </LinearLayout>

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

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

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="7"
            android:orientation="vertical">
            <ImageView
                android:id="@+id/iv"
                android:layout_width="match_parent"
                android:layout_height="150dp"/>

            <ExpandableListView
                android:id="@+id/elv"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
            </ExpandableListView>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

fragment_my

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

        <RelativeLayout
            android:id="@+id/login_back_pic"
            android:layout_width="match_parent"
            android:layout_height="183dp"
            android:background="@drawable/background">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="120dp">

                <ImageView
                    android:id="@+id/iv5_touxiang"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_gravity="center"
                    android:layout_marginLeft="10dp"
                    android:src="@drawable/login" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/tv5_login"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:text="登录/注册>"
                        android:textColor="@android:color/white"
                        android:textSize="15sp" />

                    <TextView
                        android:id="@+id/tv5_nicheng"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:layout_marginTop="10dp"
                        android:text="昵称"
                        android:textColor="@android:color/white" />
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginTop="10dp">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:onClick="tv5"
                    android:src="@drawable/shezhi" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:src="@drawable/xiaoxi" />
            </LinearLayout>
        </RelativeLayout>

    <LinearLayout
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/daifukuan"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/daishouhuo"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/daipingjia"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/shouhou"/>
        <ImageView
            android:id="@+id/iv_dingdan"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/wodedingdan"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="代付款"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="待收货"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="待评价"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="退换/售后"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="我的订单"/>
    </LinearLayout>
    <View
        android:layout_marginTop="20dp"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#f0f2f5"/>
    <LinearLayout
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:textSize="10sp"
            android:text="0"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:textSize="10sp"
            android:text="0"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:textSize="10sp"
            android:text="0.00"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:textSize="10sp"
            android:text="0"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/wodeqianbao"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="京豆"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="优惠券"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="白条"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="京东E卡"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="我的钱包"/>
    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="20dp"
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="#f0f2f5">
    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/shangpinguanzhu"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/dianpuguanzhu"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/neirongguanzhu"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/liulanjilu"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="6dp">
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="商品关注"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="店铺关注"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="内容关注"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="浏览记录"/>
    </LinearLayout>

    <View
        android:layout_marginTop="20dp"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#f0f2f5"/>

    <LinearLayout
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/wodehuodong"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/shequ"/>
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:src="@drawable/kehufuwu"/>

        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="6dp">
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="我的活动"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="社区"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10sp"
            android:text="客户服务"/>
        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text=""/>
    </LinearLayout>
    </LinearLayout>

</ScrollView>

fragment_my_layout

<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/smart_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:id="@+id/fragment_my_scroll"
        android:scrollbars="none"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:background="#ffffff"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <!--登录-->
            <RelativeLayout
                android:id="@+id/login_back_pic"
                android:background="@drawable/normal_regbg"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:id="@+id/my_linear_login"
                    android:layout_marginLeft="10dp"
                    android:gravity="center_vertical"
                    android:layout_centerVertical="true"
                    android:orientation="horizontal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:id="@+id/my_user_icon"
                        android:src="@drawable/user"
                        android:layout_width="60dp"
                        android:layout_height="60dp" />

                    <TextView
                        android:id="@+id/my_user_name"
                        android:layout_marginLeft="10dp"
                        android:textColor="#ffffff"
                        android:text="登录/注册 >"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </LinearLayout>

                <ImageView
                    android:id="@+id/my_xx"
                    android:layout_margin="10dp"
                    android:layout_alignParentRight="true"
                    android:src="@drawable/xx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <ImageView
                    android:layout_margin="10dp"
                    android:layout_toLeftOf="@+id/my_xx"
                    android:src="@drawable/sz"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </RelativeLayout>

            <!--订单-->
            <LinearLayout
                android:padding="10dp"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:id="@+id/my_order_dfk"
                    android:gravity="center_horizontal"
                    android:orientation="vertical"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:src="@drawable/dfk"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:layout_marginTop="5dp"
                        android:text="待付款"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/my_order_dsh"
                    android:gravity="center_horizontal"
                    android:orientation="vertical"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content">
                    <ImageView
                        android:src="@drawable/dsh"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:layout_marginTop="5dp"
                        android:text="待收货"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/my_order_dpj"
                    android:gravity="center_horizontal"
                    android:orientation="vertical"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content">
                    <ImageView
                        android:src="@drawable/dpj"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:layout_marginTop="5dp"
                        android:text="待评价"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/my_order_th"
                    android:gravity="center_horizontal"
                    android:orientation="vertical"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:src="@drawable/dfk"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:layout_marginTop="5dp"
                        android:text="退换/售后"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/my_order_all"
                    android:gravity="center_horizontal"
                    android:orientation="vertical"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:src="@drawable/dfk"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:layout_marginTop="5dp"
                        android:text="我的订单"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </LinearLayout>
            </LinearLayout>

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="318dp"
                android:scaleType="fitXY"
                android:src="@drawable/abc" />

            <!--为你推荐-->
            <android.support.v7.widget.RecyclerView
                android:nestedScrollingEnabled="false"
                android:id="@+id/tui_jian_recycler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
            </android.support.v7.widget.RecyclerView>
        </LinearLayout>
    </ScrollView>

</com.scwang.smartrefresh.layout.SmartRefreshLayout>

fragment_shopcart

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center"
        android:text="购物车"/>

    <ExpandableListView
        android:id="@+id/elv"
        android:groupIndicator="@null"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">
    </ExpandableListView>

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

        <CheckBox
            android:id="@+id/cbAll"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="全选"/>

        <TextView
            android:id="@+id/tvMoney"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@id/cbAll"
            android:text="合计:"/>

        <TextView
            android:id="@+id/tvTotal"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:textColor="#ffffff"
            android:background="#ff0000"
            android:gravity="center"
            android:layout_marginLeft="10dp"
            android:text="去结算:"/>
    </RelativeLayout>
</LinearLayout>

rvclass_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/line_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:gravity="center"
    android:orientation="vertical">

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

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</LinearLayout>

rvleft_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <TextView
        android:id="@+id/tv"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center"/>

</LinearLayout>

shopcart_seller_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:layout_width="match_parent"
    android:layout_height="30dp">
    <CheckBox
        android:id="@+id/cbSeller"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"/>

    <TextView
        android:id="@+id/tvSeller"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"/>
</LinearLayout>

shopcart_seller_product_item

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <CheckBox
        android:id="@+id/cbProduct"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="20dp"/>

    <TextView
        android:id="@+id/tvDel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="15dp"
        android:background="#ff0000"
        android:gravity="center_vertical"
        android:text="删除"
        android:textColor="#ffffff"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/tvDel"
        android:layout_toRightOf="@id/cbProduct"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/iv"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_gravity="center_vertical"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tvTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"/>

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

                <TextView
                    android:id="@+id/tvPrice"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:text="12312"
                    android:textColor="#ff0000"/>

                <com.bwie.test.utils.AddSubView
                    android:id="@+id/addSubCard"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true">
                </com.bwie.test.utils.AddSubView>
            </RelativeLayout>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

drawable文件夹下cart_biankuang

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff" />
    <stroke
        android:width="0.1dp"
        android:color="#000000" />
</shape>

shape_search

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="20dp"></corners>
    <solid android:color="#ffffff"></solid>
</shape>

tab_class

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/abx" android:state_checked="true"/>
    <item android:drawable="@drawable/abw" android:state_checked="false"/>
</selector>

tab_find

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/abz" android:state_checked="true"/>
    <item android:drawable="@drawable/aby" android:state_checked="false"/>
</selector>

tab_homepage

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ac1" android:state_checked="true"/>
    <item android:drawable="@drawable/ac0" android:state_checked="false"/>
</selector>

tab_mine

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ac3" android:state_checked="true"/>
    <item android:drawable="@drawable/ac2" android:state_checked="false"/>
</selector>

tab_shopcar

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/abv" android:state_checked="true"/>
    <item android:drawable="@drawable/abu" android:state_checked="false"/>
</selector>

MainActivity

import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.bwie.test.mysimulation.base.BaseActivity;
import com.bwie.test.mysimulation.classify.ClassifyFragment;
import com.bwie.test.mysimulation.findfragment.FindFragment;
import com.bwie.test.mysimulation.homepage.HomeFragment;
import com.bwie.test.mysimulation.myfragment.MyFragment;
import com.bwie.test.mysimulation.shopfragment.ShopFragment;

public class MainActivity extends BaseActivity {
    //创建5个Fragment
    private FrameLayout mFlContent;
    private HomeFragment homeFragment;
    private ClassifyFragment classFragment;
    private FindFragment findFragment;
    private ShopFragment shopFragment;
    private MyFragment myFragment;
    private RadioGroup mRg;
    private FragmentManager fragmentManager;
    private RadioButton mRbHomepage;
    private RadioButton mRbClass;
    private RadioButton mRbFind;
    private RadioButton mRbShopCar;
    private RadioButton mRbMine;
    private int currentIndex = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main);
        initView();//初始化
        homeFragment = new HomeFragment();
        classFragment = new ClassifyFragment();
        shopFragment = new ShopFragment();
        findFragment = new FindFragment();
        myFragment = new MyFragment();
        fragmentManager = getSupportFragmentManager();
        //默认显示首页
        fragmentManager.beginTransaction().replace(R.id.flContent, homeFragment).commit();
        mRbHomepage.setChecked(true);
        //设置点击事件
        setListener();
    }

    private void setListener() {
        mRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rbHomepage:
                        //首页
                        if (currentIndex == 1) {
                            return;
                        }
                        currentIndex = 1;
                        fragmentManager.beginTransaction().replace(R.id.flContent, homeFragment)
                                  .commit();
                        break;
                    case R.id.rbClass:
                        //分类
                        if (currentIndex == 2) {
                            return;
                        }
                        currentIndex = 2;
                        fragmentManager.beginTransaction().replace(R.id.flContent, classFragment)
                                  .commit();
                        break;
                    case R.id.rbFind:
                        if (currentIndex == 3) {
                            return;
                        }
                        currentIndex = 3;
                        fragmentManager.beginTransaction().replace(R.id.flContent, findFragment)
                                .commit();
                        break;
                    case R.id.rbShopCar:
                        if (currentIndex == 4) {
                            return;
                        }
                        currentIndex = 4;
                        fragmentManager.beginTransaction().replace(R.id.flContent, shopFragment)
                               .commit();
                        break;
                    case R.id.rbMine:
                        if (currentIndex == 5) {
                            return;
                        }
                        currentIndex = 5;
                        fragmentManager.beginTransaction().replace(R.id.flContent, myFragment)
                                .commit();
                        break;
                }
            }
        });
    }

    //加载布局id
    private void initView() {
        mRg = (RadioGroup) findViewById(R.id.rg);
        mFlContent = (FrameLayout) findViewById(R.id.flContent);
        mRbHomepage = (RadioButton) findViewById(R.id.rbHomepage);
        mRbClass = (RadioButton) findViewById(R.id.rbClass);
        mRbFind = (RadioButton) findViewById(R.id.rbFind);
        mRbShopCar = (RadioButton) findViewById(R.id.rbShopCar);
        mRbMine = (RadioButton) findViewById(R.id.rbMine);

    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void inject() {
    }
}

HomeFragment

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class HomeFragment extends Fragment{
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                    @Nullable Bundle savedInstanceState) {
        TextView textView = new TextView(getActivity());
        textView.setText("首页");
        return textView;
    }

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

FindFragment

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class FindFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, 
                 @Nullable Bundle savedInstanceState) {
        TextView textView = new TextView(getActivity());
        textView.setText("发现");
        return textView;
    }

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

ClassifyFragment

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ImageView;

import com.bwie.test.adapter.ElvAdapter;
import com.bwie.test.adapter.RvLeftAdapter;
import com.bwie.test.bean.CatagoryBean;
import com.bwie.test.bean.ProductCatagoryBean;
import com.bwie.test.component.DaggerHttpComponent;
import com.bwie.test.inter.OnItemClickListener;
import com.bwie.test.module.HttpModule;
import com.bwie.test.mysimulation.R;
import com.bwie.test.mysimulation.base.BaseFragment;
import com.bwie.test.mysimulation.classify.contract.ClassifyContract;
import com.bwie.test.mysimulation.classify.presenter.ClassifyPresenter;
import java.util.ArrayList;
import java.util.List;

public class ClassifyFragment extends BaseFragment<ClassifyPresenter> implements 
                   ClassifyContract.View, View.OnClickListener{
    private RecyclerView mRvLeft;
    private ImageView mIv;
    private ExpandableListView mElv;
    private ImageView iivZxing;
    private ImageView imessage;

    @Override
    public int getContentLayout() {
        return R.layout.fragment_class;
    }

    @Override
    public void inject() {
        DaggerHttpComponent.builder()
                .httpModule(new HttpModule())
                .build()
                .inject(this);
    }

    @Override
    public void initView(View view) {
        mRvLeft = (RecyclerView) view.findViewById(R.id.rvLeft);
        mIv = (ImageView) view.findViewById(R.id.iv);
        mIv.setBackgroundResource(R.drawable.timg);
        mElv = (ExpandableListView) view.findViewById(R.id.elv);
        mElv.setGroupIndicator(null);
        iivZxing=(ImageView)view.findViewById( R.id.ivZxing );
        imessage=(ImageView)view.findViewById( R.id.message );
        setListener();
        //请求数据
        initData();
    }

    private void setListener() {
        iivZxing.setOnClickListener(this);
        imessage.setOnClickListener(this);
    }

    private void initData() {
        mPresenter.getCatagory();
    }

    @Override
    public void getProductCatagorySuccess(ProductCatagoryBean productCatagoryBean) {
        List<String> groupList = new ArrayList<>();
        List<List<ProductCatagoryBean.DataBean.ListBean>> childList = new ArrayList<>();
        List<ProductCatagoryBean.DataBean> data = productCatagoryBean.getData();
        for (int i = 0; i < data.size(); i++) {
            groupList.add(data.get(i).getName());
            List<ProductCatagoryBean.DataBean.ListBean> list = data.get(i).getList();
            childList.add(list);
        }
        ElvAdapter elvAdapter = new ElvAdapter(getContext(), groupList, childList);
        mElv.setAdapter(elvAdapter);
        for (int i = 0; i < groupList.size(); i++) {
            mElv.expandGroup(i);
        }
    }

    @Override
    public void getCatagorySuccess(CatagoryBean catagoryBean) {
        final List<CatagoryBean.DataBean> data = catagoryBean.getData();
        mRvLeft.setLayoutManager(new LinearLayoutManager(getContext()));
        mRvLeft.addItemDecoration(new DividerItemDecoration(getContext(), RecyclerView.VERTICAL));
        final RvLeftAdapter adapter = new RvLeftAdapter(getContext(), data);
        mRvLeft.setAdapter(adapter);
        mPresenter.getProductCatagory(data.get(0).getCid()+"");
        adapter.changeCheck(0, true);
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                adapter.changeCheck(position, true);
                mPresenter.getProductCatagory(data.get(position).getCid() + "");
            }
            @Override
            public void onLongItemClick(int position) {

            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ivZxing:
//                Intent intent = new Intent(getContext(), CaptureActivity.class);
//                startActivityForResult(intent, 1);
                break;
            case R.id.message:
//                Intent intent2 = new Intent(getContext(), WebViewActivity.class);
//                String detailUrl="https://www.jd.com/intro/about.aspx";
//                intent2.putExtra("detailUrl", detailUrl);
//                startActivity(intent2);
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
//        if (requestCode == 1 && data != null) {
//            Bundle bundle = data.getExtras();
//            if (bundle.getInt( CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) {
//                String string = bundle.getString(CodeUtils.RESULT_STRING);
//                //拿到最终结果
//                //Intent intent = new Intent(getContext(),WebViewActivity.class);
//            }
//        }
    }
}

ShopFragment

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.TextView;

import com.bwie.test.adapter.ElvShopcartAdapter;
import com.bwie.test.bean.GetCartsBean;
import com.bwie.test.bean.SellerBean;
import com.bwie.test.bean.eventbus.MessageEvent;
import com.bwie.test.component.DaggerHttpComponent;
import com.bwie.test.mysimulation.R;
import com.bwie.test.mysimulation.base.BaseFragment;
import com.bwie.test.mysimulation.shopfragment.contract.ShopcartContract;
import com.bwie.test.mysimulation.shopfragment.presenter.ShopcartPresenter;
import com.bwie.test.utils.DialogUtil;
import com.bwie.test.utils.SharedPreferencesUtils;
import org.greenrobot.eventbus.EventBus;
import java.util.List;

public class ShopFragment extends BaseFragment<ShopcartPresenter> implements ShopcartContract.View {
    private ExpandableListView mElv;
    /**
     * 全选
     */
    private CheckBox mCbAll;
    /**
     * 合计:
     */
    private TextView mTvMoney;
    /**
     * 去结算:
     */
    private TextView mTvTotal;
    private ProgressDialog progressDialog;
    private ElvShopcartAdapter adapter;

    @Override
    public int getContentLayout() {
        return R.layout.fragment_shopcart;
    }

    @Override
    public void inject() {
        DaggerHttpComponent.builder()
                .build()
                .inject(this);
    }

    @Override
    public void initView(View view) {
        //初始化dialog
        progressDialog = DialogUtil.getProgressDialog(getActivity());
        String token = (String) SharedPreferencesUtils.getParam(getActivity(), "token", "");
        String uid = (String) SharedPreferencesUtils.getParam(getActivity(), "uid", "");
        mPresenter.getCarts(uid,token);

        mElv = (ExpandableListView) view.findViewById( R.id.elv );
        mCbAll = (CheckBox) view.findViewById( R.id.cbAll );
        mTvMoney = (TextView) view.findViewById( R.id.tvMoney );
        mTvTotal = (TextView) view.findViewById( R.id.tvTotal );
        mCbAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (adapter != null) {
                    progressDialog.show();
                    adapter.changeAllState(mCbAll.isChecked());
                }
            }
        });
        mTvTotal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent = new Intent(getActivity(), MakeSureOrderActivity.class);
//                startActivity(intent);
                //把用户选中的商品传过去
                List<SellerBean> gList = adapter.getGroupList();
                List<List<GetCartsBean.DataBean.ListBean>> cList = adapter.getchildList();
                MessageEvent messageEvent = new MessageEvent();
                messageEvent.setcList(cList);
                messageEvent.setgList(gList);
                EventBus.getDefault().postSticky(messageEvent);
            }
        });
    }

    @Override
    public void showCartList(List<SellerBean> groupList, List<List<GetCartsBean.DataBean.ListBean>>
                               childList) {
        //判断所有商家是否全部选中
        mCbAll.setChecked(isSellerAddSelected(groupList));
        //创建适配器
        adapter = new ElvShopcartAdapter(getActivity(), groupList, childList, mPresenter,progressDialog);
        mElv.setAdapter(adapter);
        //获取数量和总价
        String[] strings = adapter.computeMoneyAndNum();
        mTvMoney.setText("总计:" + strings[0] + "元");
        mTvTotal.setText("去结算("+strings[1]+"个)");
        //        //默认展开列表
        for (int i = 0; i < groupList.size(); i++) {
            mElv.expandGroup(i);
        }
        //关闭进度条
        progressDialog.dismiss();
    }

    @Override
    public void updateCartsSuccess(String msg) {
        if (adapter!=null){
            adapter.updataSuccess();
        }
    }

    @Override
    public void deleteCartSuccess(String msg) {
        //调用适配器里的delSuccess()方法
        if (adapter!=null){
            adapter.delSuccess();
        }
    }
    /**
     * 判断所有商家是否全部选中
     * @param groupList
     * @return
     */
    private boolean isSellerAddSelected(List<SellerBean> groupList) {
        for (int i = 0; i < groupList.size(); i++) {
            SellerBean sellerBean = groupList.get(i);
            if (!sellerBean.isSelected()) {
                return false;
            }
        }
        return true;
    }
}

ShopCartActivity

import android.app.ProgressDialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.TextView;

import com.bwie.test.adapter.ElvShopcartAdapter;
import com.bwie.test.bean.GetCartsBean;
import com.bwie.test.bean.SellerBean;
import com.bwie.test.bean.eventbus.MessageEvent;
import com.bwie.test.component.DaggerHttpComponent;
import com.bwie.test.mysimulation.R;
import com.bwie.test.mysimulation.base.BaseActivity;
import com.bwie.test.mysimulation.shopfragment.contract.ShopcartContract;
import com.bwie.test.mysimulation.shopfragment.presenter.ShopcartPresenter;
import com.bwie.test.utils.DialogUtil;
import com.bwie.test.utils.SharedPreferencesUtils;
import org.greenrobot.eventbus.EventBus;
import java.util.List;

public class ShopCartActivity extends BaseActivity<ShopcartPresenter> implements ShopcartContract.View {
    private ExpandableListView mElv;
    /**
     * 全选
     */
    private CheckBox mCbAll;
    /**
     * 合计:
     */
    private TextView mTvMoney;
    /**
     * 去结算:
     */
    private TextView mTvTotal;
    private ProgressDialog progressDialog;
    private ElvShopcartAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        //初始化dialog
        progressDialog = DialogUtil.getProgressDialog(this);
        String token = (String) SharedPreferencesUtils.getParam(ShopCartActivity.this, "token", "");
        String uid = (String) SharedPreferencesUtils.getParam(ShopCartActivity.this, "uid", "");
        mPresenter.getCarts(uid,token);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_shop_cart;
    }

    @Override
    public void inject() {
        DaggerHttpComponent.builder()
                .build()
                .inject(this);
    }

    private void initView() {
        mElv = (ExpandableListView) findViewById(R.id.elv);
        mCbAll = (CheckBox) findViewById(R.id.cbAll);
        mTvMoney = (TextView) findViewById(R.id.tvMoney);
        mTvTotal = (TextView) findViewById(R.id.tvTotal);

        mCbAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (adapter != null) {
                    progressDialog.show();
                    adapter.changeAllState(mCbAll.isChecked());
                }
            }
        });
        mTvTotal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent = new Intent(ShopCartActivity.this, MakeSureOrderActivity.class);
//                startActivity(intent);
                //把用户选中的商品传过去
                List<SellerBean> gList = adapter.getGroupList();
                List<List<GetCartsBean.DataBean.ListBean>> cList = adapter.getchildList();
                MessageEvent messageEvent = new MessageEvent();
                messageEvent.setcList(cList);
                messageEvent.setgList(gList);
                EventBus.getDefault().postSticky(messageEvent);
            }
        });
    }

    @Override
    public void showCartList(List<SellerBean> groupList, List<List<GetCartsBean.DataBean.ListBean>> 
                    childList) {
       //判断所有商家是否全部选中
        mCbAll.setChecked(isSellerAddSelected(groupList));
        //创建适配器
        adapter = new ElvShopcartAdapter(this, groupList, childList, mPresenter, progressDialog);
        mElv.setAdapter(adapter);
        //获取数量和总价
        String[] strings = adapter.computeMoneyAndNum();
        mTvMoney.setText("总计:" + strings[0] + "元");
        mTvTotal.setText("去结算("+strings[1]+"个)");
        //        //默认展开列表
        for (int i = 0; i < groupList.size(); i++) {
            mElv.expandGroup(i);
        }
        //关闭进度条
        progressDialog.dismiss();
    }

    @Override
    public void updateCartsSuccess(String msg) {
        if (adapter != null){
            adapter.updataSuccess();
        }
    }

    @Override
    public void deleteCartSuccess(String msg) {
        //调用适配器里的delSuccess()方法
        if (adapter != null){
            adapter.delSuccess();
        }
    }

    /**
     * 判断所有商家是否全部选中
     * @param groupList
     * @return
     */
    private boolean isSellerAddSelected(List<SellerBean> groupList) {
        for (int i = 0; i < groupList.size(); i++) {
            SellerBean sellerBean = groupList.get(i);
            if (!sellerBean.isSelected()) {
                return false;
            }
        }
        return true;
    }
}

MyFragment

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bwie.test.mysimulation.R;
import com.bwie.test.mysimulation.base.BaseFragment;
import com.bwie.test.utils.SharedPreferencesUtils;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

public class MyFragment extends BaseFragment implements View.OnClickListener{
    private View view;
    private ImageView mMyUserIcon;
    /**
     * 登录/注册 >
     */
    private RecyclerView tui_jian_recycler;
    private LinearLayout my_linear_login;
    private ImageView my_user_icon;
    private TextView my_user_name;
    private LinearLayout my_order_dfk;
    private LinearLayout my_order_dpj;
    private LinearLayout my_order_dsh;
    private LinearLayout my_order_th;
    private LinearLayout my_order_all;
    private ScrollView fragment_my_scroll;
    private RelativeLayout login_back_pic;
    private SmartRefreshLayout smart_refresh;

    @Override
    public int getContentLayout() {
        return R.layout.fragment_my_layout;
    }

    @Override
    public void onResume() {
        super.onResume();
        String name = (String) SharedPreferencesUtils.getParam(getContext(), "name", "");
        String iconUrl = (String) SharedPreferencesUtils.getParam(getContext(), "iconUrl", "");
        String uid = (String) SharedPreferencesUtils.getParam(getContext(), "uid", "");
        if (!TextUtils.isEmpty(uid)) {
            //登录过
            login_back_pic.setBackgroundResource(R.drawable.normal_regbg);
        } else {
            //未登录
            login_back_pic.setBackgroundResource(R.drawable.reg_bg);
        }
        if (!TextUtils.isEmpty(iconUrl)) {
            Glide.with(getContext()).load(iconUrl).into(my_user_icon);
        }
        if (!TextUtils.isEmpty(name)) {
            my_user_name.setText(name);
        }
    }

    @Override
    public void inject() {
    }

    @Override
    public void initView(View view) {
        tui_jian_recycler = view.findViewById(R.id.tui_jian_recycler);
        my_linear_login = view.findViewById(R.id.my_linear_login);
        my_user_icon = view.findViewById(R.id.my_user_icon);
        my_user_name = view.findViewById(R.id.my_user_name);
        my_order_dfk = view.findViewById(R.id.my_order_dfk);
        my_order_dpj = view.findViewById(R.id.my_order_dpj);
        my_order_dsh = view.findViewById(R.id.my_order_dsh);
        my_order_th = view.findViewById(R.id.my_order_th);
        my_order_all = view.findViewById(R.id.my_order_all);
        fragment_my_scroll = view.findViewById(R.id.fragment_my_scroll);
        login_back_pic = view.findViewById(R.id.login_back_pic);
        smart_refresh = view.findViewById(R.id.smart_refresh);
        setListener();
    }

    private void setListener(){
        my_linear_login.setOnClickListener(this);
        my_order_dfk.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.my_linear_login:
                //判断是否登录过
                String uid = (String) SharedPreferencesUtils.getParam(getContext(), "uid", "");
                if (TextUtils.isEmpty(uid)) {
                    //未登录
                    Intent intent = new Intent(getContext(), LoginActivity.class);
                    startActivity(intent);
                } else {
                    //已登录
//                    Intent intent = new Intent(getContext(), UserInfoActivity.class);
//                    startActivity(intent);
                }
                break;
            case R.id.my_order_dfk:
                //跳转到我的订单页面
//                Intent intent = new Intent(getContext(),OrderListActivity.class);
//                startActivity(intent);
                break;
        }
    }
}

LoginActivity

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bwie.test.bean.UserBean;
import com.bwie.test.component.DaggerHttpComponent;
import com.bwie.test.module.HttpModule;
import com.bwie.test.mysimulation.MainActivity;
import com.bwie.test.mysimulation.R;
import com.bwie.test.mysimulation.base.BaseActivity;
import com.bwie.test.mysimulation.myfragment.contract.LoginContract;
import com.bwie.test.mysimulation.myfragment.presenter.LoginPresenter;
import com.bwie.test.utils.SharedPreferencesUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class LoginActivity extends BaseActivity<LoginPresenter> implements View.OnClickListener, 
                   LoginContract.View {
    @BindView(R.id.cha)
    ImageView mCha;
    @BindView(R.id.login_title_relative)
    RelativeLayout mLoginTitleRelative;
    @BindView(R.id.mobile)
    EditText mMobile;
    @BindView(R.id.password)
    EditText mPassword;
    @BindView(R.id.btLogin)
    Button mBtLogin;
    @BindView(R.id.text_regist)
    TextView mTextRegist;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        mMobile = (EditText) findViewById(R.id.mobile);
        mPassword = (EditText) findViewById(R.id.password);
        mBtLogin = (Button) findViewById(R.id.btLogin);
        mBtLogin.setOnClickListener(this);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_login;
    }

    @Override
    public void inject() {
        DaggerHttpComponent.builder()
                .httpModule(new HttpModule())
                .build()
                .inject(this);
    }

    @Override
    public void loginSuccess(UserBean userBean) {
        Toast.makeText(LoginActivity.this, userBean.getMsg(), Toast.LENGTH_SHORT).show();
        Toast.makeText(LoginActivity.this, userBean.getMsg(), Toast.LENGTH_SHORT).show();
        SharedPreferencesUtils.setParam(LoginActivity.this,"uid",userBean.getData().getUid() + "");
        SharedPreferencesUtils.setParam(LoginActivity.this,"name",userBean.getData().getUsername() + "");
        SharedPreferencesUtils.setParam(LoginActivity.this,"iconUrl",userBean.getData().getIcon() + "");
        SharedPreferencesUtils.setParam(LoginActivity.this,"token",userBean.getData().getToken() + "");
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        LoginActivity.this.finish();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.cha:
                finish();
                break;
            case R.id.btLogin:
                //需要调用P层,去完成接口调用
                String mobile = mMobile.getText().toString();
                String password = mPassword.getText().toString();
                mPresenter.login(mobile, password);
                break;
            case R.id.text_regist:
                Intent intent = new Intent(LoginActivity.this, RegistActivity.class);
                startActivity(intent);
                finish();
                break;
        }
    }
}

RegistActivity

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.bwie.test.bean.RegisterBean;
import com.bwie.test.component.DaggerHttpComponent;
import com.bwie.test.module.HttpModule;
import com.bwie.test.mysimulation.R;
import com.bwie.test.mysimulation.base.BaseActivity;
import com.bwie.test.mysimulation.myfragment.contract.RegisterContract;
import com.bwie.test.mysimulation.myfragment.presenter.RegisterPresenter;

public class RegistActivity extends BaseActivity<RegisterPresenter> implements 
                    RegisterContract.View, View.OnClickListener {
    private Button mBt;
    private ImageView mChaIamge;
    private RelativeLayout mLoginTitleRelative;
    private EditText mMobile;
    private EditText mPassword;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_regist);
        initView();
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_regist;
    }

    @Override
    public void inject() {
        DaggerHttpComponent.builder()
                .httpModule(new HttpModule())
                .build()
                .inject(this);
    }

    private void initView() {
        mChaIamge = (ImageView) findViewById(R.id.cha_iamge);
        mChaIamge.setOnClickListener(this);
        mLoginTitleRelative = (RelativeLayout) findViewById(R.id.login_title_relative);
        mMobile = (EditText) findViewById(R.id.mobile);
        mPassword = (EditText) findViewById(R.id.password);
        mBt = (Button) findViewById(R.id.bt);
        mBt.setOnClickListener(this);
    }

    @Override
    public void registerSuccess(RegisterBean registerBean) {
        String msg = registerBean.getCode();
        if (msg.equals("0")){
            Intent intent = new Intent(RegistActivity.this, LoginActivity.class);
            startActivity(intent);
            //finish();
            Toast.makeText(RegistActivity.this, registerBean.getMsg(), Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(RegistActivity.this, registerBean.getMsg(), Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.cha_iamge:
                finish();
                break;
            case R.id.bt:
                String mobile = mMobile.getText().toString();
                String password = mPassword.getText().toString();
                mPresenter.register(mobile, password);
                break;
        }
    }
}

app文件夹下MyApp

import android.app.Application;
import com.facebook.drawee.backends.pipeline.Fresco;

public class MyApp extends Application{
    @Override
    public void onCreate() {
        super.onCreate();
        //初始化fresco
        Fresco.initialize(this);
    }
}

base文件夹下BaseActivity

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Toast;

import com.bwie.test.inter.IBase;
import com.bwie.test.utils.SharedPreferencesUtils;
import javax.inject.Inject;

public abstract class BaseActivity<T extends BaseContract.BasePresenter> extends
              FragmentActivity implements IBase,BaseContract.BaseView {
    @Inject
    protected T mPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentLayout());
        inject();
        //绑定
        if (mPresenter != null) {
            mPresenter.attchView(this);
        }
    }

    @Override
    public void initView(View view) {
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //解绑
        if (mPresenter != null) {
            mPresenter.detachView();
        }
    }

    @Override
    public void showLoading() {
    }

    @Override
    public void dismissLoading() {
    }

    protected String getUid() {
        return (String) SharedPreferencesUtils.getParam(this, "uid", "");
    }

    protected String getToken() {
        return (String) SharedPreferencesUtils.getParam(this, "token", "");
    }

    protected void toast(String str){
        Toast.makeText(this,str,Toast.LENGTH_SHORT).show();
    }
}

BaseContract

public interface BaseContract {
    //抽取所有Presenter共性,比如绑定,解绑
    interface BasePresenter<T extends BaseView>{
        void attchView(T view);
        void detachView();
    }

    //抽取所有View的共性,比如显示进度条和关闭进度
    interface BaseView{
        void showLoading();
        void dismissLoading();
    }
}

BaseFragment

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bwie.test.inter.IBase;
import com.bwie.test.utils.SharedPreferencesUtils;
import javax.inject.Inject;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseFragment<T extends BaseContract.BasePresenter> extends
          Fragment implements IBase,BaseContract.BaseView {
    @Inject
    protected T mPresenter;
    private Unbinder bind;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        inject();
        if (mPresenter != null) {
            mPresenter.attchView(this);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.detachView();
        }
        if (bind != null) {
            bind.unbind();
        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, 
                @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(getContentLayout(), null);
        bind = ButterKnife.bind(getActivity(), view);
        initView(view);
        return view;
    }

    @Override
    public void showLoading() {
    }

    @Override
    public void dismissLoading() {
    }

    protected String getUid() {
        return (String) SharedPreferencesUtils.getParam(getContext(), "uid", "");
    }

    protected String getToken() {
        return (String) SharedPreferencesUtils.getParam(getContext(), "token", "");
    }
}

BasePresenter

public class BasePresenter<T extends BaseContract.BaseView>implements 
                          BaseContract.BasePresenter<T> {
    protected T mView;

    @Override
    public void attchView(T view) {
        this.mView=view;
    }

    @Override
    public void detachView() {
        if (mView != null) {
            mView = null;
        }
    }
}

inter文件夹下IBase

import android.view.View;

public interface IBase {
    int getContentLayout();
    void inject();
    void initView(View view);
}
OnItemClickListener
public interface OnItemClickListener {
    void onItemClick(int position);
    void onLongItemClick(int position);
}

component文件夹下HttpComponent

import com.bwie.test.module.HttpModule;
import com.bwie.test.mysimulation.classify.ClassifyFragment;
import com.bwie.test.mysimulation.myfragment.LoginActivity;
import com.bwie.test.mysimulation.myfragment.MyFragment;
import com.bwie.test.mysimulation.myfragment.RegistActivity;
import com.bwie.test.mysimulation.shopfragment.ShopCartActivity;
import com.bwie.test.mysimulation.shopfragment.ShopFragment;
import dagger.Component;

@Component (modules = HttpModule.class)
public interface HttpComponent {
    void inject(ClassifyFragment classifyFragment);
    void inject(ShopFragment shopFragment);
    void inject(ShopCartActivity shopCartActivity);
    void inject(LoginActivity loginActivity);
    void inject(RegistActivity registActivity);
}

module文件夹下HttpModule

import com.bwie.test.net.Api;
import com.bwie.test.net.CatagoryApi;
import com.bwie.test.net.CatagoryApiService;
import com.bwie.test.net.DeleteCartApi;
import com.bwie.test.net.DeleteCartApiService;
import com.bwie.test.net.GetCartApi;
import com.bwie.test.net.GetCartApiService;
import com.bwie.test.net.LoginApi;
import com.bwie.test.net.LoginApiService;
import com.bwie.test.net.ProductCatagoryApi;
import com.bwie.test.net.ProductCatagoryApiService;
import com.bwie.test.net.RegisterApi;
import com.bwie.test.net.RegisterApiService;
import com.bwie.test.net.UpdateCartApi;
import com.bwie.test.net.UpdateCartApiService;
import com.bwie.test.utils.MyInterceptor;

import java.util.concurrent.TimeUnit;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

@Module
public class HttpModule {
    @Provides
    OkHttpClient.Builder provideOkHttpClientBuilder(){
        return new OkHttpClient.Builder()
                .writeTimeout(20, TimeUnit.SECONDS)
                .readTimeout(20, TimeUnit.SECONDS)
                .connectTimeout(20, TimeUnit.SECONDS);
    }

    @Provides
    Retrofit.Builder provideRetrofit(OkHttpClient.Builder builder){
        builder.addInterceptor(new MyInterceptor());
        return new Retrofit.Builder()
                .baseUrl(Api.BASEURL)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .client(builder.build());
    }

    @Provides
    CatagoryApi provideCatagoryApi(Retrofit.Builder builder) {
        Retrofit retrofit = builder.build();
        CatagoryApiService catagoryApiService = retrofit.create(CatagoryApiService.class);
        return CatagoryApi.getCatagoryApi(catagoryApiService);
    }
    @Provides
    ProductCatagoryApi provideProductCatagoryApi(Retrofit.Builder builder) {
        Retrofit retrofit = builder.build();
        ProductCatagoryApiService productCatagoryApiService = retrofit.create(
                                     ProductCatagoryApiService.class);
        return ProductCatagoryApi.getProductCatagoryApi(productCatagoryApiService);
    }

    @Provides
    LoginApi provideLoginApi(Retrofit.Builder builder) {
        Retrofit retrofit = builder.build();
        LoginApiService loginApiService = retrofit.create(LoginApiService.class);
        return LoginApi.getLoginApi(loginApiService);
    }

    @Provides
    RegisterApi provideRegisterApi(Retrofit.Builder builder){
        Retrofit retrofit = builder.build();
        RegisterApiService registerApiService = retrofit.create( RegisterApiService.class );
        return RegisterApi.getRegisterApi(registerApiService);
    }

    @Provides
    GetCartApi provideGetCartApi(Retrofit.Builder builder) {
        Retrofit retrofit = builder.build();
        GetCartApiService getCartApiService = retrofit.create(GetCartApiService.class);
        return GetCartApi.getGetCartApi(getCartApiService);
    }

    @Provides
    UpdateCartApi provideUpdateCartApi(Retrofit.Builder builder) {
        Retrofit retrofit = builder.build();
        UpdateCartApiService updateCartApiService = retrofit.create(UpdateCartApiService.class);
        return UpdateCartApi.getUpdateCartApi(updateCartApiService);
    }

    @Provides
    DeleteCartApi provideDeleteCartApi(Retrofit.Builder builder) {
        Retrofit retrofit = builder.build();
        DeleteCartApiService deleteCartApiService = retrofit.create(DeleteCartApiService.class);
        return DeleteCartApi.getDeleteCartApi(deleteCartApiService);
    }
}

contract文件夹下ClassifyContract

import com.bwie.test.bean.CatagoryBean;
import com.bwie.test.bean.ProductCatagoryBean;
import com.bwie.test.mysimulation.base.BaseContract;

public interface ClassifyContract {
    interface View extends BaseContract.BaseView{
        void getProductCatagorySuccess(ProductCatagoryBean productCatagoryBean);
        void getCatagorySuccess(CatagoryBean catagoryBean);
    }

    interface Presenter extends BaseContract.BasePresenter<View>{
        void getProductCatagory(String cid);
        void getCatagory();
    }
}

LoginContract

import com.bwie.test.bean.UserBean;
import com.bwie.test.mysimulation.base.BaseContract;

public interface LoginContract {
    interface View extends BaseContract.BaseView {
        void loginSuccess(UserBean userBean);
//        void getLoginSuccessByQQ(UserBean userBean, String ni_cheng, String iconurl);
    }

    interface Presenter extends BaseContract.BasePresenter<View> {
        void login(String mobile, String password);
//        void onSuccessByQQ( UserBean userBean, String ni_cheng, String iconurl);
    }
}

RegisterContract

import com.bwie.test.bean.RegisterBean;
import com.bwie.test.mysimulation.base.BaseContract;

public interface RegisterContract {
    interface View extends BaseContract.BaseView{
        void registerSuccess(RegisterBean registerBean);
    }

    interface Presenter extends BaseContract.BasePresenter<View>{
        void register(String mobile, String password);
    }
}

ShopcartContract

import com.bwie.test.bean.GetCartsBean;
import com.bwie.test.bean.SellerBean;
import com.bwie.test.mysimulation.base.BaseContract;

import java.util.List;

public interface ShopcartContract {
    interface View extends BaseContract.BaseView{
        void showCartList(List<SellerBean> groupList, List<List<GetCartsBean.DataBean.ListBean>> childList);
        void updateCartsSuccess(String msg);
        void deleteCartSuccess(String msg);
    }

    interface Presenter extends BaseContract.BasePresenter<View>{
        void getCarts(String uid, String token);
        void updateCarts(String uid, String sellerid, String pid, String num, String selected, String token);
        void deleteCart(String uid, String pid, String token);
    }
}

presenter文件夹下ClassifyPresenter

import com.bwie.test.bean.CatagoryBean;
import com.bwie.test.bean.ProductCatagoryBean;
import com.bwie.test.mysimulation.base.BasePresenter;
import com.bwie.test.mysimulation.classify.contract.ClassifyContract;
import com.bwie.test.net.CatagoryApi;
import com.bwie.test.net.ProductCatagoryApi;

import javax.inject.Inject;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class ClassifyPresenter extends BasePresenter<ClassifyContract.View> implements 
                          ClassifyContract.Presenter{
    private ProductCatagoryApi productCatagoryApi;
    private CatagoryApi catagoryApi;

    @Inject
    public ClassifyPresenter(ProductCatagoryApi productCatagoryApi, CatagoryApi catagoryApi) {
        this.productCatagoryApi = productCatagoryApi;
        this.catagoryApi = catagoryApi;
    }

    @Override
    public void getProductCatagory(String cid) {
        productCatagoryApi.getProductCatagory(cid)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<ProductCatagoryBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(ProductCatagoryBean productCatagoryBean) {
                        if (mView != null){
                            mView.getProductCatagorySuccess(productCatagoryBean);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    @Override
    public void getCatagory() {
        catagoryApi.getCatagort()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<CatagoryBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(CatagoryBean catagoryBean) {
                        if (mView != null){
                            mView.getCatagorySuccess(catagoryBean);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}

LoginPresenter

import com.bwie.test.bean.UserBean;
import com.bwie.test.mysimulation.base.BasePresenter;
import com.bwie.test.mysimulation.myfragment.contract.LoginContract;
import com.bwie.test.net.LoginApi;

import javax.inject.Inject;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class LoginPresenter extends BasePresenter<LoginContract.View> 
                      implements LoginContract.Presenter {
    private LoginApi loginApi;

    @Inject
    public LoginPresenter(LoginApi loginApi) {
        this.loginApi = loginApi;
    }

    @Override
    public void login(String mobile, String password) {
        loginApi.login(mobile, password)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<UserBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(UserBean userBean) {
                        mView.loginSuccess(userBean);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}

RegisterPresenter

import com.bwie.test.bean.RegisterBean;
import com.bwie.test.mysimulation.base.BasePresenter;
import com.bwie.test.mysimulation.myfragment.contract.RegisterContract;
import com.bwie.test.net.RegisterApi;

import javax.inject.Inject;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class RegisterPresenter extends BasePresenter<RegisterContract.View> 
                     implements RegisterContract.Presenter {
    private RegisterApi registerApi;

    @Inject
    public RegisterPresenter(RegisterApi registerApi) {
        this.registerApi = registerApi;
    }

    @Override
    public void register(String mobile, String password) {
        registerApi.register(mobile, password)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<RegisterBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(RegisterBean registerBean) {
                        mView.registerSuccess(registerBean);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}

ShopcartPresenter

import com.bwie.test.bean.BaseBean;
import com.bwie.test.bean.GetCartsBean;
import com.bwie.test.bean.SellerBean;
import com.bwie.test.mysimulation.base.BasePresenter;
import com.bwie.test.mysimulation.shopfragment.contract.ShopcartContract;
import com.bwie.test.net.DeleteCartApi;
import com.bwie.test.net.GetCartApi;
import com.bwie.test.net.UpdateCartApi;

import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;

public class ShopcartPresenter extends BasePresenter<ShopcartContract.View> 
                      implements ShopcartContract.Presenter {
    private GetCartApi getCartApi;
    private UpdateCartApi updateCartApi;
    private DeleteCartApi deleteCartApi;

    @Inject
    public ShopcartPresenter(GetCartApi getCartApi, UpdateCartApi updateCartApi, 
                       DeleteCartApi deleteCartApi) {
        this.getCartApi = getCartApi;
        this.updateCartApi = updateCartApi;
        this.deleteCartApi = deleteCartApi;
    }

    @Override
    public void getCarts(String uid, String token) {
        getCartApi.getCatagory(uid, token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<GetCartsBean>() {
                    @Override
                    public void accept(GetCartsBean getCartsBean) throws Exception {
                        List<SellerBean> groupList = new ArrayList<>();//用于封装一级列表
                        List<List<GetCartsBean.DataBean.ListBean>> childList = new ArrayList<>();
                        List<GetCartsBean.DataBean> data = getCartsBean.getData();
                        if (data == null) {
                            return;
                        }
                        for (int i = 0; i < data.size(); i++) {
                            GetCartsBean.DataBean dataBean = data.get(i);
                            SellerBean sellerBean = new SellerBean();
                            sellerBean.setSellerName(dataBean.getSellerName());
                            sellerBean.setSellerid(dataBean.getSellerid());
                            sellerBean.setSelected(isSellerProductAllSelect(dataBean));
                            //true或者false要根据该商家下面的商品是否全选
                            groupList.add(sellerBean);

                            List<GetCartsBean.DataBean.ListBean> list = dataBean.getList();
                            childList.add(list);
                        }
                        if (mView != null) {
                            mView.showCartList(groupList, childList);
                        }
                    }
                });
    }

    @Override
    public void updateCarts(String uid, String sellerid, String pid, String num, String selected,
                          String token) {
        updateCartApi.updateCarts(uid, sellerid, pid, num, selected, token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .map(new Function<BaseBean, String>() {
                    @Override
                    public String apply(BaseBean baseBean) throws Exception {
                        return baseBean.getMsg();
                    }
                }).subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {
                if (mView != null) {
                    mView.updateCartsSuccess(s);
                }
            }
        });
    }

    @Override
    public void deleteCart(String uid, String pid, String token) {
        deleteCartApi.deleteCart(uid, pid, token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .map(new Function<BaseBean, String>() {
                    @Override
                    public String apply(BaseBean baseBean) throws Exception {
                        return baseBean.getMsg();
                    }
                }).subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {
                if (mView != null) {
                    mView.updateCartsSuccess(s);
                }
            }
        });
    }

    /**
     * 判断该商家下面的商品是否全选
     * @return
     */
    private boolean isSellerProductAllSelect(GetCartsBean.DataBean dataBean) {
        //获取该商家下面的所有商品
        List<GetCartsBean.DataBean.ListBean> list = dataBean.getList();
        for (int i = 0; i < list.size(); i++) {
            GetCartsBean.DataBean.ListBean listBean = list.get(i);
            if (0 == listBean.getSelected()) {
                //如果是0的话,表示有一个商品未选中
                return false;
            }
        }
        return true;
    }
}

adapter文件夹下ElvAdapter

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import com.bwie.test.bean.ProductCatagoryBean;
import com.bwie.test.inter.OnItemClickListener;
import com.bwie.test.mysimulation.R;
import java.util.List;

public class ElvAdapter extends BaseExpandableListAdapter {
    private Context context;
    private List<String> groupList;
    private List<List<ProductCatagoryBean.DataBean.ListBean>> childList;
    private LayoutInflater inflater;

    public ElvAdapter(Context context, List<String> groupList, List<List
                             <ProductCatagoryBean.DataBean.ListBean>> childList) {
        this.context = context;
        this.groupList = groupList;
        this.childList = childList;
        inflater = LayoutInflater.from(context);
    }

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

    @Override
    public int getChildrenCount(int groupPosition) {
        //因为二级列表是一个RecylerView,所以返回1即可
        return 1;
    }

    @Override
    public Object getGroup(int groupPosition) {
        return groupList.get(groupPosition);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return childList.get(groupPosition).get(childPosition);
    }

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

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

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

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        GroupViewHolder groupViewHolder;
        if (convertView == null) {
            groupViewHolder = new GroupViewHolder();
            convertView = inflater.inflate(R.layout.rvleft_item, null);
            groupViewHolder.tv = convertView.findViewById(R.id.tv);
            convertView.setTag(groupViewHolder);
        } else {
            groupViewHolder = (GroupViewHolder) convertView.getTag();
        }
        //显示数据
        groupViewHolder.tv.setText(groupList.get(groupPosition));
        return convertView;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, 
                          View convertView, ViewGroup parent) {
        ChildViewHolder childViewHolder;
        if (convertView == null) {
            childViewHolder = new ChildViewHolder();
            convertView = inflater.inflate(R.layout.elv_rv, null);
            childViewHolder.rv = convertView.findViewById(R.id.rv);
            convertView.setTag(childViewHolder);
        } else {
            childViewHolder = (ChildViewHolder) convertView.getTag();
        }
        //显示数据
        final List<ProductCatagoryBean.DataBean.ListBean> listBeans = childList.get(groupPosition);
        //设置布局管理器
        childViewHolder.rv.setLayoutManager(new GridLayoutManager(context, 3));
        //设置适配器
        ElvRvAdapter elvRvAdapter = new ElvRvAdapter(context, listBeans);
        childViewHolder.rv.setAdapter(elvRvAdapter);
        elvRvAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                //点击跳转到列表页面
//                Intent intent = new Intent(context, ListsActivity.class);
//                int pscid = listBeans.get(position).getPscid();
//                intent.putExtra("pscid", pscid);
//                context.startActivity(intent);
            }

            @Override
            public void onLongItemClick(int position) {

            }
        });
        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    class GroupViewHolder {
        TextView tv;
    }

    class ChildViewHolder {
        RecyclerView rv;
    }
}

ElvRvAdapter

import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bwie.test.bean.ProductCatagoryBean;
import com.bwie.test.inter.OnItemClickListener;
import com.bwie.test.mysimulation.R;
import java.util.List;

public class ElvRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    private Context context;
    private List<ProductCatagoryBean.DataBean.ListBean> listBeans;
    private LayoutInflater inflater;
    private OnItemClickListener onItemClickListener;

    public ElvRvAdapter(Context context, List<ProductCatagoryBean.DataBean.ListBean> listBeans) {
        this.context = context;
        this.listBeans = listBeans;
        inflater = LayoutInflater.from(context);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.rvclass_item, parent, false);
        ElvRvAdapterViewHolder elvRvAdapterViewHolder = new ElvRvAdapterViewHolder(view);
        return elvRvAdapterViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) {
        ElvRvAdapterViewHolder elvRvAdapterViewHolder = (ElvRvAdapterViewHolder) holder;
        ProductCatagoryBean.DataBean.ListBean listBean = listBeans.get(position);
        //Glide.with(context).load(listBean.getIcon()).into(elvRvAdapterViewHolder.iv);
        String url = listBean.getIcon();
        elvRvAdapterViewHolder.iv.setImageURI(Uri.parse(url));
        elvRvAdapterViewHolder.tv.setText(listBean.getName());

        //给条目设置点击事件
        elvRvAdapterViewHolder.line_layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null) {
                    onItemClickListener.onItemClick(position);
                }
            }
        });
    }

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

    class ElvRvAdapterViewHolder extends RecyclerView.ViewHolder {
        private final ImageView iv;
        private final TextView tv;
        private final LinearLayout line_layout;

        public ElvRvAdapterViewHolder(View itemView) {
            super(itemView);
            line_layout = itemView.findViewById(R.id.line_layout);
            iv = itemView.findViewById(R.id.iv);
            tv = itemView.findViewById(R.id.tv);
        }
    }
}

RvLeftAdapter

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bwie.test.bean.CatagoryBean;
import com.bwie.test.inter.OnItemClickListener;
import com.bwie.test.mysimulation.R;
import java.util.List;

public class RvLeftAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context;
    private List<CatagoryBean.DataBean> list;
    private LayoutInflater inflater;
    private OnItemClickListener onItemClickListener;

    public RvLeftAdapter(Context context, List<CatagoryBean.DataBean> list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.rvleft_item, parent, false);
        LeftViewHolder leftViewHolder=new LeftViewHolder(view);
        return leftViewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        CatagoryBean.DataBean dataBean = list.get(position);
        LeftViewHolder leftViewHolder = (LeftViewHolder) holder;
        leftViewHolder.tv.setText(dataBean.getName());
        //设置字体颜色
        if (dataBean.getChecked()) {
            leftViewHolder.tv.setTextColor(Color.RED);
            leftViewHolder.tv.setBackgroundColor(Color.LTGRAY);
        } else {
            leftViewHolder.tv.setTextColor(Color.BLACK);
            leftViewHolder.tv.setBackgroundColor(Color.WHITE);
        }

        leftViewHolder.tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null) {
                    onItemClickListener.onItemClick(position);
                }
            }
        });
    }

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

    class LeftViewHolder extends RecyclerView.ViewHolder {
        private final TextView tv;

        public LeftViewHolder(View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.tv);
        }
    }

    /**
     * 选中后,改变字体颜色和背景色
     * @param position
     * @param bool
     */
    public void changeCheck(int position, boolean bool) {
        //先还原一下
        for (int i = 0;i<list.size();i++){
            list.get(i).setChecked(false);
        }
        CatagoryBean.DataBean dataBean = list.get(position);
        dataBean.setChecked(bool);
        //刷新界面
        notifyDataSetChanged();
    }
}

ElvShopcartAdapter

import android.app.ProgressDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bwie.test.bean.GetCartsBean;
import com.bwie.test.bean.SellerBean;
import com.bwie.test.mysimulation.R;
import com.bwie.test.mysimulation.shopfragment.presenter.ShopcartPresenter;
import com.bwie.test.utils.AddSubView;
import com.bwie.test.utils.SharedPreferencesUtils;
import java.util.ArrayList;
import java.util.List;

public class ElvShopcartAdapter extends BaseExpandableListAdapter {
    private Context context;
    private List<SellerBean> groupList;
    private List<List<GetCartsBean.DataBean.ListBean>> childList;
    private LayoutInflater inflater;
    private final String uid;
    private final String token;
    private ProgressDialog progressDialog;
    private int productIndex;
    private int groupPosition;
    private boolean checked;
    private static final int GETCARTS = 0;//查询购物车
    private static final int UPDATE_PRODUCT = 1; //更新商品
    private static final int UPDATE_SELLER = 2; //更新卖家
    private static int state = GETCARTS;
    private boolean allSelected;
    private ShopcartPresenter shopcartPresenter;

    public ElvShopcartAdapter(Context context, List<SellerBean> groupList, List<List
                       <GetCartsBean.DataBean.ListBean>>
            childList, ShopcartPresenter shopcartPresenter, ProgressDialog progressDialog) {
        this.context = context;
        this.groupList = groupList;
        this.childList = childList;
        inflater = LayoutInflater.from(context);
        this.shopcartPresenter = shopcartPresenter;

        uid = (String) SharedPreferencesUtils.getParam(context, "uid", "");
        token = (String) SharedPreferencesUtils.getParam(context, "token", "");
        //初始化进度对话框
        this.progressDialog = progressDialog;
    }

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

    @Override
    public int getChildrenCount(int groupPosition) {
        return childList.get(groupPosition).size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return groupList.get(groupPosition);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return childList.get(groupPosition).get(childPosition);
    }

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

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

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

    @Override
    public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, 
                       ViewGroup parent) {
        final GroupViewHolder groupViewHolder;
        if (convertView == null) {
            groupViewHolder = new GroupViewHolder();
            convertView = inflater.inflate(R.layout.shopcart_seller_item, null);
            groupViewHolder.cbSeller = convertView.findViewById(R.id.cbSeller);
            groupViewHolder.tvSeller = convertView.findViewById(R.id.tvSeller);
            convertView.setTag(groupViewHolder);
        } else {
            groupViewHolder = (GroupViewHolder) convertView.getTag();
        }
        //设置值
        SellerBean sellerBean = groupList.get(groupPosition);
        groupViewHolder.tvSeller.setText(sellerBean.getSellerName());
        groupViewHolder.cbSeller.setChecked(sellerBean.isSelected());

        //给商家checkbox设置点击事件
        groupViewHolder.cbSeller.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //设置当前的更新状态
                state = UPDATE_PRODUCT;
                //显示进度条
                progressDialog.show();
                //默认从第一个商品开始更新购物车状态
                productIndex = 0;
                //全局记录一下当前更新的商家
                ElvShopcartAdapter.this.groupPosition = groupPosition;
                //该商家是否选中
                checked = groupViewHolder.cbSeller.isChecked();
                //更新商家下的商品状态
                updateProductInSeller();
            }
        });
        return convertView;
    }

    @Override
    public View getChildView(final int groupPosition, int childPosition, boolean isLastChild,
                      View convertView, ViewGroup parent) {
        final ChildViewHolder childViewHolder;
        if (convertView == null) {
            childViewHolder = new ChildViewHolder();
            convertView = inflater.inflate(R.layout.shopcart_seller_product_item, null);
            childViewHolder.cbProduct = convertView.findViewById(R.id.cbProduct);
            childViewHolder.iv = convertView.findViewById(R.id.iv);
            childViewHolder.tvTitle = convertView.findViewById(R.id.tvTitle);
            childViewHolder.tvPrice = convertView.findViewById(R.id.tvPrice);
            childViewHolder.tvDel = convertView.findViewById(R.id.tvDel);
            childViewHolder.addSubView = convertView.findViewById(R.id.addSubCard);
            convertView.setTag(childViewHolder);
        } else {
            childViewHolder = (ChildViewHolder) convertView.getTag();
        }

        final GetCartsBean.DataBean.ListBean listBean = childList.get(groupPosition).get(childPosition);
        //根据服务器返回的select值,给checkBox设置是否选中
        childViewHolder.cbProduct.setChecked(listBean.getSelected() == 1 ? true : false);
        childViewHolder.tvTitle.setText(listBean.getTitle());
        childViewHolder.tvPrice.setText(listBean.getPrice() + "");
        Glide.with(context).load(listBean.getImages().split("\\|")[0]).into(childViewHolder.iv);
        childViewHolder.addSubView.setNum(listBean.getNum() + "");
        //给二级列表的checkbox设置点击事件
        childViewHolder.cbProduct.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                state = GETCARTS;
                //显示进度条
                progressDialog.show();
                ElvShopcartAdapter.this.groupPosition = groupPosition;
                //调用更新购物车接口,改变购物车的状态
                //获取卖家id
                String sellerid = groupList.get(groupPosition).getSellerid();
                //获取pid
                String pid = listBean.getPid() + "";
                //是否选中
                boolean childChecked = childViewHolder.cbProduct.isChecked();

                shopcartPresenter.updateCarts(uid, sellerid, pid, "1", childChecked ? "1" : "0", token);
            }
        });

        //给加号设置点击事件
        childViewHolder.addSubView.setAddOnclickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressDialog.show();
                state = GETCARTS;
                //获取sellerId
                String sellerid = groupList.get(groupPosition).getSellerid();
                //获取pid
                int pid = listBean.getPid();
                //获取数量
                int num = listBean.getNum();
                num += 1;
                //是否选中
                String isChecked = childViewHolder.cbProduct.isChecked() ? "1" : "0";
                //调用更新购物车的接口即可
                shopcartPresenter.updateCarts(uid, sellerid, pid + "", num + "", isChecked, token);
            }
        });

        //给减号设置点击事件
        childViewHolder.addSubView.setSubOnclickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressDialog.show();
                state = GETCARTS;
                //获取当前商品的数量
                int num = listBean.getNum();
                if (num <= 1) {
                    progressDialog.dismiss();
                    Toast.makeText(context, "数量不能小于1", Toast.LENGTH_SHORT).show();
                    return;
                }
                num -= 1;
                //获取sellerId
                String sellerid = groupList.get(groupPosition).getSellerid();
                //获取pid
                int pid = listBean.getPid();
                //是否选中
                String isChecked = childViewHolder.cbProduct.isChecked() ? "1" : "0";
                //更新购物车
                shopcartPresenter.updateCarts(uid, sellerid, pid + "", num + "", isChecked, token);
            }
        });

        //给删除设置点击事件
        childViewHolder.tvDel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressDialog.show();
                state = GETCARTS;
                //获取pid
                int pid = listBean.getPid();
                //删除购物车里的选项
                shopcartPresenter.deleteCart(uid, pid + "", token);
            }
        });
        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }

    //删除成功回调接口
    public void delSuccess() {
        shopcartPresenter.getCarts(uid, token);
    }

    class GroupViewHolder {
        CheckBox cbSeller;
        TextView tvSeller;
    }

    class ChildViewHolder {
        CheckBox cbProduct;
        ImageView iv;
        TextView tvTitle;
        TextView tvPrice;
        TextView tvDel;
        AddSubView addSubView;
    }

    //更新购物车成功回调的方法
    public void updataSuccess() {
        switch (state) {
            case GETCARTS:
                //更新成功以后调用查询购物车接口
                productIndex = 0;
                groupPosition = 0;
                shopcartPresenter.getCarts(uid, token);
                break;
            case UPDATE_PRODUCT:
                //更新成功一个商品以后,再接着更新该商家下面的其它商品,直到没有商品为止
                productIndex++;
                //下标是否越界
                if (productIndex < childList.get(groupPosition).size()) {
                    //可以继续跟新商品
                    updateProductInSeller();
                } else {
                    //商品已经全部更新完成,请查询购物车
                    state = GETCARTS;
                    updataSuccess();
                }
                break;
            case UPDATE_SELLER:
                //遍历所有商家下的商品,并更新状态
                productIndex++;
                //下标是否越界
                if (productIndex < childList.get(groupPosition).size()) {
                    //可以继续跟新商品
                    updateProductInSeller(allSelected);
                } else {
                    //商品已经全部更新完成,请查询购物车
                    productIndex = 0;
                    groupPosition++;
                    if (groupPosition < groupList.size()) {
                        //可以继续跟新商品
                        updateProductInSeller(allSelected);
                    } else {
                        //商品已经全部更新完成,请查询购物车
                        state = GETCARTS;
                        updataSuccess();
                    }
                }
                break;
        }
    }

    private void updateProductInSeller() {
        //获取SellerId
        SellerBean sellerBean = groupList.get(groupPosition);
        String sellerid = sellerBean.getSellerid();
        //获取pid
        GetCartsBean.DataBean.ListBean listBean = childList.get(groupPosition).get(productIndex);
        int num = listBean.getNum();
        int pid = listBean.getPid();
        shopcartPresenter.updateCarts(uid, sellerid, pid + "", num + "", checked ? "1" : "0", token);
    }

    private void updateProductInSeller(boolean bool) {
        //获取SellerId
        SellerBean sellerBean = groupList.get(groupPosition);
        String sellerid = sellerBean.getSellerid();
        //获取pid
        GetCartsBean.DataBean.ListBean listBean = childList.get(groupPosition).get(productIndex);
        int pid = listBean.getPid();
        int num = listBean.getNum();
        shopcartPresenter.updateCarts(uid, sellerid, pid + "", num + "", bool ? "1" : "0", token);
    }

    /**
     * 计算数量和价钱
     * @return
     */
    public String[] computeMoneyAndNum() {
        double sum = 0;
        int num = 0;
        for (int i = 0; i < groupList.size(); i++) {
            for (int j = 0; j < childList.get(i).size(); j++) {
                //判断商品是否选中
                GetCartsBean.DataBean.ListBean listBean = childList.get(i).get(j);
                if (listBean.getSelected() == 1) {
                    //该商品为选中状态
                    sum += listBean.getPrice() * listBean.getNum();
                    num += listBean.getNum();
                }
            }
        }
        return new String[]{sum + "", num + ""};
    }

    public void changeAllState(boolean bool) {
        this.allSelected = bool;
        state = UPDATE_SELLER;
        //遍历商家下的商品,修改状态
        updateProductInSeller(bool);

    }

    public List<SellerBean> getGroupList() {
        //先创建一个集合
        List<SellerBean> gList = new ArrayList<>();
        //遍历原先的groupList
        for (int i = 0; i < groupList.size(); i++) {
            for (int j = 0;j<childList.get(i).size();j++){
                if (childList.get(i).get(j).getSelected() == 1) {
                    if (!gList.contains(groupList.get(i))){
                        gList.add(groupList.get(i));
                    }
                }
            }
        }
        return gList;
    }

    public List<List<GetCartsBean.DataBean.ListBean>> getchildList() {
        List<List<GetCartsBean.DataBean.ListBean>> cList = new ArrayList<>();
        for (int i = 0; i < groupList.size(); i++) {
            List<GetCartsBean.DataBean.ListBean> l = new ArrayList<>();
            for (int j = 0; j < childList.get(i).size(); j++) {
                if (childList.get(i).get(j).getSelected() == 1) {
                    l.add(childList.get(i).get(j));
                }
            }
            if (l.size()>0){
                cList.add(l);
            }
        }
        return cList;
    }
}

net文件夹下Api

public interface Api {
    String BASEURL = "https://www.zhaoapi.cn/";
}

CatagoryApiService

import com.bwie.test.bean.CatagoryBean;
import io.reactivex.Observable;
import retrofit2.http.GET;

public interface CatagoryApiService {
    @GET("product/getCatagory")
    Observable<CatagoryBean> getCatagory();
}

CatagoryApi

import com.bwie.test.bean.CatagoryBean;
import io.reactivex.Observable;

public class CatagoryApi {
    private static CatagoryApi catagoryApi;
    private CatagoryApiService catagoryApiService;

    public CatagoryApi(CatagoryApiService catagoryApiService) {
        this.catagoryApiService = catagoryApiService;
    }

    public static CatagoryApi getCatagoryApi(CatagoryApiService catagoryApiService){
        if (catagoryApi == null) {
            catagoryApi = new CatagoryApi(catagoryApiService);
        }
        return catagoryApi;
    }

    public Observable<CatagoryBean> getCatagort(){
        return catagoryApiService.getCatagory();
    }
}

DeleteCartApiService

import com.bwie.test.bean.BaseBean;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

public interface DeleteCartApiService {
    @FormUrlEncoded
    @POST("product/deleteCart")
    Observable<BaseBean> deleteCart(@Field("uid") String uid, @Field("pid") String pid, @Field("token") 
               String token);
}

DeleteCartApi

import com.bwie.test.bean.BaseBean;
import io.reactivex.Observable;

public class DeleteCartApi {
    private static DeleteCartApi deleteCartApi;
    private DeleteCartApiService deleteCartApiService;

    private DeleteCartApi(DeleteCartApiService deleteCartApiService) {
        this.deleteCartApiService = deleteCartApiService;
    }

    public static DeleteCartApi getDeleteCartApi(DeleteCartApiService deleteCartApiService) {
        if (deleteCartApi == null) {
            deleteCartApi = new DeleteCartApi(deleteCartApiService);
        }
        return deleteCartApi;
    }

    public Observable<BaseBean> deleteCart(String uid, String pid, String token) {
        return deleteCartApiService.deleteCart(uid, pid, token);
    }
}

GetCartApiService

import com.bwie.test.bean.GetCartsBean;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;

public interface GetCartApiService {
    @FormUrlEncoded
    @POST("product/getCarts")
    Observable<GetCartsBean> getCart(@Field("Uid") String uid, @Field("Token") String token);
}

GetCartApi

package com.bwie.test.net;
import com.bwie.test.bean.GetCartsBean;
import io.reactivex.Observable;

public class GetCartApi {
    private static GetCartApi getCartApi;
    private GetCartApiService getCartApiService;

    private GetCartApi(GetCartApiService getCartApiService) {
        this.getCartApiService = getCartApiService;
    }

    public static GetCartApi getGetCartApi(GetCartApiService getCartApiService) {
        if (getCartApi == null) {
            getCartApi = new GetCartApi(getCartApiService);
        }
        return getCartApi;
    }

    public Observable<GetCartsBean> getCatagory(String uid, String token) {
        return getCartApiService.getCart(uid, token);
    }
}

LoginApiService

import com.bwie.test.bean.UserBean;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

public interface LoginApiService {
    @FormUrlEncoded
    @POST("user/login")
    Observable<UserBean> login(@Field("mobile") String mobile, @Field("password") String password);
}

LoginApi

import com.bwie.test.bean.UserBean;
import io.reactivex.Observable;

public class LoginApi {
    private static LoginApi loginApi;
    private LoginApiService loginApiService;

    private LoginApi(LoginApiService loginApiService) {
        this.loginApiService = loginApiService;
    }

    public static LoginApi getLoginApi(LoginApiService loginApiService) {
        if (loginApi == null) {
            loginApi = new LoginApi(loginApiService);
        }
        return loginApi;
    }

    public Observable<UserBean> login(String mobile, String password) {
        return loginApiService.login(mobile, password);
    }
}

ProductCatagoryApiService

import com.bwie.test.bean.ProductCatagoryBean;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

public interface ProductCatagoryApiService {
    @FormUrlEncoded
    @POST("product/getProductCatagory")
    Observable<ProductCatagoryBean> getProductCatagory(@Field("cid") String cid);
}

ProductCatagoryApi

import com.bwie.test.bean.ProductCatagoryBean;
import io.reactivex.Observable;

public class ProductCatagoryApi {
    private static ProductCatagoryApi productCatagoryApi;
    private ProductCatagoryApiService productCatagoryApiService;

    public ProductCatagoryApi(ProductCatagoryApiService productCatagoryApiService) {
        this.productCatagoryApiService = productCatagoryApiService;
    }

    public static ProductCatagoryApi getProductCatagoryApi(ProductCatagoryApiService 
                productCatagoryApiService){
        if(productCatagoryApi == null){
            productCatagoryApi = new ProductCatagoryApi(productCatagoryApiService);
        }
        return productCatagoryApi;
    }

    public Observable<ProductCatagoryBean> getProductCatagory(String cid){
        return productCatagoryApiService.getProductCatagory(cid);
    }
}

RegisterApiService

import com.bwie.test.bean.RegisterBean;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

public interface RegisterApiService {
    @FormUrlEncoded
    @POST("user/reg")
    Observable<RegisterBean> register(@Field("mobile") String mobile, @Field("password") String password);
}

RegisterApi

import com.bwie.test.bean.RegisterBean;
import io.reactivex.Observable;

public class RegisterApi {
    private static RegisterApi registerApi;
    private RegisterApiService registerApiService;

    public RegisterApi(RegisterApiService registerApiService) {
        this.registerApiService = registerApiService;
    }

    public static RegisterApi getRegisterApi(RegisterApiService registerApiService){
        if (registerApi==null){
            registerApi=new RegisterApi(registerApiService);
        }
        return registerApi;
    }

    public Observable<RegisterBean> register(String mobile, String password){
        return registerApiService.register(mobile,password);
    }
}

UpdateCartApiService

import com.bwie.test.bean.BaseBean;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

public interface UpdateCartApiService {
    @FormUrlEncoded
    @POST("product/updateCarts")
    Observable<BaseBean> updateCarts(@Field("uid") String uid, @Field("sellerid") String sellerid,
                                     @Field("pid") String pid, @Field("num") String num,
                                     @Field("selected") String selected, @Field("token") String token);
}

UpdateCartApi

import com.bwie.test.bean.BaseBean;
import io.reactivex.Observable;

public class UpdateCartApi {
    private static UpdateCartApi updateCartApi;
    private UpdateCartApiService updateCartApiService;

    private UpdateCartApi(UpdateCartApiService updateCartApiService) {
        this.updateCartApiService = updateCartApiService;
    }

    public static UpdateCartApi getUpdateCartApi(UpdateCartApiService updateCartApiService) {
        if (updateCartApi == null) {
            updateCartApi = new UpdateCartApi(updateCartApiService);
        }
        return updateCartApi;
    }

    public Observable<BaseBean> updateCarts(String uid, String sellerid, String pid, String num, 
             String selected, String token) {
        return updateCartApiService.updateCarts(uid, sellerid, pid, num, selected, token);
    }
}

utils文件夹下AddSubView

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bwie.test.mysimulation.R;

public class AddSubView extends LinearLayout {
    private TextView sub;
    private TextView num;
    private TextView add;

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

    public AddSubView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(context).inflate( R.layout.add_sub_view, this);
        sub = findViewById(R.id.child_text_jian);
        num = findViewById(R.id.child_text_num);
        add = findViewById(R.id.child_text_add);
    }

    /**
     * 设置数量
     * @param str
     */
    public void setNum(String str) {
        num.setText(str);
    }

    /**
     * 获取数量
     *
     * @return
     */
    public String getNum() {
        return num.getText().toString();
    }

    /**
     * 给加号设置点击事件
     * @param onclickListener
     */
    public void setAddOnclickListener(OnClickListener onclickListener) {
        add.setOnClickListener(onclickListener);
    }

    /**
     * 给减号设置点击事件
     * @param onclickListener
     */
    public void setSubOnclickListener(OnClickListener onclickListener) {
        sub.setOnClickListener(onclickListener);
    }
}

DialogUtil

import android.app.ProgressDialog;
import android.content.Context;

public class DialogUtil {
    public static ProgressDialog getProgressDialog(Context context) {
        ProgressDialog progressDialog = new ProgressDialog(context);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage("正在加载...");
        progressDialog.setCancelable(false);
        return progressDialog;
    }
}

GlideImageLoader

import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.youth.banner.loader.ImageLoader;

public class GlideImageLoader extends ImageLoader {
    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        //Glide 加载图片简单用法
        Glide.with(context).load(path).into(imageView);
    }
}

MyInterceptor

import java.io.IOException;
import okhttp3.FormBody;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import retrofit2.http.FormUrlEncoded;

public class MyInterceptor implements Interceptor {
    private Response response;
    @Override
    public Response intercept(Chain chain) throws IOException {
        //区分是GET请求还是POST请求
        Request originRequest = chain.request();
        if ("GET".equals(originRequest.method())) {
            HttpUrl httpUrl = originRequest.url()
                    .newBuilder()
                    .addQueryParameter("source", "android")
                    .addQueryParameter("appVersion","101")
                    .build();
            Request request = new Request.Builder().url(httpUrl).build();
            //发送请求
            response = chain.proceed(request);
        } else if ("POST".equals(originRequest.method())) {
            //POST请求
            FormBody.Builder builder = new FormBody.Builder();
            //获取原始的请求体里的参数
            RequestBody body1 = originRequest.body();
            if(body1 instanceof FormBody){
            FormBody formBody = (FormBody) originRequest.body();
            //遍历原始的请求体里的参数
            for (int i = 0; i < formBody.size(); i++) {
                builder.add(formBody.name(i), formBody.value(i));
            }
            //添加新参数
            builder.add("source", "android");
            builder.add("appVersion","101");
            FormBody body = builder.build();
            //添加请求的参数
            Request request = originRequest.newBuilder()
                    .url(originRequest.url())
                    .post(body)
                    .build();
            response = chain.proceed(request);
            } else {
                response = chain.proceed(originRequest);
            }
        } else{
            response = chain.proceed(originRequest);
        }
        return response;
    }
}

SharedPreferencesUtils

package com.bwie.test.utils;
import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUtils {
   /**
    * 保存在手机里面的文件名
    */
   private static final String FILE_NAME = "share_date";

   /**
    * 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法
    * @param context
    * @param key
    * @param object 
    */
   public static void setParam(Context context , String key, Object object){
      String type = object.getClass().getSimpleName();
      SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
      SharedPreferences.Editor editor = sp.edit();
      
      if("String".equals(type)){
         editor.putString(key, (String)object);
      }
      else if("Integer".equals(type)){
         editor.putInt(key, (Integer)object);
      }
      else if("Boolean".equals(type)){
         editor.putBoolean(key, (Boolean)object);
      }
      else if("Float".equals(type)){
         editor.putFloat(key, (Float)object);
      }
      else if("Long".equals(type)){
         editor.putLong(key, (Long)object);
      }
      
      editor.commit();
   }

   /**
    * 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
    * @param context
    * @param key
    * @param defaultObject
    * @return
    */
   public static Object getParam(Context context , String key, Object defaultObject){
      String type = defaultObject.getClass().getSimpleName();
      SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
      
      if("String".equals(type)){
         return sp.getString(key, (String)defaultObject);
      }
      else if("Integer".equals(type)){
         return sp.getInt(key, (Integer)defaultObject);
      }
      else if("Boolean".equals(type)){
         return sp.getBoolean(key, (Boolean)defaultObject);
      }
      else if("Float".equals(type)){
         return sp.getFloat(key, (Float)defaultObject);
      }
      else if("Long".equals(type)){
         return sp.getLong(key, (Long)defaultObject);
      }
      return null;
   }

   public static void clear(Context context){
      SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
      sp.edit().clear().commit();
   }
}

eventbus文件夹下MessageEvent

import com.bwie.test.bean.GetCartsBean;
import com.bwie.test.bean.SellerBean;
import java.util.List;

public class MessageEvent {
    private List<SellerBean> gList;
    private List<List<GetCartsBean.DataBean.ListBean>> cList;

    public List<SellerBean> getgList() {
        return gList;
    }

    public void setgList(List<SellerBean> gList) {
        this.gList = gList;
    }

    public List<List<GetCartsBean.DataBean.ListBean>> getcList() {
        return cList;
    }

    public void setcList(List<List<GetCartsBean.DataBean.ListBean>> cList) {
        this.cList = cList;
    }
}

bean文件夹下BaseBean

public class BaseBean {

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

CatagoryBean

import java.util.List;

public class CatagoryBean {
    private String msg;
    private String code;
    private List<DataBean> data;

    public String getMsg() {
        return msg;
    }

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

    public String getCode() {
        return code;
    }

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

    public List<DataBean> getData() {
        return data;
    }

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

    public static class DataBean {
        
        private int cid;
        private String createtime;
        private String icon;
        private int ishome;
        private String name;
        private boolean checked;//表示是否选中

        public boolean getChecked() {
            return checked;
        }

        public void setChecked(boolean checked) {
            this.checked = checked;
        }

        public int getCid() {
            return cid;
        }

        public void setCid(int cid) {
            this.cid = cid;
        }

        public String getCreatetime() {
            return createtime;
        }

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

        public String getIcon() {
            return icon;
        }

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

        public int getIshome() {
            return ishome;
        }

        public void setIshome(int ishome) {
            this.ishome = ishome;
        }

        public String getName() {
            return name;
        }

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

GetCartsBean

import java.util.List;

public class GetCartsBean {

    private String msg;
    private String code;
    private List<DataBean> data;

    public String getMsg() {
        return msg;
    }

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

    public String getCode() {
        return code;
    }

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

    public List<DataBean> getData() {
        return data;
    }

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

    public static class DataBean {
        private String sellerName;
        private String sellerid;
        private List<ListBean> list;


        public String getSellerName() {
            return sellerName;
        }

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

        public String getSellerid() {
            return sellerid;
        }

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

        public List<ListBean> getList() {
            return list;
        }

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

        public static class ListBean {

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

ProductCatagoryBean

import java.util.List;

public class ProductCatagoryBean {
  
    private String msg;
    private String code;
    private List<DataBean> data;

    public String getMsg() {
        return msg;
    }

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

    public String getCode() {
        return code;
    }

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

    public List<DataBean> getData() {
        return data;
    }

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

    public static class DataBean {
        private String cid;
        private String name;
        private String pcid;
        private List<ListBean> list;

        public String getCid() {
            return cid;
        }

        public void setCid(String cid) {
            this.cid = cid;
        }

        public String getName() {
            return name;
        }

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

        public String getPcid() {
            return pcid;
        }

        public void setPcid(String pcid) {
            this.pcid = pcid;
        }

        public List<ListBean> getList() {
            return list;
        }

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

        public static class ListBean {

            private String icon;
            private String name;
            private int pcid;
            private int pscid;

            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 getPcid() {
                return pcid;
            }

            public void setPcid(int pcid) {
                this.pcid = pcid;
            }

            public int getPscid() {
                return pscid;
            }

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

RegisterBean

public class RegisterBean {

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

SellerBean

import java.io.Serializable;

public class SellerBean implements Serializable{
    private String sellerName;
    private String sellerid;
    private boolean selected;//商家是否选中

    public boolean isSelected() {
        return selected;
    }

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

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

UserBean

public class UserBean {

    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 {
        private Object age;
        private String appkey;
        private String appsecret;
        private String createtime;
        private Object email;
        private Object fans;
        private Object follow;
        private Object gender;
        private Object icon;
        private Object latitude;
        private Object longitude;
        private String mobile;
        private Object money;
        private Object nickname;
        private String password;
        private Object praiseNum;
        private String token;
        private int uid;
        private Object userId;
        private String username;

        public Object getAge() {
            return age;
        }

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

        public String getAppkey() {
            return appkey;
        }

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

        public String getAppsecret() {
            return appsecret;
        }

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

        public String getCreatetime() {
            return createtime;
        }

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

        public Object getEmail() {
            return email;
        }

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

        public Object getFans() {
            return fans;
        }

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

        public Object getFollow() {
            return follow;
        }

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

        public Object getGender() {
            return gender;
        }

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

        public Object getIcon() {
            return icon;
        }

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

        public Object getLatitude() {
            return latitude;
        }

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

        public Object getLongitude() {
            return longitude;
        }

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

        public String getMobile() {
            return mobile;
        }

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

        public Object getMoney() {
            return money;
        }

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

        public Object getNickname() {
            return nickname;
        }

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

        public String getPassword() {
            return password;
        }

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

        public Object getPraiseNum() {
            return praiseNum;
        }

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

        public String getToken() {
            return token;
        }

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

        public int getUid() {
            return uid;
        }

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

        public Object getUserId() {
            return userId;
        }

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

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值