属性动画+购物车+结算

来源:互联网 发布:登陆淘宝卖家中心 编辑:程序博客网 时间:2024/05/17 04:36

微笑微笑微笑效果图

微笑微笑微笑添加依赖

apply plugin: 'com.android.application'android {    compileSdkVersion 26    buildToolsVersion "26.0.2"    defaultConfig {        applicationId "samsung.com.yuekaomoni"        minSdkVersion 19        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 {    compile fileTree(dir: 'libs', include: ['*.jar'])    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {        exclude group: 'com.android.support', module: 'support-annotations'    })    compile 'com.android.support:appcompat-v7:26.+'    compile 'com.android.support.constraint:constraint-layout:1.0.2'    compile 'com.squareup.okhttp3:okhttp:3.9.1'    compile 'com.google.code.gson:gson:2.8.1'    compile 'com.github.bumptech.glide:glide:3.7.0'    testCompile 'junit:junit:4.12'    compile 'com.android.support:design:26.0.0-alpha1'    compile 'com.jcodecraeer:xrecyclerview:1.2.0'}
微笑微笑微笑添加权限

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="samsung.com.yuekaomoni">    <uses-permission android:name="android.permission.INTERNET" />    <application        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=".MainActivity">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>        <activity android:name=".recyclerDetails.RecyclerDetailsActivity" />        <activity android:name=".shoppingCar.ShoppingCartActivity" />        <activity android:name=".indent.IndentActivity" />        <activity android:name=".indent.IndentListActivity"></activity>    </application></manifest>
微笑微笑微笑layout 包下 activity_main 布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="samsung.com.yuekaomoni.MainActivity">    <ImageView        android:id="@+id/img"        android:layout_width="100dp"        android:layout_height="100dp"        android:layout_centerHorizontal="true"        android:src="@mipmap/ic_launcher"        /></RelativeLayout>
微笑微笑微笑layout 包下  activity_details  布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">    <android.support.v4.view.ViewPager        android:id="@+id/viewPager"        android:layout_width="match_parent"        android:layout_height="250dp"></android.support.v4.view.ViewPager>    <TextView        android:id="@+id/title"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/viewPager"        android:text="标题"        android:textSize="22sp" />    <TextView        android:id="@+id/price"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/title"        android:text="价格"        android:textColor="#F00"        android:textSize="22sp" />    <LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:orientation="horizontal"        android:layout_alignParentBottom="true"        >        <Button            android:id="@+id/shopcar"            android:layout_width="0dp"            android:layout_weight="1"            android:layout_height="50dp"            android:text="购物车"            android:onClick="shopcar"            />        <Button            android:id="@+id/join"            android:layout_width="0dp"            android:layout_weight="1"            android:layout_height="50dp"            android:text="加入购物车" />    </LinearLayout></RelativeLayout>
微笑微笑微笑layout  包下  activity_indent   布局

<?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.bwie.skn.moni.indent.IndentActivity">    <LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:orientation="horizontal"        android:layout_alignParentBottom="true"        >        <TextView            android:id="@+id/tv_price"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="8"            android:text="实付款¥0.00"            android:textSize="25dp"            android:textColor="@color/colorAccent"            android:gravity="right"            />        <Button            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="2"            android:text="立即下单"            android:onClick="indent"            />    </LinearLayout></RelativeLayout>
微笑微笑微笑layout   包下  activity_indent_list   布局

<?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.bwie.skn.moni.indent.IndentListActivity">    <android.support.design.widget.TabLayout        android:id="@+id/tl"        android:layout_width="match_parent"        android:layout_height="50dp"        app:tabGravity="fill"        app:tabIndicatorColor="@color/colorAccent"        app:tabMode="fixed"        app:tabTextColor="@color/colorPrimary"        />    <android.support.v4.view.ViewPager        android:id="@+id/vp"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_below="@+id/tl"        ></android.support.v4.view.ViewPager></RelativeLayout>
微笑微笑微笑layout  包下  activity_shoppingcar   布局

<?xml version="1.0" encoding="utf-8"?><LinearLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">    <RelativeLayout        android:id="@+id/car_title"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:background="#fff"        >        <TextView            android:layout_width="match_parent"            android:layout_height="match_parent"            android:gravity="center"            android:text="购物车"            android:textColor="#000"            android:textSize="35dp"            />        <TextView            android:id="@+id/edit_tv"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="1.5"            android:text="编辑"            android:textSize="20dp"            android:layout_marginRight="30dp"            android:layout_centerVertical="true"            android:layout_alignParentRight="true"            android:layout_alignParentEnd="true"            android:layout_marginEnd="30dp" />    </RelativeLayout>    <ExpandableListView        android:id="@+id/car_elv"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="9"        android:layout_below="@+id/car_title"></ExpandableListView>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:orientation="horizontal"        android:layout_gravity="bottom"        >        <CheckBox            android:id="@+id/chooseAll"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:textSize="25sp"            android:padding="10dp"            android:text="全选"/>        <TextView            android:id="@+id/totalPrice"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:textSize="25sp"            android:layout_weight="1"            android:padding="10dp"            android:gravity="center"            android:text="合计:0.00 "/>        <TextView            android:id="@+id/btnAmount"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="结算 : (0)"            android:gravity="center"            android:background="@android:color/holo_orange_light"            android:textColor="@android:color/black"            android:textSize="25sp"            android:padding="10dp"/>    </LinearLayout></LinearLayout>
微笑微笑微笑layout  包下  allfragment_layout   布局

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">    <com.jcodecraeer.xrecyclerview.XRecyclerView        android:id="@+id/xrecyclerview"        android:layout_width="match_parent"        android:layout_height="match_parent"></com.jcodecraeer.xrecyclerview.XRecyclerView></LinearLayout>
微笑微笑微笑layout   包下  child_layout   布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="horizontal" android:layout_width="match_parent"    android:layout_height="wrap_content">    <CheckBox        android:id="@+id/child_box"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_centerVertical="true"        android:layout_marginLeft="5dp"        android:scaleX="0.6"        android:scaleY="0.6" />    <ImageView        android:id="@+id/child_iv"        android:layout_width="70dp"        android:layout_height="80dp"        android:layout_centerVertical="true"        android:layout_marginLeft="5dp"        android:background="@mipmap/ic_launcher"        android:layout_toRightOf="@id/child_box" />    <LinearLayout        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="10dp"        android:layout_marginTop="15dp"        android:layout_toRightOf="@id/child_iv"        android:orientation="vertical">        <TextView            android:id="@+id/child_tv_name"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="酒红色纯红色纯羊毛西服套装"            android:textColor="@android:color/black"            android:textSize="12sp"            android:textStyle="bold" />        <LinearLayout            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:orientation="horizontal">            <TextView                android:id="@+id/child_tv_attr"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_marginTop="3dp"                android:text="属性:粉蓝色"                android:textSize="12sp"                android:textColor="@color/colorPrimary" />        </LinearLayout>        <LinearLayout            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginTop="4dp"            android:orientation="horizontal">            <TextView                android:id="@+id/child_tv_price"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="390"                android:textColor="@android:color/holo_red_dark"                android:textSize="12sp"                android:textStyle="bold" />            <TextView                android:id="@+id/child_tv_num"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_marginLeft="20dp"                android:text="x1"                android:textColor="@android:color/darker_gray" />            <LinearLayout                android:id="@+id/rl_edit"                android:layout_width="120dp"                android:background="@android:color/holo_orange_light"                android:layout_height="30dp"                android:layout_marginLeft="20dp"                >                <TextView                    android:id="@+id/child_tv_minus"                    android:layout_width="0dp"                    android:layout_weight="1"                    android:gravity="center"                    android:textColor="@android:color/black"                    android:background="@android:color/white"                    android:layout_margin="1dp"                    android:layout_height="match_parent"                    android:text=" - " />                <TextView                    android:id="@+id/child_tv_show_num"                    android:layout_width="0dp"                    android:layout_weight="1"                    android:gravity="center"                    android:background="@android:color/white"                    android:layout_margin="1dp"                    android:layout_height="match_parent"                    android:text="1"                    />                <TextView                    android:id="@+id/child_tv_add"                    android:layout_width="0dp"                    android:layout_weight="1"                    android:gravity="center"                    android:layout_margin="1dp"                    android:background="@android:color/white"                    android:layout_height="match_parent"                    android:text=" + " />            </LinearLayout>        </LinearLayout>    </LinearLayout>    <Button   android:id="@+id/delete"    android:layout_width="30dp"    android:layout_height="30dp"    android:layout_alignParentRight="true"    android:layout_centerVertical="true"    android:gravity="center"    android:text=""    android:background="@android:color/holo_blue_light"    android:textSize="20sp"    android:textColor="@android:color/holo_green_dark"    android:layout_margin="5dp"    android:visibility="visible" /></RelativeLayout>
微笑微笑微笑layout  包下 group_layout   布局

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="horizontal" android:layout_width="match_parent"    android:layout_height="match_parent">    <CheckBox        android:id="@+id/group_box"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />    <TextView        android:id="@+id/group_tv"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="商家"        /></LinearLayout>
微笑微笑微笑layout  包下  indent_item_layout   布局

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="horizontal" android:layout_width="match_parent"    android:layout_height="match_parent">    <LinearLayout        android:layout_width="0dp"        android:layout_weight="7"        android:layout_height="wrap_content"        android:orientation="vertical"        >        <TextView            android:id="@+id/title"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="订单测试标题3381"            />        <TextView            android:id="@+id/price"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="价格:1.10"            />        <TextView            android:id="@+id/createtime"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="0000-00-00T00:00:00"            />    </LinearLayout>    <LinearLayout        android:layout_width="0dp"        android:layout_weight="3"        android:layout_height="wrap_content"        android:orientation="vertical"        >        <TextView            android:id="@+id/status"            android:layout_width="wrap_content"            android:layout_height="0dp"            android:layout_weight="1"            android:text="未支付"            />        <Button            android:id="@+id/indentBtn"            android:layout_width="wrap_content"            android:layout_height="0dp"            android:layout_weight="2"            android:text="取消订单"            />        </LinearLayout></LinearLayout>
微笑微笑微笑layout  包下  layout_detailviewpager   布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent">    <ImageView        android:id="@+id/img"        android:scaleType="fitXY"        android:layout_width="match_parent"        android:layout_height="match_parent" /></RelativeLayout>
微笑微笑微笑主包下  MainActivity   类

package samsung.com.yuekaomoni;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.AnimationSet;import android.view.animation.RotateAnimation;import android.view.animation.ScaleAnimation;import android.view.animation.TranslateAnimation;import android.widget.ImageView;import samsung.com.yuekaomoni.recyclerDetails.RecyclerDetailsActivity;public class MainActivity extends AppCompatActivity {    private ImageView img;    private AnimationSet animationSet;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        img = (ImageView) findViewById(R.id.img);        initAnimates();//初始化动画        /**         * 动画的监听事件         */        animationSet.setAnimationListener(new Animation.AnimationListener() {            @Override            public void onAnimationStart(Animation animation) {            }            @Override            public void onAnimationEnd(Animation animation) {                /**                 * 结束监听的事件                 */                Intent intent = new Intent(MainActivity.this, RecyclerDetailsActivity.class);                startActivity(intent);                finish();            }            @Override            public void onAnimationRepeat(Animation animation) {            }        });    }    //初始化动画    private void initAnimates() {        //创建属性动画对象        animationSet = new AnimationSet(true);        /** 参数1:从哪个旋转角度开始         * 参数2:转到什么角度         * 4个参数用于设置围绕着旋转的圆的圆心在哪里         * 参数3:确定x轴坐标的类型,有ABSOLUT绝对坐标、RELATIVE_TO_SELF相对于自身坐标、RELATIVE_TO_PARENT相对于父控件的坐标         * 参数4x轴的值,0.5f表明是以自身这个控件的一半长度为x         * 参数5:确定y轴坐标的类型         * 参数6y轴的值,0.5f表明是以自身这个控件的一半长度为x         */        RotateAnimation rotateAnimation = new RotateAnimation(0, 360,                Animation.RELATIVE_TO_SELF, 0.5f,                Animation.RELATIVE_TO_SELF, 0.5f);        rotateAnimation.setDuration(3000);//        rotateAnimation.setFillAfter(true);        animationSet.addAnimation(rotateAnimation);        /**         * 移动         * 参数12x轴的开始位置         * 参数34y轴的开始位置         * 参数56x轴的结束位置         * 参数78x轴的结束位置         */        TranslateAnimation translateAnimation =                new TranslateAnimation(                        Animation.RELATIVE_TO_SELF, 0f,                        Animation.RELATIVE_TO_SELF, 0f,                        Animation.RELATIVE_TO_SELF, 0f,                        Animation.RELATIVE_TO_SELF, 3f);        translateAnimation.setDuration(3000);//        translateAnimation.setFillAfter(true);        animationSet.addAnimation(translateAnimation);        //创建一个AnimationSet对象,参数为Boolean型,        //true表示使用Animationinterpolatorfalse则是使用自己的        //创建一个AlphaAnimation对象,参数从完全的透明度,到完全的不透明        AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);        //设置动画执行的时间        alphaAnimation.setDuration(3000);//        alphaAnimation.setFillAfter(true);        animationSet.addAnimation(alphaAnimation);        //参数1x轴的初始值        //参数2x轴收缩后的值        //参数3y轴的初始值        //参数4y轴收缩后的值        //参数5:确定x轴坐标的类型        //参数6x轴的值,0.5f表明是以自身这个控件的一半长度为x        //参数7:确定y轴坐标的类型        //参数8y轴的值,0.5f表明是以自身这个控件的一半长度为x        ScaleAnimation scaleAnimation = new ScaleAnimation(                2, 1f, 2, 1f,                Animation.RELATIVE_TO_SELF, 0.5f,                Animation.RELATIVE_TO_SELF, 0.5f);        scaleAnimation.setDuration(3000);//        scaleAnimation.setFillAfter(true);        animationSet.addAnimation(scaleAnimation);        //使动画静止        animationSet.setFillAfter(true);        img.startAnimation(animationSet);    }}
微笑微笑微笑adapter  包下  CarExpandAdapter  类

package samsung.com.yuekaomoni.adapter;import android.content.Context;import android.view.View;import android.view.ViewGroup;import android.widget.BaseExpandableListAdapter;import android.widget.Button;import android.widget.CheckBox;import android.widget.ImageView;import android.widget.TextView;import android.widget.Toast;import com.bumptech.glide.Glide;import java.util.List;import samsung.com.yuekaomoni.R;import samsung.com.yuekaomoni.bean.Child;import samsung.com.yuekaomoni.bean.Group;import samsung.com.yuekaomoni.deleteShopping.DeletePresenter;import samsung.com.yuekaomoni.deleteShopping.DeleteView;import samsung.com.yuekaomoni.shoppingCar.ShoppingCartActivity;public class CarExpandAdapter extends BaseExpandableListAdapter{    private Context context;    private List<Group> groupList;    private List<List<Child>> childList;    private ShoppingCartActivity s;    public static boolean flog;    public CarExpandAdapter(Context context, List<Group> groupList, List<List<Child>> childList,ShoppingCartActivity s) {        this.context = context;        this.groupList = groupList;        this.childList = childList;        this.s = s;    }    @Override    public int getGroupCount() {        return groupList.size();    }    @Override    public int getChildrenCount(int i) {        return childList.get(i).size();    }    @Override    public Object getGroup(int i) {        return groupList.get(i);    }    @Override    public Object getChild(int i, int i1) {        return childList.get(i).get(i1);    }    @Override    public long getGroupId(int i) {        return i;    }    @Override    public long getChildId(int i, int i1) {        return i1;    }    @Override    public boolean hasStableIds() {        return false;    }    //第一级列表viewhodel    class GroupViewHolder{        CheckBox group_box;        TextView group_tv;    }    //第二级列表的viewhodel    class ChildViewHodel{        CheckBox child_box;        ImageView child_iv;        TextView child_tv_name;        TextView child_tv_attr;        TextView child_tv_price;        TextView child_tv_num;        TextView child_tv_minus;        TextView child_tv_show_num;        TextView child_tv_add;        Button delete;    }    @Override    public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {        final  GroupViewHolder holder;        if (view==null){            holder = new GroupViewHolder();            view = View.inflate(context, R.layout.group_layout,null);            holder.group_box = view.findViewById(R.id.group_box);            holder.group_tv = view.findViewById(R.id.group_tv);            view.setTag(holder);        }else{            holder = (GroupViewHolder) view.getTag();        }        holder.group_tv.setText(groupList.get(i).getName());        holder.group_box.setChecked(groupList.get(i).isFlag());        holder.group_box.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                //group布尔值变成选中状态                groupList.get(i).setFlag(holder.group_box.isChecked());                //遍历Group的集合                for (int i=0;i<groupList.size();i++){                    //如果有一个未选中  全选变成FALSE并跳出                    if (!groupList.get(i).isFlag()){                        s.getisAll(false);                        break;                    }else{                        s.getisAll(true);                    }                }                //Child集合布尔值为选中的状态                for (int j=0;j<childList.get(i).size();j++){                    childList.get(i).get(j).setFlag(holder.group_box.isChecked());                }                //刷新适配器                notifyDataSetChanged();                s.js();            }        });        return view;    }    @Override    public View getChildView(final int i, final int i1, boolean b, View view, ViewGroup viewGroup) {        final  ChildViewHodel hodel;        if (view == null){            hodel = new ChildViewHodel();            view = View.inflate(context, R.layout.child_layout,null);            hodel.child_box=view.findViewById(R.id.child_box);            hodel.child_iv = view.findViewById(R.id.child_iv);            hodel.child_tv_name = view.findViewById(R.id.child_tv_name);            hodel.child_tv_attr = view.findViewById(R.id.child_tv_attr);            hodel.child_tv_price = view.findViewById(R.id.child_tv_price);            hodel.child_tv_minus = view.findViewById(R.id.child_tv_minus);            hodel.child_tv_show_num = view.findViewById(R.id.child_tv_show_num);            hodel.child_tv_add = view.findViewById(R.id.child_tv_add);            hodel.child_tv_num = view.findViewById(R.id.child_tv_num);            hodel.delete=view.findViewById(R.id.delete);            view.setTag(hodel);        }else{            hodel = (ChildViewHodel) view.getTag();        }        hodel.child_tv_name.setText(childList.get(i).get(i1).getTitle());        hodel.child_tv_show_num.setText(childList.get(i).get(i1).getNum()+"");        hodel.child_tv_attr.setText(childList.get(i).get(i1).getColor());        hodel.child_tv_price.setText(childList.get(i).get(i1).getPrice()+"");        Glide.with(context).load(childList.get(i).get(i1).getImage().split("\\|")[0]).into(hodel.child_iv);        hodel.child_box.setChecked(childList.get(i).get(i1).isFlag());        hodel.delete.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                DeletePresenter presenter = new DeletePresenter(new DeleteView() {                    @Override                    public void onDeleteFailure(String error) {                        Toast.makeText(context, error, Toast.LENGTH_SHORT).show();                    }                    @Override                    public void onDeleteSuccesss(String code) {                        Toast.makeText(context, "删除成功", Toast.LENGTH_SHORT).show();                    }                });                int pid = childList.get(i).get(i1).getPid();                presenter.verfiy(3381+"",pid+"");                //从新请求网络                s.setSelectCar();                notifyDataSetChanged();            }        });        hodel.child_box.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                //Child布尔值变成选中状态                childList.get(i).get(i1).setFlag(hodel.child_box.isChecked());                //遍历Child集合                for (int i=0;i<childList.size();i++){                    for (int j=0;j<childList.get(i).size();j++){                        //如果有一个未选中     全选与商家按钮变成false并跳出                        if(!childList.get(i).get(j).isFlag()){                            groupList.get(i).setFlag(false);                            s.getisAll(false);                            break;                        }else{//全部选中  全选与商家按钮变成true                            groupList.get(i).setFlag(true);                            s.getisAll(false);                        }                    }                }                //二次遍历                for(int i=0;i<groupList.size();i++){                    boolean flag = groupList.get(i).isFlag();                    if(flag){                        s.getisAll(true);                    }else{                        s.getisAll(false);                        break;                    }                }                notifyDataSetChanged();                //计算加减                s.js();            }        });        ////        hodel.child_tv_minus.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                String num = hodel.child_tv_show_num.getText().toString();                int num1 =  Integer.parseInt(num);                num1--;                childList.get(i).get(i1).setNum(num1);                hodel.child_tv_show_num.setText(childList.get(i).get(i1).getNum()+"");                notifyDataSetChanged();                s.js();            }        });        hodel.child_tv_add.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                String num = hodel.child_tv_show_num.getText().toString();                int num1 =  Integer.parseInt(num);                num1++;                childList.get(i).get(i1).setNum(num1);                hodel.child_tv_show_num.setText(childList.get(i).get(i1).getNum()+"");                notifyDataSetChanged();                s.js();            }        });        return view;    }    @Override    public boolean isChildSelectable(int i, int i1) {        return false;    }}
微笑微笑微笑adapter   包下   DetailsAdapter   类

package samsung.com.yuekaomoni.adapter;import android.content.Context;import android.support.v4.view.PagerAdapter;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import com.bumptech.glide.Glide;import samsung.com.yuekaomoni.R;public class DetailsAdapter extends PagerAdapter {    private Context context;    private String[] split;    public DetailsAdapter(Context context, String[] split) {        this.context = context;        this.split = split;    }    @Override    public int getCount() {        return Integer.MAX_VALUE;    }    @Override    public Object instantiateItem(ViewGroup container, int position) {        View view = View.inflate(context, R.layout.layout_detailviewpager, null);        ImageView img = view.findViewById(R.id.img);        Glide.with(context).load(split[position%split.length]).into(img);        container.addView(view);        return view;    }    @Override    public void destroyItem(ViewGroup container, int position, Object object) {        container.removeView((View) object);    }    @Override    public boolean isViewFromObject(View view, Object object) {        return view==object;    }}
微笑微笑微笑bean  包下  AddShopCarBean   类

package samsung.com.yuekaomoni.bean;public class AddShopCarBean {    private String code;    private String msg;    public String getCode() {        return code;    }    public void setCode(String code) {        this.code = code;    }    public String getMsg() {        return msg;    }    public void setMsg(String msg) {        this.msg = msg;    }}
微笑微笑微笑bean  包下   Child   类

package samsung.com.yuekaomoni.bean;public class Child {    /*    false,    list.get(j).getTitle(),    (float) list.get(j).getPrice(),    list.get(j).getImages(),    list.get(j).getNum()     */    private boolean flag;    private String title;    private double price;    private String image;    private int num;    private String color;    private int pid;    public Child(boolean flag, String title, double price, String image, int num,String color,int pid) {        this.flag = flag;        this.title = title;        this.price = price;        this.image = image;        this.num = num;        this.color = color;        this.pid = pid;    }    public boolean isFlag() {        return flag;    }    public void setFlag(boolean flag) {        this.flag = flag;    }    public String getTitle() {        return title;    }    public void setTitle(String title) {        this.title = title;    }    public double getPrice() {        return price;    }    public void setPrice(double price) {        this.price = price;    }    public String getImage() {        return image;    }    public void setImage(String image) {        this.image = image;    }    public int getNum() {        return num;    }    public void setNum(int num) {        this.num = num;    }    public String getColor() {        return color;    }    public void setColor(String color) {        this.color = color;    }    public int getPid() {        return pid;    }    public void setPid(int pid) {        this.pid = pid;    }}

微笑微笑微笑bean包下   Group   类

package samsung.com.yuekaomoni.bean;public class Group {    private boolean flag;    private String name;    public Group(boolean flag, String name) {        this.flag = flag;        this.name = name;    }    public boolean isFlag() {        return flag;    }    public void setFlag(boolean flag) {        this.flag = flag;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }}
微笑微笑微笑bean  包下  RecyclerDetailsBean   类

package samsung.com.yuekaomoni.bean;public class RecyclerDetailsBean {    /**     * msg :     * seller : {"description":"我是商家17","icon":"http://120.27.23.105/images/icon.png","name":"商家17","productNums":999,"score":5,"sellerid":17}     * code : 0     * data : {"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","itemtype":1,"pid":1,"price":118,"pscid":1,"salenum":0,"sellerid":17,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}     */    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 : 我是商家17         * icon : http://120.27.23.105/images/icon.png         * name : 商家17         * productNums : 999         * score : 5.0         * sellerid : 17         */        private String description;        private String icon;        private String name;        private int productNums;        private double score;        private int sellerid;        public String getDescription() {            return description;        }        public void setDescription(String description) {            this.description = description;        }        public String getIcon() {            return icon;        }        public void setIcon(String icon) {            this.icon = icon;        }        public String getName() {            return name;        }        public void setName(String name) {            this.name = name;        }        public int getProductNums() {            return productNums;        }        public void setProductNums(int productNums) {            this.productNums = productNums;        }        public double getScore() {            return score;        }        public void setScore(double score) {            this.score = score;        }        public int getSellerid() {            return sellerid;        }        public void setSellerid(int sellerid) {            this.sellerid = sellerid;        }    }    public static class DataBean {        /**         * bargainPrice : 111.99         * createtime : 2017-10-14T21:39:05         * detailUrl : https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends         * images : https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg         * itemtype : 1         * pid : 1         * price : 118.0         * pscid : 1         * salenum : 0         * sellerid : 17         * subhead : 每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下         * title : 北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g         */        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    包下  SelectCarBean    类

package samsung.com.yuekaomoni.bean;import java.util.List;public class SelectCarBean {    /**     * msg : 请求成功     * code : 0     * data : [{"list":[{"bargainPrice":399,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/1439822107.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5887/201/859509257/69994/6bde9bf6/59224c24Ne854e14c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg","num":2,"pid":83,"price":444,"pscid":85,"selected":0,"sellerid":4,"subhead":"2件,总价打6.50","title":"Gap男装 休闲舒适简约水洗五袋直筒长裤紧身牛仔裤941825 深灰色 33/32(175/84A)"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":2,"pid":1,"price":118,"pscid":1,"selected":0,"sellerid":17,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家17","sellerid":"17"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":1,"pid":4,"price":999,"pscid":1,"selected":0,"sellerid":20,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家20","sellerid":"20"}]     */    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":399,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/1439822107.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5887/201/859509257/69994/6bde9bf6/59224c24Ne854e14c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg","num":2,"pid":83,"price":444,"pscid":85,"selected":0,"sellerid":4,"subhead":"2件,总价打6.50","title":"Gap男装 休闲舒适简约水洗五袋直筒长裤紧身牛仔裤941825 深灰色 33/32(175/84A)"}]         * sellerName : 商家4         * sellerid : 4         */        private String sellerName;        private String sellerid;        private List<ListBean> list;        public String getSellerName() {            return sellerName;        }        public void setSellerName(String sellerName) {            this.sellerName = sellerName;        }        public String getSellerid() {            return sellerid;        }        public void setSellerid(String sellerid) {            this.sellerid = sellerid;        }        public List<ListBean> getList() {            return list;        }        public void setList(List<ListBean> list) {            this.list = list;        }        public static class ListBean {            /**             * bargainPrice : 399.0             * createtime : 2017-10-14T21:38:26             * detailUrl : https://item.m.jd.com/product/1439822107.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends             * images : https://m.360buyimg.com/n0/jfs/t5887/201/859509257/69994/6bde9bf6/59224c24Ne854e14c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg             * num : 2             * pid : 83             * price : 444.0             * pscid : 85             * selected : 0             * sellerid : 4             * subhead : 2件,总价打6.50             * title : Gap男装 休闲舒适简约水洗五袋直筒长裤紧身牛仔裤941825 深灰色 33/32(175/84A)             */            private double bargainPrice;            private String createtime;            private String detailUrl;            private String images;            private int num;            private int pid;            private double price;            private int pscid;            private int selected;            private int sellerid;            private String subhead;            private String title;            public double getBargainPrice() {                return bargainPrice;            }            public void setBargainPrice(double bargainPrice) {                this.bargainPrice = bargainPrice;            }            public String getCreatetime() {                return createtime;            }            public void setCreatetime(String createtime) {                this.createtime = createtime;            }            public String getDetailUrl() {                return detailUrl;            }            public void setDetailUrl(String detailUrl) {                this.detailUrl = detailUrl;            }            public String getImages() {                return images;            }            public void setImages(String images) {                this.images = images;            }            public int getNum() {                return num;            }            public void setNum(int num) {                this.num = num;            }            public int getPid() {                return pid;            }            public void setPid(int pid) {                this.pid = pid;            }            public double getPrice() {                return price;            }            public void setPrice(double price) {                this.price = price;            }            public int getPscid() {                return pscid;            }            public void setPscid(int pscid) {                this.pscid = pscid;            }            public int getSelected() {                return selected;            }            public void setSelected(int selected) {                this.selected = selected;            }            public int getSellerid() {                return sellerid;            }            public void setSellerid(int sellerid) {                this.sellerid = sellerid;            }            public String getSubhead() {                return subhead;            }            public void setSubhead(String subhead) {                this.subhead = subhead;            }            public String getTitle() {                return title;            }            public void setTitle(String title) {                this.title = title;            }        }    }}
微笑微笑微笑deleteShopping  包下  DeteleModel    类

package samsung.com.yuekaomoni.deleteShopping;import org.json.JSONException;import org.json.JSONObject;import java.util.HashMap;import java.util.Map;import samsung.com.yuekaomoni.utils.Constant;import samsung.com.yuekaomoni.utils.OKHttpCallBack;import samsung.com.yuekaomoni.utils.OKHttpUtils;public class DeleteModel {    public void deleteverfy(String uid, String pid, final Deleteper deleteper){        Map<String,String> map=new HashMap<>();        map.put("uid",uid);        map.put("pid",pid);        OKHttpUtils.getInstance().doGet(Constant.DELETE, map, new OKHttpCallBack() {            @Override            public void onFailed(String msg) {                deleteper.onDeleteFailure("失败的请求");            }            @Override            public void onSuccess(String request) {                try {                    JSONObject object = new JSONObject(request);                    String code = object.optString("code");                    if ("0".equals(code)){                        String msg = object.optString("msg");                        deleteper.onDeleteSuccesss(msg);                    }else{                        String msg = object.optString("msg");                        deleteper.onDeleteFailure(msg);                    }                } catch (JSONException e) {                    e.printStackTrace();                }            }        });    }}
微笑微笑微笑deleteShopping  包下   Deleteper   接口

package samsung.com.yuekaomoni.deleteShopping;public interface Deleteper {    void onDeleteFailure(String error);    void onDeleteSuccesss(String code);}
微笑微笑微笑deleteShopping  包下   DeletePresenter   类

package samsung.com.yuekaomoni.deleteShopping;public class DeletePresenter implements Deleteper {    private DeleteView deleteView;    private final DeleteModel deleteModel;    public DeletePresenter(DeleteView deleteView){        this.deleteView=deleteView;        deleteModel = new DeleteModel();    }    public void verfiy(String uid,String pid){        deleteModel.deleteverfy(uid,pid,this);    }    @Override    public void onDeleteFailure(String error) {          deleteView.onDeleteFailure(error);    }    @Override    public void onDeleteSuccesss(String code) {         deleteView.onDeleteSuccesss(code);    }}
微笑微笑微笑deleteShopping  包下   DeleteView    接口

package samsung.com.yuekaomoni.deleteShopping;public interface DeleteView {    void onDeleteFailure(String error);    void onDeleteSuccesss(String code);}
微笑微笑微笑indent   包下   AllFragment   类

package samsung.com.yuekaomoni.indent;import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.support.v7.widget.DividerItemDecoration;import android.support.v7.widget.LinearLayoutManager;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import com.jcodecraeer.xrecyclerview.ProgressStyle;import com.jcodecraeer.xrecyclerview.XRecyclerView;import java.util.ArrayList;import java.util.List;import samsung.com.yuekaomoni.R;public class AllFragment extends Fragment implements IIndentListView {    private View view;    private XRecyclerView xrecyclerview;    private List<IndentListBean.DataBean> list = new ArrayList<>();    private XRAdapter xrAdapter;    private IndentListPresenter indentPresenter;    @Nullable    @Override    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {        view = inflater.inflate(R.layout.allfragment_layout,container,false);        return view;    }    @Override    public void onActivityCreated(@Nullable Bundle savedInstanceState) {        super.onActivityCreated(savedInstanceState);        indentPresenter = new IndentListPresenter(this);        indentPresenter.excuteSelectCarData(3381,1);        xrecyclerview = view.findViewById(R.id.xrecyclerview);        //设置可上拉        xrecyclerview.setPullRefreshEnabled(true);        xrecyclerview.setLoadingMoreEnabled(true);        //设置上拉下拉样式        xrecyclerview.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);        xrecyclerview.setLaodingMoreProgressStyle(ProgressStyle.BallClipRotate);        // 线性布局管理器   VERTICAL默认样式/竖向显示       第三个参数是数据是否到过来显示        LinearLayoutManager manager = new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false);        //添加分格线        xrecyclerview.addItemDecoration(new DividerItemDecoration(getActivity(),LinearLayoutManager.VERTICAL));        //添加布局管理器        xrecyclerview.setLayoutManager(manager);        //设置适配器    }    @Override    public void onSuccess(List<IndentListBean.DataBean> data) {        list.clear();        list.addAll(data);        xrAdapter = new XRAdapter(getActivity(), data);        xrecyclerview.setAdapter(xrAdapter);//        xrAdapter.notifyDataSetChanged();//        xrecyclerview.loadMoreComplete();    }    @Override    public void onFailed() {    }}
微笑微笑微笑indent   包下   IIndentListPresenter   接口

package samsung.com.yuekaomoni.indent;import java.util.List;public interface IIndentListPresenter {    void onSuccess(List<IndentListBean.DataBean> data);    void onFailed();}
微笑微笑微笑indent   包下   IIndentListView   接口

package samsung.com.yuekaomoni.indent;import java.util.List;public interface IIndentListView {    void onSuccess(List<IndentListBean.DataBean> data);    void onFailed();}
微笑微笑微笑indent   包下   IIndentPreasenter   接口

package samsung.com.yuekaomoni.indent;public interface IIndentPreasenter {    void onSuccess(String msg);    void onFailed(String msg);}
微笑微笑微笑indent   包下    IIndentView    接口

package samsung.com.yuekaomoni.indent;public interface IIndentView {    void onSuccess(String msg);    void onFailed(String msg);}
微笑微笑微笑indent   包下    IndentActivity   类

package samsung.com.yuekaomoni.indent;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.TextView;import android.widget.Toast;import samsung.com.yuekaomoni.R;public class IndentActivity extends AppCompatActivity implements IIndentView{    private TextView tv_price;    private IndentPresenter indentPresenter;    private String price;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_indent);        Intent intent = getIntent();        price = intent.getStringExtra("price");        tv_price = (TextView) findViewById(R.id.tv_price);        tv_price.setText(price +"");        indentPresenter = new IndentPresenter(this);    }    public void indent(View view){        double p = Double.parseDouble(price);        indentPresenter.excuteIndentData(3381,p);    }    @Override    public void onSuccess(String msg) {        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();        Intent intent = new Intent(IndentActivity.this, IndentListActivity.class);        intent.putExtra("price",tv_price.getText().toString());        startActivity(intent);    }    @Override    public void onFailed(String msg) {        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();    }}
微笑微笑微笑indent   包下  IndentListActivity    类

package samsung.com.yuekaomoni.indent;import android.os.Bundle;import android.support.design.widget.TabLayout;import android.support.v4.app.Fragment;import android.support.v4.app.FragmentManager;import android.support.v4.app.FragmentPagerAdapter;import android.support.v4.view.ViewPager;import android.support.v7.app.AppCompatActivity;import java.util.ArrayList;import java.util.List;import samsung.com.yuekaomoni.R;public class IndentListActivity extends AppCompatActivity {    private TabLayout tl;    private ViewPager vp;    private List<String> datas = new ArrayList<String>();    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_indent_list);        tl = (TabLayout) findViewById(R.id.tl);        vp = (ViewPager) findViewById(R.id.vp);        datas.add("全部");        datas.add("待支付");        datas.add("已支付");        datas.add("已取消");        vp.setAdapter(new MyAdapter(getSupportFragmentManager()));        //进行关联        tl.setupWithViewPager(vp);    }    class MyAdapter extends FragmentPagerAdapter {        //带参的构造方法        public MyAdapter(FragmentManager fm) {            super(fm);        }        @Override        public int getCount() {            return datas.size();        }        //返回选项卡的文本 ,,,添加选项卡        @Override        public CharSequence getPageTitle(int position) {            return datas.get(position);        }        @Override        public Fragment getItem(int position) {            return new AllFragment();        }    }}
微笑微笑微笑indent   包下   IndentListBean   类

package samsung.com.yuekaomoni.indent;import java.util.List;public class IndentListBean {    /**     * msg : 请求成功     * code : 0     * data : [{"createtime":"2017-12-20T11:25:46","orderid":3677,"price":99.99,"status":2,"title":"订单测试标题3381","uid":3381}]     * 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 {        /**         * createtime : 2017-12-20T11:25:46         * orderid : 3677         * price : 99.99         * status : 2         * title : 订单测试标题3381         * uid : 3381         */        private String createtime;        private int orderid;        private double price;        private int status;        private String title;        private int uid;        public String getCreatetime() {            return createtime;        }        public void setCreatetime(String createtime) {            this.createtime = createtime;        }        public int getOrderid() {            return orderid;        }        public void setOrderid(int orderid) {            this.orderid = orderid;        }        public double getPrice() {            return price;        }        public void setPrice(double price) {            this.price = price;        }        public int getStatus() {            return status;        }        public void setStatus(int status) {            this.status = status;        }        public String getTitle() {            return title;        }        public void setTitle(String title) {            this.title = title;        }        public int getUid() {            return uid;        }        public void setUid(int uid) {            this.uid = uid;        }    }}
微笑微笑微笑indent   包下  IndentListModel    l类   、

