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

微笑微笑微笑效果图

微笑微笑微笑添加依赖

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.samsung.yuekaolianxi"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.jakewharton:butterknife:8.8.1'
    compile 'org.greenrobot:greendao:3.2.2'
    compile 'org.greenrobot:greendao-generator:3.0.0'
    compile 'com.facebook.fresco:fresco:0.12.0'
    compile 'org.greenrobot:eventbus:3.1.1'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    compile 'io.reactivex.rxjava2:rxjava:2.1.7'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
微笑 微笑 微笑 添加权限

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.samsung.yuekaolianxi">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".view.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".view.RegistActivity" />
        <activity android:name=".view.ListActivity" />
        <activity android:name=".view.GoodsActivity" />
        <activity android:name=".view.GoodsShopActivity"></activity>
    </application>

</manifest>
微笑 微笑 微笑 values   下  attrs    布局

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="AddDeleteViewStyle">
        <attr name="left_text" format="string"/>
        <attr name="right_text" format="string"/>
        <attr name="middle_text" format="string"/>
    </declare-styleable>
</resources>
微笑 微笑 微笑 layout    下   activity_goods    布局

<?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"
    xmlns:fresco="http://schemas.android.com/apk/res-auto"
    tools:context="com.example.samsung.yuekaolianxi.view.GoodsActivity">
    <LinearLayout
        android:orientation="vertical"
        android:padding="20dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/img"
        fresco:placeholderImage="@mipmap/ic_launcher"
        android:layout_width="match_parent"
        android:layout_height="200dp" />
        <TextView
            android:layout_marginTop="10dp"
            android:text="萨达是打算大所大是打算大所大 "
            android:id="@+id/goods_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="1555"
            android:layout_marginTop="10dp"

            android:id="@+id/goods_price"
            android:textColor="#f00"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/btn_add"
            android:background="#f00"
            android:text="加入购物车"
            android:layout_weight="1"
            android:textColor="#fff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:id="@+id/btn_into"
            android:text="购物车"
            android:textColor="#fff"

            android:background="#ffc400"
            android:layout_weight="1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</RelativeLayout>
微笑 微笑 微笑 layout   下  activity_goods_shop   布局

<?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"
    >
    <LinearLayout
        android:id="@+id/top_bar"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:orientation="vertical" >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/back"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_alignParentLeft="true"
                android:layout_gravity="center_vertical"
                android:layout_marginTop="10dp"
                android:src="@mipmap/leftjiantou" />
            <TextView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:minHeight="48dp"
                android:text="购物车"
                android:textColor="#1a1a1a"
                android:textSize="16sp" />

            <TextView
                android:id="@+id/subtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="20dp"
                android:gravity="center"
                android:minHeight="48dp"
                android:text="编辑"
                android:textColor="#1a1a1a"
                android:textSize="14sp"
                android:visibility="visible" />
        </RelativeLayout>
    </LinearLayout>
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
        <LinearLayout
            android:id="@+id/ll_cart"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"

            >
            <ExpandableListView
                android:id="@+id/exListView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:childIndicator="@null"
                android:groupIndicator="@null" >
            </ExpandableListView>

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

                <CheckBox
                    android:id="@+id/all_chekbox"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_gravity="center_vertical"
                    android:layout_marginRight="4dp"
                    android:gravity="center"
                    android:focusable="false"
                    android:layout_marginLeft="10dp"
                    android:text="全选"
                    />
                <LinearLayout
                    android:id="@+id/ll_info"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="4"
                    >
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:layout_marginRight="20dp"
                        android:layout_weight="1"
                        >
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:gravity="right"
                            >
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="5dp"
                                android:text="合计:"
                                android:textSize="18sp"
                                android:textStyle="bold" />

                            <TextView
                                android:id="@+id/tv_total_price"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="¥0.00"
                                android:textColor="#000"
                                android:textSize="16sp"
                                android:textStyle="bold" />
                        </LinearLayout>
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="不含运费"
                            android:gravity="right"
                            android:textColor="#000"
                            android:textSize="16sp"
                            android:textStyle="bold" />
                    </LinearLayout>
                    <TextView
                        android:id="@+id/tv_go_to_pay"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="3"
                        android:background="#f00"
                        android:clickable="true"
                        android:gravity="center"
                        android:text="结算(0)"
                        android:textColor="#FAFAFA"

                        />
                </LinearLayout>
                <LinearLayout
                    android:id="@+id/ll_shar"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="4"
                    android:orientation="horizontal"
                    android:visibility="gone"
                    >
                    <TextView
                        android:id="@+id/tv_share"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:layout_weight="1"
                        android:layout_marginLeft="5dp"
                        android:text="分享宝贝"
                        android:background="#ef930a"
                        android:textColor="#fff"
                        android:textSize="16sp"
                        android:layout_marginRight="5dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/tv_save"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="移到收藏夹"
                        android:background="#ef930a"
                        android:textColor="#fff"
                        android:layout_marginRight="5dp"
                        android:textSize="16sp"
                        android:textStyle="bold" />
                    <TextView
                        android:id="@+id/tv_delete"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:background="#f00"
                        android:clickable="true"
                        android:gravity="center"
                        android:text="删除"
                        android:textColor="#FAFAFA"
                        />
                </LinearLayout>

            </LinearLayout>
        </LinearLayout>

    </FrameLayout>
</LinearLayout>
微笑 微笑 微笑 layout   下  activity_list   布局

<?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"
    tools:context="com.example.samsung.yuekaolianxi.view.ListActivity">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/rcy"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
</LinearLayout>
微笑 微笑 微笑 layout  下  activity_main   布局

<?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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.samsung.yuekaolianxi.view.MainActivity">
    <ImageView
        android:src="@mipmap/rbqh"

        android:layout_width="100dp"
        android:layout_height="100dp" />
    <LinearLayout
        android:padding="10dp"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:id="@+id/login_username"
            android:hint="请输入用户名"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/login_password"
            android:hint="请输入密码"
            android:inputType="textPassword"

            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="忘记密码"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView
                android:id="@+id/login_regist"
                android:layout_alignParentRight="true"
                android:text="新用户注册"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </RelativeLayout>
        <Button
            android:id="@+id/btn_login"
            android:layout_marginTop="10dp"
            android:text="登录"
            android:background="#ffaa00"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

</LinearLayout>
微笑 微笑 微笑 layout   下   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="com.example.samsung.yuekaolianxi.view.MainActivity">
    <RelativeLayout
        android:id="@+id/rlt"
        android:background="#ffaa00"
        android:gravity="center_vertical"
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <ImageView
            android:layout_alignParentLeft="true"
            android:id="@+id/regist_back"
            android:src="@mipmap/back"
            android:layout_width="40dp"
            android:layout_height="40dp" />
        <TextView
            android:text="新用户注册"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </RelativeLayout>
    <LinearLayout
        android:layout_below="@id/rlt"
        android:padding="10dp"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:id="@+id/regist_username"
            android:hint="请输入用户名"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/regist_password"
            android:hint="请输入密码"
            android:inputType="textPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/regist_password_again"
            android:hint="请再次输入密码"
            android:inputType="textPassword"

            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/regist_email"
            android:hint="请输入邮箱"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <Button
            android:id="@+id/regist_login"
            android:layout_marginTop="10dp"
            android:text="注册"
            android:background="#ffaa00"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</RelativeLayout>
微笑 微笑 微笑 layout   下   item   布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:gravity="center"
    android:layout_height="match_parent">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/lis_img"
        android:layout_width="100dp"
        android:src="@mipmap/ic_launcher"
        android:layout_height="100dp" />
    <LinearLayout
        android:layout_marginLeft="10dp"
        android:gravity="center_vertical"
        android:padding="10dp"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/tv_title"
            android:text="按时打算打算打算打算的"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/tv_price"
            android:text="13333"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>
微笑 微笑 微笑 layout   下   item_shopcart_group    布局

<?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="wrap_content"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white" >

        <CheckBox
            android:id="@+id/determine_chekbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            />

        <TextView
            android:id="@+id/tv_source_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp"
            android:layout_toRightOf="@id/determine_chekbox"
            android:background="#ffffffff"
            android:drawablePadding="10dp"
            android:text="第八号当铺"
            android:textColor="#000"
            android:gravity="center"
            android:textSize="18dp" />
        <TextView
            android:id="@+id/tv_store_edtor"
            android:layout_width="50dp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="14dp"
            android:textSize="18dp"
            android:background="@null"
            android:text="编辑"/>
    </RelativeLayout>

</LinearLayout>
微笑 微笑 微笑 layout    下   item_shopcart_product   布局

<?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="wrap_content"
    android:orientation="vertical" >

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#CCCCCC" />

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

        <CheckBox
            android:id="@+id/check_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="4dp"
            android:checkMark="?android:attr/listChoiceIndicatorMultiple"
            android:gravity="center"
            android:minHeight="64dp"
            android:minWidth="32dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:visibility="visible" />

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/iv_adapter_list_pic"
            android:layout_width="85dp"
            android:layout_height="85dp"
            android:layout_marginBottom="15dp"
            android:layout_marginTop="13dp"
            android:scaleType="centerCrop"
            />

        <RelativeLayout
            android:id="@+id/rl_no_edtor"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="13dp"
            >

            <TextView
                android:id="@+id/tv_intro"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginRight="10dp"
                android:layout_marginTop="20dp"
                android:ellipsize="end"
                android:maxLines="2"
                android:text="第八号店铺"
                android:textColor="#000"
                android:singleLine="true"
                />
            <TextView
                android:id="@+id/tv_color_size"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="颜色:黑色;尺码:29"
                android:layout_marginTop="5dp"
                android:textColor="#000"
                android:layout_centerVertical="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_marginBottom="20dp"
                android:layout_alignParentStart="true">

                <TextView
                    android:id="@+id/tv_price"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:singleLine="true"
                    android:text="¥ 308.00"
                    android:textColor="#000"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/tv_discount_price"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="10dp"
                    android:layout_toRightOf="@+id/tv_price"
                    android:text=""
                    />
                <TextView
                    android:id="@+id/tv_buy_num"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="20dp"
                    android:layout_alignParentRight="true"
                    android:text="X 1"
                    android:textColor="#000"
                    />
            </RelativeLayout>
        </RelativeLayout>
        <LinearLayout
            android:id="@+id/ll_edtor"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="13dp"
            android:visibility="gone"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical">
                <RelativeLayout
                    android:id="@+id/ll_change_num"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:layout_marginTop="20dp"
                    android:orientation="horizontal">
                    <com.example.samsung.yuekaolianxi.view.AddDeleteView
                        android:id="@+id/adv_main"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                        app:left_text="-"
                        app:middle_text="3"
                        app:right_text="+"
                    </com.example.samsung.yuekaolianxi.view.AddDeleteView>

                </RelativeLayout>

                <TextView
                    android:id="@+id/tv_colorsize"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:text="颜色:黑色;尺码:29"
                    android:layout_gravity="left"
                    android:textColor="#000"/>
            </LinearLayout>

            <TextView
                android:id="@+id/tv_goods_delete"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:text="删除"
                android:background="#ecb74c"
                android:gravity="center"
                android:layout_gravity="center"
                android:textColor="#fff"/>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
微笑 微笑 微笑 layout   下   layout_add_delete    布局

<?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">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        >
        <Button
            android:id="@+id/but_delete"
            android:layout_width="22dp"
            android:layout_height="22dp"
            android:background="@mipmap/remove"
            />
        <TextView
            android:id="@+id/et_number"
            android:layout_width="40dp"
            android:inputType="number"
            android:layout_height="wrap_content"
            android:gravity="center"

            />
        <Button
            android:id="@+id/but_add"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:background="@mipmap/add"
            />
    </LinearLayout>

</LinearLayout>
微笑 微笑 微笑 主包下   MyApplication   类

package com.example.samsung.yuekaolianxi;

import android.app.Application;

import com.facebook.drawee.backends.pipeline.Fresco;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Fresco.initialize(this);
    }
}
微笑 微笑 微笑 主包下  LoggingInterceptor   类

package com.example.samsung.yuekaolianxi;

import java.io.IOException;

import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class LoggingInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();
        HttpUrl url=original.url().newBuilder()
                .addQueryParameter("source","android")
                .build();
        //添加请求头
        Request request = original.newBuilder()
                .url(url)
                .build();
        return chain.proceed(request);
    }

}
微笑 微笑 微笑 主包下   ApiService   接口

package com.example.samsung.yuekaolianxi;

import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.CartBean;
import com.example.samsung.yuekaolianxi.bean.GoodsBean;
import com.example.samsung.yuekaolianxi.bean.LoginBean;
import com.example.samsung.yuekaolianxi.bean.MessageBean;
import com.example.samsung.yuekaolianxi.bean.RegistBean;

import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface ApiService {
//    http://120.27.23.105/user/login?mobile=13033333333&password=123456
//    https://www.zhaoapi.cn/product/getProducts?pscid=39&page=1
    @GET("user/{login}")
    Flowable<RegistBean> getMessage(@Path("login") String login, @Query("mobile") String mobile, @Query("password") String password);
    @GET("user/{login}")
    Flowable<LoginBean> getLoginMessage(@Path("login") String login, @Query("mobile") String mobile, @Query("password") String password);

    @GET("product/{getProducts}")
    Flowable<MessageBean> getListGoodes(@Path("getProducts") String getProducts, @Query("pscid") int pscid, @Query("page") int page);

    @GET("product/{getProducts}")
    Flowable<GoodsBean> getGoods(@Path("getProducts") String roducts, @Query("pid") String pid);
    @GET("product/{addCart}")
    Flowable<AddBean> getGoodsMessage(@Path("addCart") String login, @Query("uid") String uid, @Query("pid") String pid);
//    http://120.27.23.105/product/getCarts?uid=1262
//    http://120.27.23.105/product/deleteCart?uid=71&pid=1
    @GET("product/{getCarts}")
    Flowable<CartBean> getShoppingCarts(@Path("getCarts") String roducts, @Query("uid") String uid);
    @GET("product/{getCarts}")
    Flowable<AddBean> del(@Path("getCarts") String roducts, @Query("uid") String uid, @Query("pid") String pid);
}
微笑 微笑 微笑 主包下   IView   接口

package com.example.samsung.yuekaolianxi;

import com.example.samsung.yuekaolianxi.bean.AddBean;

public interface IView {
    void onSuccess(Object o);
    void onFailed(Exception e);

    void success(AddBean loginBean);
}
微笑 微笑 微笑 adapter   下   ListAdapter    类  

package com.example.samsung.yuekaolianxi.adapter;

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

import com.example.samsung.yuekaolianxi.R;
import com.example.samsung.yuekaolianxi.bean.MessageBean;
import com.example.samsung.yuekaolianxi.view.GoodsActivity;
import com.facebook.drawee.view.SimpleDraweeView;
import java.util.List;

public class ListsAdapter extends RecyclerView.Adapter<ListsAdapter.ViewHolder> {
    private List<MessageBean.DataBean> list;
    private Context context;
    
    public ListsAdapter(Context context, List<MessageBean.DataBean> list) {
        this.list = list;
        this.context = context;
    }

    //创建新View,被LayoutManager所调用
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View view = View.inflate(context, R.layout.item, null);
        ViewHolder vh = new ViewHolder(view);
        return vh;
    }

    //将数据与界面进行绑定的操作
    @Override
    public void onBindViewHolder(ViewHolder viewHolder, final int position) {
        String images = list.get(position).getImages();
        if(images!=null){
            String[] split = images.split("\\|");
            viewHolder.item_img.setImageURI(split[0]);

        }
        viewHolder.tvPrice.setText("¥"+list.get(position).getPrice());
        viewHolder.tvPrice.setText(list.get(position).getTitle());
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                 int pid = list.get(position).getPid();

                Intent intent = new Intent(context,GoodsActivity.class);
                intent.putExtra("pid",pid+"");
                context.startActivity(intent);
            }
        });
    }

    //获取数据的数量
    @Override
    public int getItemCount() {
        return list.size();
    }

    //自定义的ViewHolder,持有每个Item的的所有界面元素
    class ViewHolder extends RecyclerView.ViewHolder {
        public TextView tvTitle;
        public TextView tvPrice;

        private SimpleDraweeView item_img;
        public ViewHolder(View view) {
            super(view);
            tvTitle =  view.findViewById(R.id.tv_title);
            tvPrice =  view.findViewById(R.id.tv_title);

            item_img = view.findViewById(R.id.lis_img);
        }
    }
}
微笑 微笑 微笑 adapter   下   ShopCarExListAdapter    类

package com.example.samsung.yuekaolianxi.adapter;

import android.content.Context;
import android.content.DialogInterface;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.samsung.yuekaolianxi.R;
import com.example.samsung.yuekaolianxi.bean.CartBean;
import com.example.samsung.yuekaolianxi.bean.MessageEvent;
import com.example.samsung.yuekaolianxi.bean.PriceAndCountEvent;
import com.example.samsung.yuekaolianxi.bean.SomeId;
import com.example.samsung.yuekaolianxi.view.AddDeleteView;
import com.facebook.drawee.view.SimpleDraweeView;