package samsung.com.yuekaomoni.indent;import java.util.HashMap;import java.util.List;import java.util.Map;import samsung.com.yuekaomoni.utils.GsonUtils;import samsung.com.yuekaomoni.utils.OKHttpCallBack;import samsung.com.yuekaomoni.utils.OKHttpUtils;/** * author:Created by Conan on 2017/12/20. */public class IndentListModel {    private Map<String,String> map = new HashMap<>();    public void verifySelectCarInfo(int uid,int page, final IIndentListPresenter iIndentPresenter){        map.put("uid",uid+"");        map.put("page",page+"");        OKHttpUtils.getInstance().doGet("http://120.27.23.105/product/getOrders", map, new OKHttpCallBack() {            @Override            public void onFailed(String msg) {                iIndentPresenter.onFailed();            }            @Override            public void onSuccess(String request) {                IndentListBean indentBean = GsonUtils.getInstance().fromJson(request, IndentListBean.class);                String code = indentBean.getCode();                if ("0".equals(code)){                    List<IndentListBean.DataBean> data = indentBean.getData();                    iIndentPresenter.onSuccess(data);                }else {                    iIndentPresenter.onFailed();                }            }        });    }}
微笑微笑微笑indent   包下  IndentListPresenter   类

package samsung.com.yuekaomoni.indent;import java.util.List;public class IndentListPresenter implements IIndentListPresenter {    private IIndentListView iIndentView;    private IndentListModel indentModel;    public IndentListPresenter(IIndentListView iIndentView){        this.iIndentView = iIndentView;        indentModel = new IndentListModel();    }    //执行集合信息    public void excuteSelectCarData(int uid,int page){        //传到model        indentModel.verifySelectCarInfo(uid,page,this);    }    @Override    public void onSuccess(List<IndentListBean.DataBean> data) {        iIndentView.onSuccess(data);    }    @Override    public void onFailed() {        iIndentView.onFailed();    }}
微笑微笑微笑indent   包下  IndentModel   类

package samsung.com.yuekaomoni.indent;import org.json.JSONException;import org.json.JSONObject;import java.util.HashMap;import java.util.Map;import samsung.com.yuekaomoni.utils.OKHttpCallBack;import samsung.com.yuekaomoni.utils.OKHttpUtils;public class IndentModel {    private Map<String,Object> map = new HashMap<>();    public void verifyIndentCarInfo(int uid,Double price, final IIndentPreasenter iIndentPresenter){        map.put("uid",uid);        map.put("price",price);        OKHttpUtils.getInstance().doGet2("http://120.27.23.105/product/createOrder", map, new OKHttpCallBack() {            @Override            public void onFailed(String msg) {                iIndentPresenter.onFailed("请求失败");            }            @Override            public void onSuccess(String request) {                try {                    JSONObject object = new JSONObject(request);                    String code = object.optString("code");                    String msg = object.optString("msg");                    if ("0".equals(code)){                        iIndentPresenter.onSuccess(msg);                    }else {                        iIndentPresenter.onFailed(msg);                    }                } catch (JSONException e) {                    e.printStackTrace();                }            }        });    }}
微笑微笑微笑indent   包下  IndentPresenter   类

package samsung.com.yuekaomoni.indent;public class IndentPresenter implements IIndentPreasenter{    private IIndentView iIndentView;    private IndentModel indentModel;    public IndentPresenter(IIndentView iIndentView){        this.iIndentView = iIndentView;        indentModel = new IndentModel();    }    //执行集合信息    public void excuteIndentData(int uid,double price){        //传到model        indentModel.verifyIndentCarInfo(uid,price,this);    }    @Override    public void onSuccess(String msg) {        iIndentView.onSuccess(msg);    }    @Override    public void onFailed(String msg) {        iIndentView.onFailed(msg);    }}
微笑微笑微笑indent   包下  XRAdapter   类

package samsung.com.yuekaomoni.indent;import android.content.Context;import android.support.v7.widget.RecyclerView;import android.util.Log;import android.view.View;import android.view.ViewGroup;import android.widget.Button;import android.widget.TextView;import java.util.List;import samsung.com.yuekaomoni.R;public class XRAdapter extends RecyclerView.Adapter<XRAdapter.ViewHolder>{    private Context context;    private List<IndentListBean.DataBean> list;    public XRAdapter(Context context, List<IndentListBean.DataBean> list) {        this.context = context;        this.list = list;    }    @Override    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {        View view = View.inflate(context, R.layout.indent_item_layout,null);        view.setMinimumWidth(620);        ViewHolder holder = new ViewHolder(view);        return holder;    }    @Override    public void onBindViewHolder(ViewHolder holder, int position) {        holder.title.setText(list.get(position).getTitle());        holder.price.setText(list.get(position).getPrice()+"");        holder.createtime.setText(list.get(position).getCreatetime());        int status = list.get(position).getStatus();        if (status==0){            holder.status.setText("待支付");            holder.indentBtn.setText("取消订单");        }else if (status==1){            holder.status.setText("已支付");            holder.indentBtn.setText("查看订单");        }else if(status==2){            holder.status.setText("已取消");            holder.indentBtn.setText("查看订单");        }    }    @Override    public int getItemCount() {        Log.e("IIII",list.size()+"");        return list.size();    }    class ViewHolder extends RecyclerView.ViewHolder{        TextView title;        TextView price;        TextView createtime;        TextView status;        Button indentBtn;        public ViewHolder(View itemView) {            super(itemView);            title = itemView.findViewById(R.id.title);            price = itemView.findViewById(R.id.price);            createtime = itemView.findViewById(R.id.createtime);            status = itemView.findViewById(R.id.status);            indentBtn = itemView.findViewById(R.id.indentBtn);        }    }}
微笑微笑微笑recyclerDetails   包下   AddShopCarModel   类

package samsung.com.yuekaomoni.recyclerDetails;import com.google.gson.Gson;import java.util.HashMap;import samsung.com.yuekaomoni.bean.AddShopCarBean;import samsung.com.yuekaomoni.utils.OKHttpCallBack;import samsung.com.yuekaomoni.utils.OKHttpUtils;public class AddShopCarModel {    public void receive(String source, String uid, String pid, final IAddShopCarModel iAddShopCarModel) {        OKHttpUtils instance = OKHttpUtils.getInstance();        HashMap<String, String> hashMap = new HashMap<>();        hashMap.put("uid",uid);        hashMap.put("pid",pid);        instance.doGet("http://120.27.23.105/product/addCart", hashMap, new OKHttpCallBack() {            @Override            public void onSuccess(String str) {                if(str!=null){                    Gson gson = new Gson();                    AddShopCarBean addShopCarBean = gson.fromJson(str, AddShopCarBean.class);                    if(addShopCarBean!=null){                        String msg = addShopCarBean.getMsg();                        iAddShopCarModel.onSuccess(msg);                    }                }            }            @Override            public void onFailed(String message) {                iAddShopCarModel.onFailed();            }        });    }}
微笑微笑微笑recycleDetails   包下   AddShopCarPresenter   类

package samsung.com.yuekaomoni.recyclerDetails;public class AddShopCarPresenter implements IAddShopCarModel {    private AddShopCarModel addShopCarModel;    private IAddShopCarPresenter iAddShopCarPresenter;    public AddShopCarPresenter(IAddShopCarPresenter iAddShopCarPresenter) {        this.iAddShopCarPresenter = iAddShopCarPresenter;        addShopCarModel = new AddShopCarModel();    }    public void receive(String source, String uid, String pid) {        addShopCarModel.receive(source,uid,pid,this);    }    @Override    public void onSuccess(String msg) {        iAddShopCarPresenter.onSuccess(msg);    }    @Override    public void onFailed() {        iAddShopCarPresenter.onFailed();    }}
微笑微笑微笑recycleDetails   包下   IAddShopCarModel  接口

package samsung.com.yuekaomoni.recyclerDetails;public interface IAddShopCarModel {    void onSuccess(String msg);    void onFailed();}
微笑微笑微笑recycleDetails   包下    IAddShopCarPresenter   接口

package samsung.com.yuekaomoni.recyclerDetails;public interface IAddShopCarPresenter {    void onSuccess(String msg);    void onFailed();}
微笑微笑微笑recycleDetails   包下    IRecyclerDetailsModel   接口

package samsung.com.yuekaomoni.recyclerDetails;import samsung.com.yuekaomoni.bean.RecyclerDetailsBean;public interface IRecyclerDetailsModel {    void onSuccess(RecyclerDetailsBean rdBean);    void onFailed();}
微笑微笑微笑recycleDetails   包下   IRecyclerDetailsPresenter    接口

package samsung.com.yuekaomoni.recyclerDetails;import samsung.com.yuekaomoni.bean.RecyclerDetailsBean;public interface IRecyclerDetailsPresenter {    void onSuccess(RecyclerDetailsBean rdBean);    void onFailed();}
微笑微笑微笑recyclerDetails   包下   RecyclerDetailsActivity    类

package samsung.com.yuekaomoni.recyclerDetails;import android.content.Intent;import android.os.Bundle;import android.support.v4.view.ViewPager;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import android.widget.ListView;import android.widget.TextView;import android.widget.Toast;import java.util.ArrayList;import samsung.com.yuekaomoni.R;import samsung.com.yuekaomoni.adapter.DetailsAdapter;import samsung.com.yuekaomoni.bean.RecyclerDetailsBean;import samsung.com.yuekaomoni.shoppingCar.ShoppingCartActivity;public class RecyclerDetailsActivity extends AppCompatActivity implements IRecyclerDetailsPresenter,IAddShopCarPresenter{    private int pid = 71;    private RecyclerDetailsPresenter recyclerDetailsPresenter;    private ListView listView;    private RecyclerDetailsBean.DataBean data;    private TextView title;    private TextView price;    private String urlImg;    private String[] split;    private String urlTitle;    private double urlPrice;    private ArrayList<String> lists = new ArrayList<String>();    private ViewPager viewPager;    private DetailsAdapter adapter;    private Button join;    private int pids;    private AddShopCarPresenter addShopCarPresenter;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_details);        viewPager = (ViewPager) findViewById(R.id.viewPager);        join = (Button) findViewById(R.id.join);        title = (TextView) findViewById(R.id.title);        price = (TextView) findViewById(R.id.price);        //Intent intent = getIntent();        //pid = intent.getIntExtra("pid", this.pid);        recyclerDetailsPresenter = new RecyclerDetailsPresenter(this);        recyclerDetailsPresenter.receive(pid + "");        addShopCarPresenter = new AddShopCarPresenter(this);    }    @Override    public void onSuccess(RecyclerDetailsBean rdBean) {        /**         * 从集合获取数据,并赋值         */        data = rdBean.getData();        pids = data.getPid();        urlImg = data.getImages();        split = urlImg.split("\\|");        urlTitle = data.getTitle();        urlPrice = data.getPrice();        title.setText(urlTitle);        price.setText(urlPrice + "");        /**         * 将图片做成无限轮播         * 配置适配器         */        adapter = new DetailsAdapter(RecyclerDetailsActivity.this, split);        viewPager.setAdapter(adapter);        /**         * 点击加入购物车的按钮         */        join.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                /*Toast.makeText(RecyclerDetailsActivity.this, ImageLoaderApp.sql.getInt("id", 0)+"", Toast.LENGTH_SHORT).show();*/                //传入加入购物车的字段                addShopCarPresenter.receive("android", 3381+"", pids + "");            }        });    }    @Override    public void onSuccess(String msg) {        Toast.makeText(RecyclerDetailsActivity.this, msg, Toast.LENGTH_SHORT).show();    }    @Override    public void onFailed() {    }    /**     * 跳转购物车     * @param view     */    public void shopcar(View view){        Intent intent = new Intent(RecyclerDetailsActivity.this, ShoppingCartActivity.class);        startActivity(intent);    }}
微笑微笑微笑recyclerDetails   包下    RecyclerDetailsModel   类

package samsung.com.yuekaomoni.recyclerDetails;import com.google.gson.Gson;import java.util.HashMap;import samsung.com.yuekaomoni.bean.RecyclerDetailsBean;import samsung.com.yuekaomoni.utils.OKHttpCallBack;import samsung.com.yuekaomoni.utils.OKHttpUtils;public class RecyclerDetailsModel {    public void receive(String pid, final IRecyclerDetailsModel iRecyclerDetailsModel) {        OKHttpUtils instance = OKHttpUtils.getInstance();        HashMap<String, String> hashMap = new HashMap<>();        hashMap.put("pid", pid);        instance.doGet("http://120.27.23.105/product/getProductDetail", hashMap, new OKHttpCallBack() {            @Override            public void onSuccess(String str) {                if (str != null) {                    Gson gson = new Gson();                    RecyclerDetailsBean rdBean = gson.fromJson(str, RecyclerDetailsBean.class);                    if (rdBean != null) {                        iRecyclerDetailsModel.onSuccess(rdBean);                    }                }            }            @Override            public void onFailed(String message) {                iRecyclerDetailsModel.onFailed();            }        });    }}
微笑微笑微笑recyclerDetails   包下   RecyclerDetailsPresenter    类

package samsung.com.yuekaomoni.recyclerDetails;import samsung.com.yuekaomoni.bean.RecyclerDetailsBean;public class RecyclerDetailsPresenter implements IRecyclerDetailsModel {    private RecyclerDetailsModel recyclerDetailsModel;    private IRecyclerDetailsPresenter irecyclerDetailsPresenter;    public RecyclerDetailsPresenter(IRecyclerDetailsPresenter irecyclerDetailsPresenter) {        this.irecyclerDetailsPresenter = irecyclerDetailsPresenter;        recyclerDetailsModel = new RecyclerDetailsModel();    }    public void receive(String pid) {        recyclerDetailsModel.receive(pid, this);    }    @Override    public void onSuccess(RecyclerDetailsBean rdBean) {        irecyclerDetailsPresenter.onSuccess(rdBean);    }    @Override    public void onFailed() {        irecyclerDetailsPresenter.onFailed();    }}
微笑微笑微笑shoppingCar  包下  ISelectCarPresenter   接口

package samsung.com.yuekaomoni.shoppingCar;import java.util.List;import samsung.com.yuekaomoni.bean.SelectCarBean;public interface ISelectCarPresenter {    void onFailed(String msg);    void onSuccess(List<SelectCarBean.DataBean> data);}
微笑微笑微笑shoppingCar  包下    ISelectCarView   接口

package samsung.com.yuekaomoni.shoppingCar;import java.util.List;import samsung.com.yuekaomoni.bean.SelectCarBean;public interface ISelectCarView {    void onFailed(String msg);    void onSuccess(List<SelectCarBean.DataBean> data);}
微笑微笑微笑shoppingCar  包下     SelectCarModel   类

package samsung.com.yuekaomoni.shoppingCar;import android.util.Log;import java.util.HashMap;import java.util.List;import java.util.Map;import samsung.com.yuekaomoni.bean.SelectCarBean;import samsung.com.yuekaomoni.utils.Constant;import samsung.com.yuekaomoni.utils.GsonUtils;import samsung.com.yuekaomoni.utils.OKHttpCallBack;import samsung.com.yuekaomoni.utils.OKHttpUtils;public class SelectCarModel {    private Map<String,String> map = new HashMap<>();    public void verifySelectCarInfo(int uid, final ISelectCarPresenter iSelectCarPresenter){        Log.e("selectcar",uid+"");        map.put("uid",uid+"");        OKHttpUtils.getInstance().doGet(Constant.SELECTCAR, map, new OKHttpCallBack() {            @Override            public void onFailed(String msg) {                iSelectCarPresenter.onFailed("请求失败");            }            @Override            public void onSuccess(String request) {                SelectCarBean selectCarBean = GsonUtils.getInstance().fromJson(request, SelectCarBean.class);                Log.e("CODEDELETE",selectCarBean.getCode());                String code = selectCarBean.getCode();                if ("0".equals(code)){                    List<SelectCarBean.DataBean> data = selectCarBean.getData();                    iSelectCarPresenter.onSuccess(data);                }else{                    iSelectCarPresenter.onFailed("请求失败");                }            }        });    }}
微笑微笑微笑shoppingCar   包下   SelectCarPresenter   类

package samsung.com.yuekaomoni.shoppingCar;import java.util.List;import samsung.com.yuekaomoni.bean.SelectCarBean;public class SelectCarPresenter implements ISelectCarPresenter{    private ISelectCarView iSelectCarView;    private SelectCarModel selectCarModel;    public SelectCarPresenter (ISelectCarView iSelectCarView){        this.iSelectCarView = iSelectCarView;        selectCarModel = new SelectCarModel();    }    //执行集合信息    public void excuteSelectCarData(int uid){        //传到model        selectCarModel.verifySelectCarInfo(uid,this);    }    @Override    public void onFailed(String msg) {        iSelectCarView.onFailed(msg);    }    @Override    public void onSuccess(List<SelectCarBean.DataBean> data) {        iSelectCarView.onSuccess(data);    }}
微笑微笑微笑shoppingCar   包下     ShoppingCarActivity   类

package samsung.com.yuekaomoni.shoppingCar;import android.content.Intent;import android.os.Bundle;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.TextView;import java.util.ArrayList;import java.util.List;import samsung.com.yuekaomoni.R;import samsung.com.yuekaomoni.adapter.CarExpandAdapter;import samsung.com.yuekaomoni.bean.Child;import samsung.com.yuekaomoni.bean.Group;import samsung.com.yuekaomoni.bean.SelectCarBean;import samsung.com.yuekaomoni.indent.IndentActivity;public class ShoppingCartActivity extends AppCompatActivity implements ISelectCarView,View.OnClickListener{    private boolean isLogin;    private SelectCarPresenter selectCarPresenter;    private ExpandableListView car_elv;    private List<Group> glist = new ArrayList<>();    private List<List<Child>> clist = new ArrayList<>();    private CarExpandAdapter carExpandAdapter;    private TextView edit_tv;    private CheckBox chooseAll;    private TextView totalPrice;    private TextView btnAmount;    private boolean isAll;    private double p;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_shoppingcar);        //初始化数据        init();        chooseAll.setOnClickListener(this);        btnAmount.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                Intent intent = new Intent(ShoppingCartActivity.this, IndentActivity.class);                intent.putExtra("price",p+"");                startActivity(intent);            }        });    }    /**     * 查询购物车     */    private void selectShoppingCar() {            selectCarPresenter = new SelectCarPresenter(this);            selectCarPresenter.excuteSelectCarData(3381);            carExpandAdapter = new CarExpandAdapter(this,glist,clist,this);            car_elv.setAdapter(carExpandAdapter);    }    /**     * 初始化属性     */    private void init() {        car_elv = (ExpandableListView) findViewById(R.id.car_elv);        edit_tv = (TextView) findViewById(R.id.edit_tv);        chooseAll = (CheckBox) findViewById(R.id.chooseAll);        totalPrice = (TextView) findViewById(R.id.totalPrice);        btnAmount = (TextView) findViewById(R.id.btnAmount);        //登录购物车        selectShoppingCar();    }    @Override    public void onFailed(String msg) {    }    @Override    public void onSuccess(List<SelectCarBean.DataBean> data) {        glist.clear();        clist.clear();        for(int i = 0;i<data.size();i++){            glist.add(new Group(false,data.get(i).getSellerName()));            List<SelectCarBean.DataBean.ListBean> list = data.get(i).getList();            List<Child> cl = new ArrayList<>();            for (int j = 0; j< list.size(); j++){                cl.add(new Child(false, list.get(j).getTitle(),list.get(j).getPrice(), list.get(j).getImages(), list.get(j).getNum(),list.get(j).getSubhead(),list.get(j).getPid()));            }            clist.add(cl);        }        for(int s = 0; s < carExpandAdapter.getGroupCount(); s++){            car_elv.expandGroup(s);        }        carExpandAdapter.notifyDataSetChanged();    }    @Override    public void onResume() {        super.onResume();        init();    }    /**     * 反选     * @param isAll     */    public void getisAll(Boolean isAll) {        chooseAll.setChecked(isAll);    }    /**     * 全选按钮     * @param view     */    @Override    public void onClick(View view) {        isAll = chooseAll.isChecked();        if (!(isAll==true)) {            for (int i = 0; i < glist.size(); i++) {                glist.get(i).setFlag(false);                Log.e("Song","123");            }            for (int i=0 ;i<clist.size();i++){                for (int j=0;j<clist.get(i).size();j++){                    clist.get(i).get(j).setFlag(false);                }            }            if (isAll==true){                isAll=false;            }            js();            carExpandAdapter.notifyDataSetChanged();        } else {            for (int i = 0; i < glist.size(); i++) {                glist.get(i).setFlag(true);            }            for (int i=0 ;i<clist.size();i++){                for (int j=0;j<clist.get(i).size();j++){                    clist.get(i).get(j).setFlag(true);                }            }            if (isAll==false){                isAll=true;            }            js();            carExpandAdapter.notifyDataSetChanged();        }    }    //结算    public void js(){        p = 0;        int s = 0;//选中商品数量        for(int i=0;i<clist.size();i++){            for(int j=0;j<clist.get(i).size();j++){                if(clist.get(i).get(j).isFlag()){                    double price = clist.get(i).get(j).getPrice();                    int num = clist.get(i).get(j).getNum();                    p += price * num;                    s++;                }            }        }        //DecimalFormat df   = new DecimalFormat("######0.00");        totalPrice.setText("总价:"+ p +"");        btnAmount.setText("结算:("+s+")");    }    /**     * 请求网络的方法     */    public void setSelectCar(){        selectCarPresenter.excuteSelectCarData(3381);    }}
微笑微笑微笑utils   包下   Constant   类

package samsung.com.yuekaomoni.utils;public class Constant {    //域名    private static final String HOST = "http://120.27.23.105/";    //首页广告(轮播图+京东秒杀+最底部的为你推荐)    public static final String HOMEAD = HOST+"ad/getAd";    //商品分类接口(此接口用于首页九宫格,和底部页签分类页)    public static final String HOMECATAGORY = HOST+"product/getCatagory";    //商品子分类接口    public static final String ClassifyPC=HOST+"product/getProductCatagory";    //登录接口    // http://120.27.23.105/user/login    public static final String Login=HOST+"user/login";    //注册接口http://120.27.23.105/user/reg    public static final String REG = HOST+"user/reg";    //根据关键字搜索商品    //http://120.27.23.105/product/searchProducts?keywords=笔记本&page=1    public static final String SEARCH = HOST+"product/searchProducts";    //查询购物车的接口http://120.27.23.105/product/getCarts    public static final String SELECTCAR = HOST+"product/getCarts";    //商品详情页 http://120.27.23.105/product/getProductDetail    public static final String DETAIL = HOST+"product/getProductDetail";    //商品删除    //http://120.27.23.105/product/deleteCart?uid=72&pid=1    public static final String DELETE = HOST+"product/deleteCart";}
微笑微笑微笑utils   包下   GsonUtils   类

package samsung.com.yuekaomoni.utils;import com.google.gson.Gson;public class GsonUtils {    private static Gson gson;        public static Gson getInstance(){            if(gson==null){                gson=new Gson();            }            return gson;        }}

微笑微笑微笑utils   包下     Intercept   类

package samsung.com.yuekaomoni.utils;import java.io.IOException;import okhttp3.HttpUrl;import okhttp3.Interceptor;import okhttp3.Request;import okhttp3.Response;public class Intercept 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);    }}
微笑微笑微笑utils   包下    OKHTTPCallBack   接口

package samsung.com.yuekaomoni.utils;public interface OKHttpCallBack {    void onFailed(String msg);    void onSuccess(String request);}
微笑微笑微笑utils   包下    OKHTTPUtils   类

package samsung.com.yuekaomoni.utils;import android.os.Handler;import android.util.Log;import java.io.IOException;import java.util.Map;import okhttp3.Call;import okhttp3.Callback;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.Response;public class OKHttpUtils {    private static OKHttpUtils okHttpUtils;    private static Handler handler = new Handler();    //私有化构造方法    public OKHttpUtils(){    }    /**     * 获取OKhttpClient实例化     */    public static OKHttpUtils getInstance(){        if(null == okHttpUtils){            synchronized (OKHttpUtils.class){                if (null == okHttpUtils){                    okHttpUtils = new OKHttpUtils();                }            }        }        return okHttpUtils;    }    /**     *  封装的异步Get请求     */    public void doGet(String path, Map<String,String>map, final OKHttpCallBack okHttpCallBack){        //创建一个字符串容器        StringBuilder sb = null;        if (null==map){            if (null ==sb){                sb = new StringBuilder();                sb.append(path);            }        }else {            for (String key:map.keySet()){                if (null == sb){                    sb = new StringBuilder();                    sb.append("?");                }else{                    sb.append("&");                }                sb.append(key).append("=").append(map.get(key));            }        }//        StringBuilder sb = new StringBuilder();//        sb.append(path).append("?");//        for(Map.Entry entry:map.entrySet()){//            sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&");//        }////        sb.deleteCharAt(sb.lastIndexOf("&"));        //Log.e("WWWWW",sb.toString());        //////////////////        OkHttpClient okHttpClient = new OkHttpClient.Builder()                .addInterceptor(new Intercept())                .build();        Request request = new Request.Builder()                .url(path+sb.toString())                .get()                .build();        //OKHttp 网络        Call call = okHttpClient.newCall(request);        //异步请求        call.enqueue(new Callback() {            @Override            public void onFailure(Call call, IOException e) {                //请求失败                Log.e("TAG","OK请求失败");                okHttpCallBack.onFailed(e.getMessage());            }            @Override            public void onResponse(Call call, final Response response) throws IOException {                final String str = response.body().string();                //请求成功                handler.post(new Runnable() {                    @Override                    public void run() {                        Log.e("TAG","请求成功"+str);                        okHttpCallBack.onSuccess(str) ;                    }                });            }        });    }    /**     *  封装的异步Int类型Get请求     */    public void doGet2(String path, Map<String,Object>map, final OKHttpCallBack okHttpCallBack){        //创建一个字符串容器        StringBuilder sb = null;        if (null==map){            if (null ==sb){                sb = new StringBuilder();                sb.append(path);            }        }else {            for (String key:map.keySet()){                if (null == sb){                    sb = new StringBuilder();                    sb.append("?");                }else{                    sb.append("&");                }                sb.append(key).append("=").append(map.get(key));            }        }//        StringBuilder sb = new StringBuilder();//        sb.append(path).append("?");//        for(Map.Entry entry:map.entrySet()){//            sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&");//        }////        sb.deleteCharAt(sb.lastIndexOf("&"));        //Log.e("WWWWW",sb.toString());        //////////////////        OkHttpClient okHttpClient = new OkHttpClient.Builder()                .addInterceptor(new Intercept())                .build();        Request request = new Request.Builder()                .url(path+sb.toString())                .get()                .build();        //OKHttp 网络        Call call = okHttpClient.newCall(request);        //异步请求        call.enqueue(new Callback() {            @Override            public void onFailure(Call call, IOException e) {                //请求失败                Log.e("TAG","OK请求失败");                okHttpCallBack.onFailed(e.getMessage());            }            @Override            public void onResponse(Call call, final Response response) throws IOException {                final String str = response.body().string();                //请求成功                handler.post(new Runnable() {                    @Override                    public void run() {                        Log.e("TAG","请求成功"+str);                        okHttpCallBack.onSuccess(str) ;                    }                });            }        });    }}