import org.greenrobot.eventbus.EventBus;

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

public class ShopCartExListAdapter extends BaseExpandableListAdapter {
    private Context context;
    private List<CartBean.DataBean> list = new ArrayList<>();
    private boolean isShow = true;
    private boolean flag = true;
    private int totalCount=0;

    public ShopCartExListAdapter(Context context, List<CartBean.DataBean> list) {
        this.context = context;
        this.list = list;
    }

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

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

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

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

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

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

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

    @Override
    public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        View view;
        final GroupViewHolder holder;
        if (convertView == null) {
            holder = new GroupViewHolder();
            view = View.inflate(context, R.layout.item_shopcart_group, null);
            holder.determine_chekbox = (CheckBox) view.findViewById(R.id.determine_chekbox);
            holder.tv_source_name = (TextView) view.findViewById(R.id.tv_source_name);
            holder.tv_store_edtor = (TextView) view.findViewById(R.id.tv_store_edtor);
            view.setTag(holder);
        } else {
            view = convertView;
            holder = (GroupViewHolder) view.getTag();
        }
        final CartBean.DataBean dataBean = list.get(groupPosition);

        holder.determine_chekbox.setChecked(dataBean.isChecked());

        holder.tv_source_name.setText(dataBean.getSellerName());
        //一级checkbox
        holder.determine_chekbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                totalCount++;
                dataBean.setChecked(holder.determine_chekbox.isChecked());
                changeChildCbState(groupPosition, holder.determine_chekbox.isChecked());
                EventBus.getDefault().post(compute());
                changeAllCbState(isAllGroupCbSelected());
                notifyDataSetChanged();
            }
        });
        if (dataBean.isEditor()) {
            holder.tv_store_edtor.setText("完成");
        } else {
            holder.tv_store_edtor.setText("编辑");
        }
        holder.tv_store_edtor.setOnClickListener(new GroupViewClick(groupPosition, holder.tv_store_edtor, dataBean));
        notifyDataSetChanged();
        return view;
    }

    @Override
    public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        View view;
        final ChildViewHolder holder;
        if (convertView == null) {
            holder = new ChildViewHolder();
            view = View.inflate(context,R.layout.item_shopcart_product, null);
            holder.cbChild = (CheckBox) view.findViewById(R.id.check_box);
            holder.tv_intro = (TextView) view.findViewById(R.id.tv_intro);
            holder.imgIcon = (SimpleDraweeView) view.findViewById(R.id.iv_adapter_list_pic);
            holder.tv_price = (TextView) view.findViewById(R.id.tv_price);
            holder.tv_del = (TextView) view.findViewById(R.id.tv_goods_delete);
//            holder.bt_add = (ImageView) view.findViewById(R.id.bt_add);
//            holder.bt_del = (ImageView) view.findViewById(R.id.bt_reduce);
//            holder.et_num = (EditText) view.findViewById(R.id.et_num);
            holder.tv_num = (TextView) view.findViewById(R.id.tv_buy_num);
            holder.ll_edtor = (LinearLayout) view.findViewById(R.id.ll_edtor);
            holder.rl_no_edtor = (RelativeLayout) view.findViewById(R.id.rl_no_edtor);
            holder.adv = view.findViewById(R.id.adv_main);
            view.setTag(holder);
        } else {
            view = convertView;
            holder = (ChildViewHolder) view.getTag();
        }
        final CartBean.DataBean.ListBean datasBean = list.get(groupPosition).getList().get(childPosition);



        holder.cbChild.setChecked(datasBean.isChecked());

        holder.tv_intro.setText(datasBean.getTitle());
        holder.tv_price.setText("¥"+datasBean.getPrice() );
        holder.tv_num.setText(datasBean.getNum() + "");
//        holder.et_num.setText(datasBean.getNum() + "");
        holder.adv.setNumber(datasBean.getNum());
        String[] split = datasBean.getImages().split("[|]");
        holder.imgIcon.setImageURI(Uri.parse(split[0]));

        //二级checkbox
        holder.cbChild.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //设置该条目对象里的checked属性值
                datasBean.setChecked(holder.cbChild.isChecked());
                PriceAndCountEvent priceAndCountEvent = compute();
                EventBus.getDefault().post(priceAndCountEvent);
                if (holder.cbChild.isChecked()) {
                    //当前checkbox是选中状态
                    if (isAllChildCbSelected(groupPosition)) {
                        changGroupCbState(groupPosition, true);
                        changeAllCbState(isAllGroupCbSelected());
                    }
                    totalCount++;
                } else {
                    changGroupCbState(groupPosition, false);
                    changeAllCbState(isAllGroupCbSelected());
                }
                notifyDataSetChanged();
            }
        });
        holder.adv.setOnAddDelClickListener(new AddDeleteView.OnAddDelClickListener() {
            @Override
            public void onAddClick(View v) {
                Log.i("zxz", "onAddClick: 执行");
                int origin = holder.adv.getNumber();
                origin++;
//                holder.adv.setNumber(origin);
                int num = datasBean.getNum();
                num++;
                holder.adv.setNumber(num);
                datasBean.setNum(num);
                if (holder.cbChild.isChecked()) {
                    EventBus.getDefault().post(compute());
                }
            }

            @Override
            public void onDelClick(View v) {
                int origin = holder.adv.getNumber();
//                int num = datasBean.getNum();

                origin--;
                if (origin == 0) {
                    Toast.makeText(context,"最小数量为1", Toast.LENGTH_SHORT).show();
                    return ;
                }
                holder.adv.setNumber(origin);
                datasBean.setNum(origin);
                if (holder.cbChild.isChecked()) {

                    EventBus.getDefault().post(compute());
                }

            }
        });

        //删除
        holder.tv_del.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog alert;
                alert = new AlertDialog.Builder(context).create();
                alert.setTitle("操作提示");
                alert.setMessage("您确定要将这些商品从购物车中移除吗?");
                alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                return;
                            }
                        });
                alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                List<CartBean.DataBean.ListBean> datasBeen = list.get(groupPosition).getList();
                                CartBean.DataBean.ListBean remove = datasBeen.remove(childPosition);
                                if (datasBeen.size() == 0) {
                                    list.remove(groupPosition);
                                }
                                int pid = datasBean.getPid();
                                SomeId someId = new SomeId();
                                someId.setPid(pid+"");
                                EventBus.getDefault().post(someId);
                                EventBus.getDefault().post(compute());
                                notifyDataSetChanged();
                            }
                        });
                alert.show();
            }
        });
        //编辑
        //判断是否在编辑状态下(标题中的编辑)
        if (list.get(groupPosition).isEditor() == true) {
            holder.ll_edtor.setVisibility(View.VISIBLE);
            holder.rl_no_edtor.setVisibility(View.GONE);
        } else {
            holder.ll_edtor.setVisibility(View.GONE);
            holder.rl_no_edtor.setVisibility(View.VISIBLE);
        }

        return view;
    }

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

    class GroupViewHolder {
        CheckBox determine_chekbox;
        TextView tv_source_name,tv_store_edtor;
    }
    /**
     * 使某个组处于编辑状态
     * <p/>
     * groupPosition组的位置
     */
    class GroupViewClick implements View.OnClickListener {
        private int groupPosition;
        private TextView edtor;
        private CartBean.DataBean group;

        public GroupViewClick(int groupPosition, TextView edtor, CartBean.DataBean group) {
            this.groupPosition = groupPosition;
            this.edtor = edtor;
            this.group = group;
        }
        @Override
        public void onClick(View v) {
            int groupId = v.getId();
            if (groupId == edtor.getId()) {
                if (group.isEditor()) {
                    group.setEditor(false);
                } else {
                    group.setEditor(true);

                }
                notifyDataSetChanged();
            }
        }
    }
    /**
     * 监听编辑状态
     */
    public interface GroupEdtorListener {
        void groupEdit(int groupPosition);
    }

    class ChildViewHolder {
        CheckBox cbChild;
        TextView tv_intro;
        SimpleDraweeView imgIcon;
        TextView tv_price;
        TextView tv_del;
        ImageView bt_del,bt_add;
        EditText et_num;
        //        TextView tv_num;
        LinearLayout ll_edtor;
        RelativeLayout rl_no_edtor;
        AddDeleteView adv;
        ImageView iv_del;
        ImageView iv_add;
        TextView tv_num;
    }

    /**
     * 改变全选的状态
     *
     * @param flag
     */
    private void changeAllCbState(boolean flag) {
        MessageEvent messageEvent = new MessageEvent();
        messageEvent.setChecked(flag);
        EventBus.getDefault().post(messageEvent);
    }

    /**
     * 改变一级列表checkbox状态
     *
     * @param groupPosition
     */
    private void changGroupCbState(int groupPosition, boolean flag) {
        CartBean.DataBean dataBean = list.get(groupPosition);
        dataBean.setChecked(flag);
    }

    /**
     * 改变二级列表checkbox状态
     *
     * @param groupPosition
     * @param flag
     */
    private void changeChildCbState(int groupPosition, boolean flag) {
        List<CartBean.DataBean.ListBean> datasBeen = list.get(groupPosition).getList();

        for (int i = 0; i < datasBeen.size(); i++) {
            CartBean.DataBean.ListBean datasBean = datasBeen.get(i);

            datasBean.setChecked(flag);
        }
    }

    /**
     * 判断一级列表是否全部选中
     *
     * @return
     */
    private boolean isAllGroupCbSelected() {
        for (int i = 0; i < list.size(); i++) {
            CartBean.DataBean dataBean = list.get(i);
            if (!dataBean.isChecked()) {
                return false;
            }
        }
        return true;
    }

    /**
     * 判断二级列表是否全部选中
     *
     * @param groupPosition
     * @return
     */
    private boolean isAllChildCbSelected(int groupPosition) {
        List<CartBean.DataBean.ListBean> datasBeen = list.get(groupPosition).getList();
        for (int i = 0; i < datasBeen.size(); i++) {
            CartBean.DataBean.ListBean datasBean = datasBeen.get(i);
            if (!datasBean.isChecked()) {
                return false;
            }
        }
        return true;
    }

    /**
     * 计算列表中,选中的钱和数量
     */
    private PriceAndCountEvent compute() {
        int count = 0;
        int price = 0;
        for (int i = 0; i < list.size(); i++) {
            List<CartBean.DataBean.ListBean> datasBeen = list.get(i).getList();
            for (int j = 0; j < datasBeen.size(); j++) {
                CartBean.DataBean.ListBean datasBean = datasBeen.get(j);
                if (datasBean.isChecked()) {
                    price += datasBean.getNum() * datasBean.getPrice();
                    count += datasBean.getNum();
                }
            }
        }
        PriceAndCountEvent priceAndCountEvent = new PriceAndCountEvent();
        priceAndCountEvent.setCount(count);
        priceAndCountEvent.setPrice(price);
        return priceAndCountEvent;
    }

    /**
     * 设置全选、反选
     *
     * @param flag
     */
    public void changeAllListCbState(boolean flag) {
        for (int i = 0; i < list.size(); i++) {
            changGroupCbState(i, flag);
            changeChildCbState(i, flag);
        }
        EventBus.getDefault().post(compute());
        notifyDataSetChanged();
    }
    /**
     * 是否显示可编辑
     *
     * @param flag
     */
    public void isShow(boolean flag) {
        isShow = flag;
        notifyDataSetChanged();
    }
}
微笑 微笑 微笑 bean   下   AddBean   类

package com.example.samsung.yuekaolianxi.bean;

public class AddBean {
    /**
     * 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;
    }
}
微笑 微笑 微笑 bean   下   CartBean    类

package com.example.samsung.yuekaolianxi.bean;

import java.util.List;

public class CartBean {
    /**
     * msg : 请求成功
     * code : 0
     * data : [{"list":[{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":1,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"}],"sellerName":"商家2","sellerid":"2"}]
     */

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

    public String getMsg() {
        return msg;
    }

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

    public String getCode() {
        return code;
    }

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

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

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

    public static class DataBean {
        /**
         * list : [{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":1,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"}]
         * sellerName : 商家2
         * sellerid : 2
         */
        private boolean checked;
        private String sellerName;
        private String sellerid;
        private List<ListBean> list;
        private boolean editor;
        public boolean isChecked() {
            return checked;
        }

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

        public boolean isEditor() {
            return editor;
        }

        public void setEditor(boolean editor) {
            this.editor = editor;
        }

        public String getSellerName() {
            return sellerName;
        }

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

        public String getSellerid() {
            return sellerid;
        }

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

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

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

        public static class ListBean {
            /**
             * bargainPrice : 6666
             * createtime : 2017-10-10T16:01:31
             * detailUrl : https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends
             * images : https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg
             * num : 1
             * pid : 46
             * price : 234
             * pscid : 39
             * selected : 0
             * sellerid : 2
             * subhead : 【iPhone新品上市】新一代iPhone,让智能看起来更不一样
             * title : Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机
             */
            private boolean checked;

            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 boolean isChecked() {
                return checked;
            }

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

            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;
            }
        }
    }
}
微笑 微笑 微笑 bean   下   DeleteBean   类

package com.example.samsung.yuekaolianxi.bean;

public class DeleteBean {
    /**
     * msg : 删除购物车成功
     * code : 0
     */

    private String msg;
    private String code;

    public String getMsg() {
        return msg;
    }

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

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
微笑 微笑 微笑 bean   下  GoodsBean   类

package com.example.samsung.yuekaolianxi.bean;

public class GoodsBean {
    /**
     * msg :
     * seller : {"description":"我是商家15","icon":"http://120.27.23.105/images/icon.png","name":"商家15","productNums":999,"score":5,"sellerid":15}
     * code : 0
     * data : {"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":0,"pid":71,"price":32999,"pscid":40,"salenum":4242,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}
     */

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

    public String getMsg() {
        return msg;
    }

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

    public SellerBean getSeller() {
        return seller;
    }

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

    public String getCode() {
        return code;
    }

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

    public DataBean getData() {
        return data;
    }

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

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

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

        public String getDescription() {
            return description;
        }

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

        public String getIcon() {
            return icon;
        }

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

        public String getName() {
            return name;
        }

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

        public int getProductNums() {
            return productNums;
        }

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

        public int getScore() {
            return score;
        }

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

        public int getSellerid() {
            return sellerid;
        }

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

    public static class DataBean {
        /**
         * bargainPrice : 11800
         * createtime : 2017-10-03T23:53:28
         * detailUrl : https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1
         * images : https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg
         * itemtype : 0
         * pid : 71
         * price : 32999
         * pscid : 40
         * salenum : 4242
         * sellerid : 15
         * subhead : 购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)
         * title : 全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G
         */

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

        public double getBargainPrice() {
            return bargainPrice;
        }

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

        public String getCreatetime() {
            return createtime;
        }

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

        public String getDetailUrl() {
            return detailUrl;
        }

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

        public String getImages() {
            return images;
        }

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

        public int getItemtype() {
            return itemtype;
        }

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

        public int getPid() {
            return pid;
        }

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

        public double getPrice() {
            return price;
        }

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

        public int getPscid() {
            return pscid;
        }

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

        public int getSalenum() {
            return salenum;
        }

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

        public int getSellerid() {
            return sellerid;
        }

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

        public String getSubhead() {
            return subhead;
        }

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

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}
微笑 微笑 微笑 bean    下   ListBean   类

package com.example.samsung.yuekaolianxi.bean;

public class ListBean {

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

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

    public int getBargainPrice() {
        return bargainPrice;
    }

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

    public String getCreatetime() {
        return createtime;
    }

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

    public String getDetailUrl() {
        return detailUrl;
    }

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

    public String getImages() {
        return images;
    }

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

    public int getItemtype() {
        return itemtype;
    }

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

    public int getPid() {
        return pid;
    }

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

    public int getPrice() {
        return price;
    }

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

    public int getPscid() {
        return pscid;
    }

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

    public int getSalenum() {
        return salenum;
    }

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

    public int getSellerid() {
        return sellerid;
    }

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

    public String getSubhead() {
        return subhead;
    }

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

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
微笑 微笑 微笑 bean   下   LoginBean   类

package com.example.samsung.yuekaolianxi.bean;

public class LoginBean {

    /**
     * msg : 登录成功
     * code : 0
     * data : {"age":null,"appkey":"24d600aa568390f1","appsecret":"17F9742DA5FE4669BAF5A9FF3AF20D31","createtime":"2017-12-21T13:33:03","email":null,"fans":null,"follow":null,"gender":null,"icon":"https://www.zhaoapi.cn/images/15128322493651512832249638.png","latitude":null,"longitude":null,"mobile":"13033333333","money":null,"nickname":null,"password":"8F669074CAF5513351A2DE5CC22AC04C","praiseNum":null,"token":"E2E588BC5796B4DA1A90529FD028CB89","uid":1262,"userId":null,"username":"13033333333"}
     */

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

    public String getMsg() {
        return msg;
    }

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

    public String getCode() {
        return code;
    }

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

    public DataBean getData() {
        return data;
    }

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

    public static class DataBean {
        /**
         * age : null
         * appkey : 24d600aa568390f1
         * appsecret : 17F9742DA5FE4669BAF5A9FF3AF20D31
         * createtime : 2017-12-21T13:33:03
         * email : null
         * fans : null
         * follow : null
         * gender : null
         * icon : https://www.zhaoapi.cn/images/15128322493651512832249638.png
         * latitude : null
         * longitude : null
         * mobile : 13033333333
         * money : null
         * nickname : null
         * password : 8F669074CAF5513351A2DE5CC22AC04C
         * praiseNum : null
         * token : E2E588BC5796B4DA1A90529FD028CB89
         * uid : 1262
         * userId : null
         * username : 13033333333
         */

        private Object age;
        private String appkey;
        private String appsecret;
        private String createtime;
        private Object email;
        private Object fans;
        private Object follow;
        private Object gender;
        private String icon;
        private Object latitude;
        private Object longitude;
        private String mobile;
        private Object money;
        private 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 String getIcon() {
            return icon;
        }

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

        public Object getLatitude() {
            return latitude;
        }

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

        public Object getLongitude() {
            return longitude;
        }

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

        public String getMobile() {
            return mobile;
        }

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

        public Object getMoney() {
            return money;
        }

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

        public 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;
        }
    }
}
微笑 微笑 微笑 bean   下   MessageBean   类

package com.example.samsung.yuekaolianxi.bean;

import java.util.List;

public class MessageBean {

    /**
     * msg : 请求成功
     * code : 0
     * data : [{"bargainPrice":99,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/4345173.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6037/35/2944615848/95178/6cd6cff0/594a3a10Na4ec7f39.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6607/258/1025744923/75738/da120a2d/594a3a12Ne3e6bc56.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6370/292/1057025420/64655/f87644e3/594a3a12N5b900606.jpg!q70.jpg","itemtype":1,"pid":45,"price":2999,"pscid":39,"salenum":4666,"sellerid":1,"subhead":"高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!","title":"一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机"},{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","itemtype":0,"pid":46,"price":234,"pscid":39,"salenum":868,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"},{"bargainPrice":1599,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/1993026402.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5863/302/8961270302/97126/41feade1/5981c81cNc1b1fbef.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7003/250/1488538438/195825/53bf31ba/5981c57eN51e95176.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5665/100/8954482513/43454/418611a9/5981c57eNd5fc97ba.jpg!q70.jpg","itemtype":2,"pid":47,"price":111,"pscid":39,"salenum":757,"sellerid":3,"subhead":"碳黑色 32GB 全网通 官方标配   1件","title":"锤子 坚果Pro 特别版 巧克力色 酒红色 全网通 移动联通电信4G手机 双卡双待 碳黑色 32GB 全网通"},{"bargainPrice":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","itemtype":1,"pid":48,"price":222,"pscid":39,"salenum":656,"sellerid":4,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"},{"bargainPrice":1999,"createtime":"2017-10-10T16:09:02","detailUrl":"https://item.m.jd.com/product/5025971.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t7210/232/3738666823/232298/9004583e/59c3a9a7N8de42e15.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8356/82/2107423621/109733/c019b8c6/59c3a9a6Ne9a4bdd7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t10219/74/25356012/171379/7d55e296/59c3a9a8N82fa6e02.jpg!q70.jpg","itemtype":0,"pid":49,"price":333,"pscid":39,"salenum":123,"sellerid":5,"subhead":"vivo X20 带你开启全面屏时代!逆光也清晰,照亮你的美!","title":"vivo X20 全面屏手机 全网通 4GB+64GB 金色 移动联通电信4G手机 双卡双待"},{"bargainPrice":3455,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","itemtype":2,"pid":50,"price":444,"pscid":39,"salenum":54,"sellerid":6,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"},{"bargainPrice":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","itemtype":1,"pid":51,"price":555,"pscid":39,"salenum":424,"sellerid":7,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"},{"bargainPrice":3455,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","itemtype":0,"pid":52,"price":666,"pscid":39,"salenum":212,"sellerid":8,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"},{"bargainPrice":2999,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2385655.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t2068/298/2448145915/157953/7be197df/56d51a42Nd86f1c8e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2437/128/1687178395/117431/bcc190c1/56d3fcbaNb2963d21.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2467/222/2263160610/95597/927b8a2f/56d3eafeNdecebeb6.jpg!q70.jpg","itemtype":2,"pid":53,"price":777,"pscid":39,"salenum":0,"sellerid":9,"subhead":"Super AMOLED三星双曲面2K 屏,支持无线充电!","title":"三星 Galaxy S7 edge(G9350)4GB+32GB 铂光金 移动联通电信4G手机 双卡双待"},{"bargainPrice":3455,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","itemtype":0,"pid":54,"price":888,"pscid":39,"salenum":7575,"sellerid":10,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}]
     * page : 1
     */

    private String msg;
    private String code;
    private String page;
    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 String getPage() {
        return page;
    }

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

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

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

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

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

        public double getBargainPrice() {
            return bargainPrice;
        }

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

        public String getCreatetime() {
            return createtime;
        }

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

        public String getDetailUrl() {
            return detailUrl;
        }

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

        public String getImages() {
            return images;
        }

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

        public int getItemtype() {
            return itemtype;
        }

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

        public int getPid() {
            return pid;
        }

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

        public double getPrice() {
            return price;
        }

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

        public int getPscid() {
            return pscid;
        }

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

        public int getSalenum() {
            return salenum;
        }

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

        public int getSellerid() {
            return sellerid;
        }

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

        public String getSubhead() {
            return subhead;
        }

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

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}
微笑 微笑 微笑 bean   下   MessageEvent   类

package com.example.samsung.yuekaolianxi.bean;

public class MessageEvent {
    private boolean checked;

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }
}
微笑 微笑 微笑 bean   下   PriceAndCountEvent    类

package com.example.samsung.yuekaolianxi.bean;

public class PriceAndCountEvent {
    private int price;
    private int count;

    public int getPrice() {
        return price;
    }

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

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
微笑 微笑 微笑 bean   下   RegistBean   类

package com.example.samsung.yuekaolianxi.bean;

public class RegistBean {

    /**
     * msg : 天呢!用户已注册
     * code : 1
     * data : {}
     */

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

    public String getMsg() {
        return msg;
    }

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

    public String getCode() {
        return code;
    }

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

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }
}
微笑 微笑 微笑 bean   下   SomeId   类

package com.example.samsung.yuekaolianxi.bean;

public class SomeId {
    private String pid;

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }
}
微笑 微笑 微笑 model   下   DeleteModel   类

package com.example.samsung.yuekaolianxi.model;

import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.presenter.DeletePresenter;
import com.example.samsung.yuekaolianxi.utils.RetrofitUtils;

import io.reactivex.Flowable;

public class DeleteModel {
    private DeletePresenter presenter;

    public DeleteModel(DeletePresenter presenter) {
        this.presenter = presenter;
    }
    public void getData(String url, String roducts,String uid,String pid){

                Flowable<AddBean> flowable = RetrofitUtils
                        .getInstance(url)
                        .getApiService()
                        .del(roducts ,uid,pid);
                presenter.getMessage(flowable);

    }
}
微笑 微笑 微笑 model  下   MessageModel    类

package com.example.samsung.yuekaolianxi.model;

import com.example.samsung.yuekaolianxi.bean.GoodsBean;
import com.example.samsung.yuekaolianxi.bean.MessageBean;
import com.example.samsung.yuekaolianxi.presenter.MessagePresenter;
import com.example.samsung.yuekaolianxi.utils.RetrofitUtils;

import io.reactivex.Flowable;

public class MessageModel {
    private MessagePresenter presenter;

    public MessageModel(MessagePresenter presenter) {
        this.presenter = presenter;
    }
    public void getData(String url, String roducts,String pid, int pscid,int page){
            if(pid.equals("")){
                Flowable<MessageBean> flowable = RetrofitUtils.getInstance(url).getApiService().getListGoodes(roducts,pscid, page);
                presenter.getMessage(flowable);
            }else{
                Flowable<GoodsBean> flowable2 = RetrofitUtils.getInstance(url).getApiService().getGoods(roducts,pid );
                presenter.getNews(flowable2);
            }

    }
}
微笑 微笑 微笑 model   下   MyModel   类

package com.example.samsung.yuekaolianxi.model;

import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.LoginBean;
import com.example.samsung.yuekaolianxi.bean.RegistBean;
import com.example.samsung.yuekaolianxi.presenter.MyPresenter;
import com.example.samsung.yuekaolianxi.utils.RetrofitUtils;

import io.reactivex.Flowable;

public class MyModel {
    private MyPresenter presenter;

    public MyModel(MyPresenter presenter) {
        this.presenter = presenter;
    }
    public void getData(String url,String login ,String mobile,String password){
        if(login.equals("reg")){
            Flowable<RegistBean> flowable = RetrofitUtils.getInstance(url).getApiService().getMessage(login,mobile, password);
            presenter.getMessage(flowable);
        } else if (login.equals("login")) {
            Flowable<LoginBean> flowable2 = RetrofitUtils.getInstance(url).getApiService().getLoginMessage(login,mobile, password);
            presenter.getLoginMessage(flowable2);
        }else{
            Flowable<AddBean> flowable3 = RetrofitUtils.getInstance(url).getApiService().getGoodsMessage(login,mobile, password);
            presenter.getGoodsMessage(flowable3);
        }

    }
}
微笑 微笑 微笑 model  下    ShopCartsModel    类

package com.example.samsung.yuekaolianxi.model;

import com.example.samsung.yuekaolianxi.bean.CartBean;
import com.example.samsung.yuekaolianxi.presenter.ShopCartsPresenter;
import com.example.samsung.yuekaolianxi.utils.RetrofitUtils;

import io.reactivex.Flowable;

public class ShopCartsModel {
    private ShopCartsPresenter presenter;

    public ShopCartsModel(ShopCartsPresenter presenter) {
        this.presenter = presenter;
    }
    public void getData(String url, String roducts,String uid){

                Flowable<CartBean> flowable = RetrofitUtils
                        .getInstance(url)
                        .getApiService()
                        .getShoppingCarts(roducts ,uid);
                presenter.getMessage(flowable);
    }
}
微笑 微笑 微笑 presenter  下   BasePresenter   接口

package com.example.samsung.yuekaolianxi.presenter;

public interface BasePresenter {
    void getData(String url, String login, String mobile, String password);

}
微笑 微笑 微笑 presenter   下   DeletePresenter   类

package com.example.samsung.yuekaolianxi.presenter;

import android.util.Log;

import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.model.DeleteModel;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.DisposableSubscriber;

public class DeletePresenter implements DelPresenter{
    private IView iv;
    private DisposableSubscriber<AddBean> disposableSubscriber;

    public void attach(IView iv){
        this.iv=iv;
    }
    public void detach(){
        if (iv!=null){
            iv=null;
        }
        if(!disposableSubscriber.isDisposed()){
            disposableSubscriber.dispose();
        }
    }
//    http://120.27.23.105/product/deleteCart?uid=71&pid=1
    @Override
    public void getData(String url,String products,String uid ,String pid) {
        DeleteModel messageModel = new DeleteModel(this);
        messageModel.getData(url,products,uid,pid);
    }


    public void getMessage(Flowable<AddBean> flowable) {
        disposableSubscriber = flowable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSubscriber<AddBean>() {
                    @Override
                    public void onNext(AddBean bean) {
                        if (bean != null) {
                                iv.success(bean);
                            
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        Log.e("zxz",t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

}
微笑 微笑 微笑 presenter   下   DelPresenter   接口

package com.example.samsung.yuekaolianxi.presenter;

public interface DelPresenter {
    void getData(String url, String products, String uid, String pid);

}
微笑 微笑 微笑 presenter   下   IPresenter   接口

package com.example.samsung.yuekaolianxi.presenter;

public interface IPresenter {
    void getData(String url, String products, String pid, int pscid, int page);
}
微笑 微笑 微笑 presenter   下   MessagePresenter    类

package com.example.samsung.yuekaolianxi.presenter;

import android.util.Log;

import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.bean.GoodsBean;
import com.example.samsung.yuekaolianxi.bean.MessageBean;
import com.example.samsung.yuekaolianxi.model.MessageModel;

import java.util.List;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.DisposableSubscriber;

public class MessagePresenter implements IPresenter{
    private IView iv;
    private DisposableSubscriber<MessageBean> disposableSubscriber;
    private DisposableSubscriber<GoodsBean> disposableSubscriber1;

    public void attach(IView iv){
        this.iv=iv;
    }
    public void detach(){
        if (iv!=null){
            iv=null;
        }
        if(!disposableSubscriber.isDisposed()){
            disposableSubscriber.dispose();
        }
        if(!disposableSubscriber1.isDisposed()){
            disposableSubscriber1.dispose();
        }
    }

//    https://www.zhaoapi.cn/product/getProducts?pscid=39&page=1
    @Override
    public void getData(String url,String products,String pid,int pscid,int page ) {
        MessageModel messageModel = new MessageModel(this);
        messageModel.getData(url,products,pid,pscid,page);
    }


    public void getMessage(Flowable<MessageBean> flowable) {
        disposableSubscriber = flowable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSubscriber<MessageBean>() {
                    @Override
                    public void onNext(MessageBean loginBean) {
                        if (loginBean != null) {
                            List<MessageBean.DataBean> data = loginBean.getData();
                            if(data!=null){
                                iv.onSuccess(data);
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        Log.e("zxz",t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
    //
    public void getNews(Flowable<GoodsBean> flowable2) {
        disposableSubscriber1 = flowable2.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSubscriber<GoodsBean>() {
                    @Override
                    public void onNext(GoodsBean loginBean) {
                        if (loginBean != null) {
                            GoodsBean.DataBean data = loginBean.getData();
                            if (data != null) {
                                iv.onSuccess(data);
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        Log.e("zxz", t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
微笑 微笑 微笑 presenter   下   MyPresenter    类

package com.example.samsung.yuekaolianxi.presenter;

import android.util.Log;

import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.LoginBean;
import com.example.samsung.yuekaolianxi.bean.RegistBean;
import com.example.samsung.yuekaolianxi.model.MyModel;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.DisposableSubscriber;

public class MyPresenter implements BasePresenter{
    private IView iv;
    private DisposableSubscriber<RegistBean> disposableSubscriber;
    private DisposableSubscriber<LoginBean> subscriber;

    public void attach(IView iv){
        this.iv=iv;
    }
    public void detach(){
        if (iv!=null){
            iv=null;
        }
        if(!disposableSubscriber.isDisposed()){
            disposableSubscriber.dispose();
        }
        if(!subscriber.isDisposed()){
            subscriber.dispose();
        }
    }


    @Override
    public void getData(String url,String login,String mobile,String password) {
        MyModel myModel = new MyModel(this);
        myModel.getData(url,login,mobile,password);
    }
    public void getMessage(Flowable<RegistBean> flowable) {
        disposableSubscriber = flowable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSubscriber<RegistBean>() {
                    @Override
                    public void onNext(RegistBean loginBean) {
                        if (loginBean != null) {
                            iv.onSuccess(loginBean);
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        Log.e("zxz",t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
    public void getLoginMessage(Flowable<LoginBean> flowable) {
        subscriber = flowable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSubscriber<LoginBean>() {
                    @Override
                    public void onNext(LoginBean loginBean) {
                        if (loginBean != null) {
                            iv.onSuccess(loginBean);
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        Log.e("zxz", t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
    //公共方法
    public void getGoodsMessage(Flowable<AddBean> flowable3) {
        flowable3.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSubscriber<AddBean>() {
                    @Override
                    public void onNext(AddBean loginBean) {
                        //给v层传数据
                        if (loginBean != null) {
                            iv.success(loginBean);
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        Log.e("zxz",t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
微笑 微笑 微笑 presenter   下   ShopCartsPresenter    类

package com.example.samsung.yuekaolianxi.presenter;

import android.util.Log;

import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.bean.CartBean;
import com.example.samsung.yuekaolianxi.model.ShopCartsModel;

import java.util.List;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.DisposableSubscriber;

public class ShopCartsPresenter implements ShoppingPresenter{
    private IView iv;
    private DisposableSubscriber<CartBean> disposableSubscriber;

    public void attach(IView iv){
        this.iv=iv;
    }
    public void detach(){
        if (iv!=null){
            iv=null;
        }
        if(!disposableSubscriber.isDisposed()){
            disposableSubscriber.dispose();
        }
    }

    @Override
    public void getData(String url,String products,String uid ) {
        ShopCartsModel messageModel = new ShopCartsModel(this);
        messageModel.getData(url,products,uid);
    }


    public void getMessage(Flowable<CartBean> flowable) {
        disposableSubscriber = flowable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSubscriber<CartBean>() {
                    @Override
                    public void onNext(CartBean bean) {
                        if (bean != null) {
                             List<CartBean.DataBean> data = bean.getData();
                            if(data!=null){
                                iv.onSuccess(data);
                                Log.i("zzzz", "onSuccess: "+ data.toString());
                            }

                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        Log.e("zxz",t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

}
微笑 微笑 微笑 presenter    下   ShoppingPresenter    接口

package com.example.samsung.yuekaolianxi.presenter;

public interface ShoppingPresenter {
    void getData(String url, String products, String uid);

}
微笑 微笑 微笑 utils   下   RetrofitUtils   类

package com.example.samsung.yuekaolianxi.utils;

import com.example.samsung.yuekaolianxi.ApiService;
import com.example.samsung.yuekaolianxi.LoggingInterceptor;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitUtils {
    private static volatile  RetrofitUtils instance;
    private OkHttpClient client= new OkHttpClient
            .Builder()
            .addInterceptor(new LoggingInterceptor())
            .build();
    private ApiService apiService;
//"http://120.27.23.105/"
    private RetrofitUtils(String url){
        Retrofit retrofit = new Retrofit.Builder()
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl(url)
                .build();
        apiService = retrofit.create(ApiService.class);
    }
    public static RetrofitUtils getInstance(String url){
        if(instance==null){
            synchronized (RetrofitUtils.class){
                if(null==instance){
                    instance = new RetrofitUtils(url);
                }
            }
        }
        return instance;
    }
    public ApiService getApiService(){
        return apiService;
    }
}
微笑 微笑 微笑 view  下   AddDeleteView    类

package com.example.samsung.yuekaolianxi.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.samsung.yuekaolianxi.R;

public class AddDeleteView extends LinearLayout {

    private OnAddDelClickListener listener;
    private TextView et_number;

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

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

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

    }
    public AddDeleteView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context,attrs,defStyleAttr);
    }
    private void initView(Context context,AttributeSet attrs,int defStyleAttr){
        View.inflate(context, R.layout.layout_add_delete,this);
        Button but_add = findViewById(R.id.but_add);
        Button but_delete = findViewById(R.id.but_delete);
        et_number = findViewById(R.id.et_number);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AddDeleteViewStyle);
        String left_text = typedArray.getString(R.styleable.AddDeleteViewStyle_left_text);
        String middle_text = typedArray.getString(R.styleable.AddDeleteViewStyle_middle_text);
        String right_text = typedArray.getString(R.styleable.AddDeleteViewStyle_right_text);

        et_number.setText(middle_text);
        //释放资源
        typedArray.recycle();

        but_add.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onAddClick(view);
            }
        });
        but_delete.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onDelClick(view);
            }
        });
    }
    /**
     * 对外提供设置EditText值的方法
     */
    public void setNumber(int number){
        if (number>0){
            et_number.setText(number+"");
        }
    }
    /**
     * 得到控件原来的值
     */
    public int getNumber(){
        int number = 0;
        try {
            String numberStr = et_number.getText().toString().trim();
            number = Integer.valueOf(numberStr);
        } catch (Exception e) {
            number = 0;
        }
        return number;
    }
}
微笑 微笑 微笑 view  下   GoodsActivity   类

package com.example.samsung.yuekaolianxi.view;

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

import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.R;
import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.GoodsBean;
import com.example.samsung.yuekaolianxi.presenter.MessagePresenter;
import com.example.samsung.yuekaolianxi.presenter.MyPresenter;
import com.facebook.drawee.view.SimpleDraweeView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class GoodsActivity extends AppCompatActivity implements IView {

    @BindView(R.id.img)
    SimpleDraweeView mImg;
    @BindView(R.id.goods_title)
    TextView mGoodsTitle;
    @BindView(R.id.goods_price)
    TextView mGoodsPrice;
    @BindView(R.id.btn_add)
    Button mBtnAdd;
    @BindView(R.id.btn_into)
    Button mBtnInto;
    private String pid;
//    https://www.zhaoapi.cn/product/getProductDetail?pid=71&source=android
    private String url = "https://www.zhaoapi.cn/";
    private int pscid=39;
    private int page=1;
//    http://120.27.23.105/product/addCart?uid=3027&pid=1&source=android
    private String  products="getProductDetail";
    private String product ="addCart";
    private MessagePresenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goods);
        ButterKnife.bind(this);
        Intent intent = getIntent();
        pid = intent.getStringExtra("pid");
        presenter = new MessagePresenter();
        presenter.attach(this);
        presenter.getData(url,products,pid,1,2);

    }

    @OnClick({R.id.btn_add, R.id.btn_into})
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.btn_add:
                MyPresenter presenter = new MyPresenter();
                presenter.attach(this);
                presenter.getData(url,product,"1262",pid);
                break;
            case R.id.btn_into:
                Intent intent = new Intent(this,GoodsShopActivity.class);
                startActivity(intent);
                break;
        }
    }
    //设置属性
    @Override
    public void onSuccess(Object o) {
        GoodsBean.DataBean bean = (GoodsBean.DataBean)o;
        if(bean!=null){
            double bargainPrice = bean.getBargainPrice();
            String images = bean.getImages();
            String[] split = images.split("\\|");
            String title = bean.getTitle();
            mGoodsTitle.setText(title);
            mGoodsPrice.setText("¥"+bargainPrice);
            mImg.setImageURI(split[0]);
        }
    }

    @Override
    public void onFailed(Exception e) {

    }

    @Override
    public void success(AddBean bean) {
        if(bean!=null){
            String msg = bean.getMsg();
            Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();
        }
    }
}
微笑 微笑 微笑 view   下   GoodsShopActivity   类

package com.example.samsung.yuekaolianxi.view;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;


import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.R;
import com.example.samsung.yuekaolianxi.adapter.ShopCartExListAdapter;
import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.CartBean;
import com.example.samsung.yuekaolianxi.bean.MessageEvent;
import com.example.samsung.yuekaolianxi.bean.PriceAndCountEvent;
import com.example.samsung.yuekaolianxi.bean.SomeId;
import com.example.samsung.yuekaolianxi.presenter.DeletePresenter;
import com.example.samsung.yuekaolianxi.presenter.ShopCartsPresenter;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

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

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class GoodsShopActivity extends AppCompatActivity implements IView {

    private static final String TAG = "MainActivity";
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.subtitle)
    TextView subtitle;
    @BindView(R.id.top_bar)
    LinearLayout topBar;
    @BindView(R.id.exListView)
    ExpandableListView exListView;
    @BindView(R.id.all_chekbox)
    CheckBox allChekbox;
    @BindView(R.id.tv_total_price)
    TextView tvTotalPrice;
    @BindView(R.id.tv_go_to_pay)
    TextView tvGoToPay;
    @BindView(R.id.ll_info)
    LinearLayout llInfo;
    @BindView(R.id.tv_share)
    TextView tvShare;
    @BindView(R.id.tv_save)
    TextView tvSave;
    @BindView(R.id.tv_delete)
    TextView tvDelete;
    @BindView(R.id.ll_shar)
    LinearLayout llShar;
    @BindView(R.id.ll_cart)
    LinearLayout llCart;
    private String url = "http://120.27.23.105/";
    private int pscid=39;
    private int page=1;
    //   http://120.27.23.105/product/getCarts
    private String product ="getCarts";
    private int count = 0;
    private List<CartBean.DataBean> list = new ArrayList<>();
    private ShopCartExListAdapter adapter;
    private boolean flag = false;
    private int totalCount = 0;
    private double totalPrice = 0.00;
    private DeletePresenter deletePresenter;
    private String products ="deleteCart";
    private String pid;

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

    @Override
    protected void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    private void getData() {
        ShopCartsPresenter presenter = new ShopCartsPresenter();
        presenter.attach(this);
        presenter.getData(url,product,"1262");
        deletePresenter = new DeletePresenter();
        deletePresenter.attach(this);
        adapter = new ShopCartExListAdapter(this, list);
        exListView.setAdapter(adapter);
    }

    @Override
    public void onSuccess(Object o) {
        if (o instanceof List) {
            List<CartBean.DataBean> dataBean = (List<CartBean.DataBean>) o;
            list.addAll(dataBean);
            adapter.notifyDataSetChanged();
            for (int i = 0; i < adapter.getGroupCount(); i++) {
                exListView.expandGroup(i);
            }
        }
    }

    @Override
    public void onFailed(Exception e) {

    }

    @Override
    public void success(AddBean loginBean) {
        Toast.makeText(this,loginBean.getMsg(),Toast.LENGTH_SHORT).show();;
    }

    public void delete() {
        for (int i = 0; i < list.size(); i++) {
            List<CartBean.DataBean.ListBean> listbean = list.get(i).getList();
            for (int j = 0; j < listbean.size(); j++) {
                CartBean.DataBean.ListBean listBean =listbean.get(j);
                if (listBean.isChecked()) {
                    listbean.remove(j);
                    j--;
                    if (listbean.size() == 0) {
                        list.remove(i);
                        i--;
                    }
                }
            }
        }
        adapter.notifyDataSetChanged();
    }

    @OnClick({R.id.all_chekbox, R.id.tv_share, R.id.tv_save, R.id.tv_delete, R.id.subtitle,R.id.tv_go_to_pay})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.all_chekbox:
                adapter.changeAllListCbState(allChekbox.isChecked());
                break;
            case R.id.tv_share:
                Toast.makeText(this, "分享成功", Toast.LENGTH_SHORT).show();
                break;
            case R.id.tv_save:
                Toast.makeText(this, "加入成功", Toast.LENGTH_SHORT).show();
                break;
            case R.id.tv_delete:
                AlertDialog dialog;
                if (totalCount == 0) {
                    Toast.makeText(GoodsShopActivity.this, "请选择要删除的商品", Toast.LENGTH_SHORT).show();
                    return;
                }
                dialog = new AlertDialog.Builder(GoodsShopActivity.this).create();
                dialog.setTitle("操作提示");
                dialog.setMessage("您确定要将这些商品从购物车中移除吗?");
                dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        return;
                    }
                });
                dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                        delete();
                        deletePresenter.getData(url,products,"1262",pid);
                    }
                });
                dialog.show();
                break;
            case R.id.subtitle:
                flag = !flag;
                if (flag) {
                    subtitle.setText("完成");
                    llShar.setVisibility(View.VISIBLE);
                    llInfo.setVisibility(View.GONE);
                } else {
                    subtitle.setText("编辑");
                    llShar.setVisibility(View.GONE);
                    llInfo.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.tv_go_to_pay:
                AlertDialog alert;
                if (totalCount == 0) {
                    Toast.makeText(this, "请选择要支付的商品", Toast.LENGTH_LONG).show();
                    return;
                }
                alert = new AlertDialog.Builder(this).create();
                alert.setTitle("操作提示");
                alert.setMessage("总计:\n" + totalCount + "种商品\n" + totalPrice + "元");
                alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                return;
                            }
                        });
                alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        });
                alert.show();
                break;
        }
    }
    //全选
    @Subscribe
    public void onMessageEvent(MessageEvent event) {
        allChekbox.setChecked(event.isChecked());
    }
    //删除
    @Subscribe
    public void onMessageEvent(SomeId event) {
        pid = event.getPid();
        deletePresenter.getData(url,products,"1262",pid);
        Log.e("zxz",pid);
    }
    //改变价格
    @Subscribe
    public void onMessageEvent(PriceAndCountEvent event) {
        title.setText("购物车(" + event.getCount() + ")");
        tvGoToPay.setText("结算(" + event.getCount() + ")");
        tvTotalPrice.setText("¥" + event.getPrice());
        totalCount = event.getCount();
        totalPrice = event.getPrice();
    }

}
微笑 微笑 微笑 view   下   ListActivity    类

package com.example.samsung.yuekaolianxi.view;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.R;
import com.example.samsung.yuekaolianxi.adapter.ListsAdapter;
import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.MessageBean;
import com.example.samsung.yuekaolianxi.presenter.MessagePresenter;

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

import butterknife.BindView;
import butterknife.ButterKnife;

public class ListActivity extends AppCompatActivity implements IView {

    @BindView(R.id.rcy)
    RecyclerView mRcy;
    private ListsAdapter adapter;
    private String url="https://www.zhaoapi.cn/";
    private int pscid=39;
    private int page=1;
    private String  products="getProducts";
    private List<MessageBean.DataBean> list = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);
        ButterKnife.bind(this);
        LinearLayoutManager manager = new LinearLayoutManager(this);
        //适配器
        adapter = new ListsAdapter(this,list);
        //调用P层
        MessagePresenter presenter = new MessagePresenter();
        presenter.attach(this);
        presenter.getData(url,products,"",pscid,page);
        mRcy.setLayoutManager(manager);
        mRcy.setAdapter(adapter);
    }

    @Override
    public void onSuccess(Object o) {
        //回调
        List<MessageBean.DataBean> data = (List<MessageBean.DataBean>) o;
            if(data!=null){
                list.addAll(data);
                adapter.notifyDataSetChanged();
            }
    }

    @Override
    public void onFailed(Exception e) {

    }

    @Override
    public void success(AddBean loginBean) {

    }

}
微笑 微笑 微笑 view   下   MainActivity   类

package com.example.samsung.yuekaolianxi.view;

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.TextView;
import android.widget.Toast;

import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.R;
import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.LoginBean;
import com.example.samsung.yuekaolianxi.presenter.MyPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity implements IView {

    @BindView(R.id.login_username)
    EditText mLoginUsername;
    @BindView(R.id.login_password)
    EditText mLoginPassword;
    @BindView(R.id.login_regist)
    TextView mLoginRegist;
    @BindView(R.id.btn_login)
    Button mBtnLogin;
    private MyPresenter presenter;
    private String url="http://120.27.23.105/";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        presenter = new MyPresenter();
        presenter.attach(this);
    }

    @OnClick({R.id.login_regist, R.id.btn_login})
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.login_regist:
                Intent intent = new Intent(this, RegistActivity.class);
                startActivity(intent);
                break;
            case R.id.btn_login:
                //获取属性
                String username = mLoginUsername.getText().toString().trim();
                String password = mLoginPassword.getText().toString().trim();
                login(username,password);
                break;
        }
    }
    //逻辑判断
    private void login(String username, String password) {
        if(password.length()<6){
            Toast.makeText(this,"密码不能小于6位",Toast.LENGTH_SHORT).show();
        }else{
            presenter.getData(url,"login",username,password);

        }
    }

    @Override
    public void onSuccess(Object o) {
        LoginBean bean = (LoginBean)o;
        if(bean!=null){
            String msg = bean.getMsg();
            Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();

            String code = bean.getCode();
            if(code.equals("0")){
                Intent intent = new Intent(MainActivity.this,ListActivity.class);
                startActivity(intent);
            }
        }
    }

    @Override
    public void onFailed(Exception e) {

    }

    @Override
    public void success(AddBean loginBean) {

    }
}
微笑 微笑 微笑 view   下    RegistActivity    类

package com.example.samsung.yuekaolianxi.view;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.samsung.yuekaolianxi.IView;
import com.example.samsung.yuekaolianxi.R;
import com.example.samsung.yuekaolianxi.bean.AddBean;
import com.example.samsung.yuekaolianxi.bean.RegistBean;
import com.example.samsung.yuekaolianxi.presenter.MyPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RegistActivity extends AppCompatActivity implements IView {

    @BindView(R.id.regist_back)
    ImageView mRegistBack;
    @BindView(R.id.regist_username)
    EditText mRegistUsername;
    @BindView(R.id.regist_password)
    EditText mRegistPassword;
    @BindView(R.id.regist_password_again)
    EditText mRegistPasswordAgain;
    @BindView(R.id.regist_email)
    EditText mRegistEmail;
    @BindView(R.id.regist_login)
    Button mRegistLogin;
    private MyPresenter presenter;
    private String url="http://120.27.23.105/";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_regist);
        ButterKnife.bind(this);
        presenter = new MyPresenter();
        presenter.attach(this);
    }

    @OnClick({R.id.regist_back, R.id.regist_login})
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.regist_back:
                finish();
                break;
            case R.id.regist_login:
                String username = mRegistUsername.getText().toString().trim();
                String password = mRegistPassword.getText().toString().trim();
                String password2 = mRegistPasswordAgain.getText().toString().trim();
                String email = mRegistEmail.getText().toString().trim();

                regist(username,password,password2,email);
                break;
        }
    }
        //注册的有参方法
    private void regist(String username, String password, String password2, String email) {
        if(password.length()<6){
            Toast.makeText(this,"密码不能小于6位",Toast.LENGTH_SHORT).show();
        } else if(!password2.equals(password)){
            Toast.makeText(this,"两次密码不一致",Toast.LENGTH_SHORT).show();

        }else if(email.length()==0){
            Toast.makeText(this,"邮箱不能为空",Toast.LENGTH_SHORT).show();

        }else{
            presenter.getData(url,"reg",username,password);

        }
    }

    @Override
    public void onSuccess(Object o) {
        RegistBean bean = (RegistBean)o;
        if(bean!=null){
            String msg = bean.getMsg();
            Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();

            String code = bean.getCode();
            if(code.equals("0")){
                finish();
            }
        }
    }

    @Override
    public void onFailed(Exception e) {

    }

    @Override
    public void success(AddBean loginBean) {

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值