Retrofit+mvp+购物车

> 依赖

 

```

compile 'com.android.support:appcompat-v7:26.+'

compile'com.android.support.constraint:constraint-layout:1.0.2'

compile 'io.reactivex.rxjava2:rxjava:2.0.7'

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

compile 'com.squareup.retrofit2:retrofit:2.1.0'

compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'

compile 'com.squareup.retrofit2:converter-gson:2.1.0'

compile 'com.squareup.retrofit2:converter-scalars:2.1.0'

compile 'com.jakewharton:butterknife:8.8.1'

compile'com.android.support:recyclerview-v7:26.0.0-alpha1'

compile'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

compile 'com.facebook.fresco:fresco:0.12.0'

compile 'com.github.bumptech.glide:glide:3.7.0'

compile 'org.greenrobot:eventbus:3.1.1'

compile 'com.android.support:design:26.0.0-alpha1'

compile 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'

testCompile 'junit:junit:4.12'

annotationProcessor'com.jakewharton:butterknife-compiler:8.8.1'

```

 

> 权限

 

```

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

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

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

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

```

 

Utils

=====

 

> DownLoadFile

--------------

 

```

public class DownLoadFile {

    private staticfinal String SP_NAME = "download_file"; 

    private staticfinal String CURR_LENGTH = "curr_length"; 

    private staticfinal int DEFAULT_THREAD_COUNT = 4;//默认下载线程数 

    //以下为线程状态 

    private staticfinal String DOWNLOAD_INIT = "1"; 

    private staticfinal String DOWNLOAD_ING = "2"; 

    private staticfinal String DOWNLOAD_PAUSE = "3"; 

 

    private ContextmContext;

 

    private StringloadUrl;//网络获取的url 

    private StringfilePath;//下载到本地的path 

    private intthreadCount = DEFAULT_THREAD_COUNT;//下载线程数 

 

    private intfileLength;//文件总大小 

    //使用volatile防止多线程不安全 

    privatevolatile int currLength;//当前总共下载的大小 

    privatevolatile int runningThreadCount;//正在运行的线程数 

    privateThread[] mThreads; 

    private StringstateDownload = DOWNLOAD_INIT;//当前线程状态 

 

    privateDownLoadListener mDownLoadListener; 

 

    public voidsetOnDownLoadListener(DownLoadListener mDownLoadListener) { 

       this.mDownLoadListener = mDownLoadListener; 

    } 

 

    publicinterface DownLoadListener {

        //返回当前下载进度的百分比 

        voidgetProgress(int progress); 

 

        voidonComplete(); 

 

        void onFailure(); 

    } 

 

    publicDownLoadFile(Context mContext, String loadUrl, String filePath) { 

       this(mContext, loadUrl, filePath, DEFAULT_THREAD_COUNT, null); 

    } 

 

    publicDownLoadFile(Context mContext, String loadUrl, String filePath,DownLoadListener mDownLoadListener) { 

       this(mContext, loadUrl, filePath, DEFAULT_THREAD_COUNT,mDownLoadListener); 

    } 

 

    publicDownLoadFile(Context mContext, String loadUrl, String filePath, intthreadCount) { 

       this(mContext, loadUrl, filePath, threadCount, null); 

    } 

 

    publicDownLoadFile(Context mContext, String loadUrl, String filePath, intthreadCount, DownLoadListener mDownLoadListener) { 

       this.mContext = mContext; 

       this.loadUrl = loadUrl; 

       this.filePath = filePath; 

       this.threadCount = threadCount; 

       runningThreadCount = 0; 

       this.mDownLoadListener = mDownLoadListener; 

    } 

 

    /**

     * 开始下载

     */

    public voiddownLoad() {

        //在线程中运行,防止anr 

        newThread(new Runnable() { 

           @Override 

            publicvoid run() { 

                try{ 

                   //初始化数据 

                   if (mThreads == null) 

                       mThreads = new Thread[threadCount]; 

 

                   //建立连接请求 

                   URL url = new URL(loadUrl);

                   HttpURLConnection conn = (HttpURLConnection) url.openConnection();

                   conn.setConnectTimeout(5000); 

                   conn.setRequestMethod("GET"); 

                   int code = conn.getResponseCode();//获取返回码 

                   if (code == 200) {//请求成功,根据文件大小开始分多线程下载 

                        fileLength =conn.getContentLength(); 

                       //根据文件大小,先创建一个空文件 

                       //“r“——以只读方式打开。调用结果对象的任何 write 方法都将导致抛出 IOException。 

                       //“rw“——打开以便读取和写入。如果该文件尚不存在,则尝试创建该文件。 

                        //“rws“—— 打开以便读取和写入,对于 “rw”,还要求对文件的内容或元数据的每个更新都同步写入到底层存储设备。 

                       //“rwd“——打开以便读取和写入,对于 “rw”,还要求对文件内容的每个更新都同步写入到底层存储设备。 

                       RandomAccessFile raf = new RandomAccessFile(filePath, "rwd");

                        raf.setLength(fileLength); 

                       raf.close(); 

                       //计算各个线程下载的数据段 

                       int blockLength = fileLength / threadCount; 

 

                       SharedPreferences sp = mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);

                       //获取上次取消下载的进度,若没有则返回0 

                       currLength = sp.getInt(CURR_LENGTH, 0); 

                       for (int i = 0; i < threadCount; i++) { 

                            //开始位置,获取上次取消下载的进度,默认返回i*blockLength,即第i个线程开始下载的位置 

                            int startPosition =sp.getInt(SP_NAME + (i + 1), i * blockLength); 

                            //结束位置,-1是为了防止上一个线程和下一个线程重复下载衔接处数据 

                            int endPosition =(i + 1) * blockLength - 1; 

                            //将最后一个线程结束位置扩大,防止文件下载不完全,大了不影响,小了文件失效 

                            if ((i + 1) ==threadCount) 

                                endPosition =endPosition * 2; 

 

                            mThreads[i] = newDownThread(i + 1, startPosition, endPosition); 

                           mThreads[i].start(); 

                       } 

                   }else { 

                        handler.sendEmptyMessage(FAILURE); 

                   } 

                }catch (Exception e) { 

                   e.printStackTrace(); 

                   handler.sendEmptyMessage(FAILURE); 

               } 

            } 

       }).start(); 

    } 

 

    /**

     * 取消下载

     */ 

    protected voidcancel() { 

        if(mThreads != null) { 

            //若线程处于等待状态,则while循环处于阻塞状态,无法跳出循环,必须先唤醒线程,才能执行取消任务 

            if(stateDownload.equals(DOWNLOAD_PAUSE)) 

                onStart(); 

            for(Thread dt : mThreads) { 

               ((DownThread) dt).cancel(); 

            } 

        } 

    } 

 

    /**

     * 暂停下载

     */

    public voidonPause() {

        if(mThreads != null) 

            stateDownload= DOWNLOAD_PAUSE; 

    } 

 

    /**

     * 继续下载

     */

    public voidonStart() {

        if(mThreads != null) 

           synchronized (DOWNLOAD_PAUSE) { 

               stateDownload = DOWNLOAD_ING; 

               DOWNLOAD_PAUSE.notifyAll(); 

            } 

    } 

 

    public voidonDestroy() {

        if(mThreads != null) 

           mThreads = null; 

    } 

 

    private classDownThread extends Thread { 

 

        privateboolean isGoOn = true;//是否继续下载 

        private intthreadId; 

        private intstartPosition;//开始下载点 

        private intendPosition;//结束下载点 

        private intcurrPosition;//当前线程的下载进度 

 

        privateDownThread(int threadId, int startPosition, int endPosition) { 

           this.threadId = threadId; 

           this.startPosition = startPosition; 

           currPosition = startPosition; 

           this.endPosition = endPosition; 

           runningThreadCount++; 

        } 

 

       @Override 

        public voidrun() { 

           SharedPreferences sp = mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE); 

            try{ 

                URLurl = new URL(loadUrl); 

               HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 

               conn.setRequestMethod("GET"); 

               conn.setRequestProperty("Range", "bytes=" +startPosition + "-" + endPosition); 

                conn.setConnectTimeout(5000); 

                //若请求头加上Range这个参数,则返回状态码为206,而不是200 

                if(conn.getResponseCode() == 206) { 

                   InputStream is = conn.getInputStream();

                   RandomAccessFile raf = new RandomAccessFile(filePath,"rwd"); 

                   raf.seek(startPosition);//跳到指定位置开始写数据 

                   int len; 

                   byte[] buffer = new byte[1024]; 

                   while ((len = is.read(buffer)) != -1) { 

                       //是否继续下载 

                       if (!isGoOn) 

                            break; 

                       //回调当前进度 

                       if (mDownLoadListener != null) { 

                            currLength +=len; 

                            int progress = (int)((float) currLength / (float) fileLength * 100); 

                           handler.sendEmptyMessage(progress); 

                       } 

 

                       raf.write(buffer, 0, len); 

                        //写完后将当前指针后移,为取消下载时保存当前进度做准备 

                       currPosition += len; 

                       synchronized (DOWNLOAD_PAUSE) { 

                            if(stateDownload.equals(DOWNLOAD_PAUSE)) { 

                                DOWNLOAD_PAUSE.wait(); 

                            } 

                       } 

                   } 

                   is.close(); 

                   raf.close(); 

                   //线程计数器-1 

                   runningThreadCount--; 

                   //若取消下载,则直接返回 

                   if (!isGoOn) { 

                       //此处采用SharedPreferences保存每个线程的当前进度,和三个线程的总下载进度 

                       if (currPosition < endPosition) { 

                           sp.edit().putInt(SP_NAME + threadId, currPosition).apply(); 

                           sp.edit().putInt(CURR_LENGTH, currLength).apply(); 

                       } 

                       return; 

                   } 

                   if (runningThreadCount == 0) { 

                       sp.edit().clear().apply(); 

                       handler.sendEmptyMessage(SUCCESS); 

                       handler.sendEmptyMessage(100); 

                       mThreads = null; 

                   } 

                }else { 

                   sp.edit().clear().apply(); 

                   handler.sendEmptyMessage(FAILURE); 

               } 

            } catch(Exception e) { 

               sp.edit().clear().apply(); 

               e.printStackTrace(); 

               handler.sendEmptyMessage(FAILURE); 

            } 

        } 

 

        public voidcancel() { 

            isGoOn= false; 

        } 

    } 

 

    private finalint SUCCESS = 0x00000101; 

    private finalint FAILURE = 0x00000102; 

 

    private Handlerhandler = new Handler() {

       @Override 

        public voidhandleMessage(Message msg) {

 

            if(mDownLoadListener != null) { 

                if(msg.what == SUCCESS) { 

                   mDownLoadListener.onComplete(); 

                }else if (msg.what == FAILURE) { 

 

                   mDownLoadListener.onFailure(); 

                }else { 

                    mDownLoadListener.getProgress(msg.what); 

               } 

            } 

        } 

    }; 

```

 

> MyApp

-------

 

```

 

public class MyApp extends Application {

    @Override

    public voidonCreate() {

       super.onCreate();

        //配置磁盘缓存

       DiskCacheConfig diskSmallCacheConfig = DiskCacheConfig.newBuilder(this)

               .setBaseDirectoryPath(this.getCacheDir())//缓存图片基路径

               .setBaseDirectoryName(getString(R.string.app_name))//文件夹名

                .build();

       ImagePipelineConfig imagePipelineConfig =ImagePipelineConfig.newBuilder(this)

               .setBitmapsConfig(Bitmap.Config.RGB_565)

               .setSmallImageDiskCacheConfig(diskSmallCacheConfig)

               .build();

        //初始化Fresco

       Fresco.initialize(this, imagePipelineConfig);

    }

}

 

```

 

net

===

 

> ServiceApi

------------

 

```

public interface ServiceApi {

    //商品详情

   @GET(Urls.PRODUCTDETAIL)

   Observable<ProductDetailBean> getDetail(@Query("pid")String pid);

 

    //添加购物车

   @GET(Urls.ADDCART)

   Observable<AddCartBean> addCart(@Query("pid") Stringpid, @Query("uid") String uid);

 

    //查询购物车

   @GET(Urls.GETCARTS)

   Observable<CartBean> getCarts(@Query("uid") String uid);

 

}

```

 

> OnNetListener

---------------

 

```

public interface OnNetListener<T> {

    public voidonSuccess(T t);

 

    public voidonFailure(Throwable throwable);

}

```

 

> RetrofitHelper

----------------

 

```

public class RetrofitHelper {

    private staticOkHttpClient okHttpClient;

    private staticServiceApi serviceApi;

 

    static {

       initOkHttpClient();

    }

 

    /**

     * 创建OkHttpClient

     */

    private staticvoid initOkHttpClient() {

        if(okHttpClient == null) {

           synchronized (RetrofitHelper.class) {

                if(okHttpClient == null) {

                   //设置拦截器

                   HttpLoggingInterceptor logging = new HttpLoggingInterceptor();

                    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

                   okHttpClient = new OkHttpClient.Builder()

                           .addInterceptor(logging)//添加拦截器

                            .addInterceptor(newMyInterceptor())

                            .connectTimeout(5,TimeUnit.SECONDS)//设置连接超时

                            .build();

                }

            }

        }

    }

 

    /**

     * 定义一个泛型方法

     *

     * @paramtClass

     * @param url

     * @param<T>

     * @return

     */

    public static<T> T createAPi(Class<T> tClass, String url) {

        Retrofitretrofit = new Retrofit.Builder()

               .baseUrl(url)

               .client(okHttpClient)

               .addConverterFactory(GsonConverterFactory.create())

               .addCallAdapterFactory(RxJava2CallAdapterFactory.create())

               .build();

        returnretrofit.create(tClass);

    }

 

    /**

     * 初始化ServiceApi

     *

     * @return

     */

    public staticServiceApi getServiceApi() {

        if(serviceApi == null) {

           synchronized (ServiceApi.class) {

                if(serviceApi == null) {

                   serviceApi = createAPi(ServiceApi.class, Urls.BASE_URL);

                }

            }

        }

        returnserviceApi;

    }

 

    /**

     * 添加公共参数拦截器

     */

    static classMyInterceptor implements Interceptor {

 

        @Override

        publicResponse intercept(Chain chain) throws IOException {

            Requestrequest = chain.request();

            HttpUrlhttpUrl = request.url()

                   .newBuilder()

                   .addQueryParameter("source", "android")

                   .build();

            Requestbuild = request.newBuilder()

                   .url(httpUrl)

                    .build();

            returnchain.proceed(build);

        }

    }

}

 

```

 

> Urls

-----

 

```

public class Urls {

    public staticfinal String BASE_URL = "https://www.zhaoapi.cn/";

    //详情

    public staticfinal String PRODUCTDETAIL = "product/getProductDetail";

    //添加购物车

    public staticfinal String ADDCART = "product/addCart";

    //查询购物车

    public staticfinal String GETCARTS = "product/getCarts";

}

 

```

 

View层

=====

 

> MainActivity

--------------

 

```

public class MainActivity extends AppCompatActivityimplements View.OnClickListener{

    /**

     * 下载

     */

    private ButtonmBtXiazai;

    /**

     * 暂停

     */

    private ButtonmBtZanting;

    /**

     * 继续

     */

    private ButtonmBtJixu;

    privateProgressBar mPro;

    /**

     * 下载:0%

     */

    privateTextView mTvProgress;

    /**

     * 进入详情

     */

    private ButtonmBtXiangqing;

    privateDownLoadFile downLoadFile;

    @Override

    protected voidonCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_main);

        initView();

    }

    private voidinitView() {

        mBtXiazai =(Button) findViewById(R.id.bt_xiazai);

       mBtXiazai.setOnClickListener(this);

        mBtZanting= (Button) findViewById(R.id.bt_zanting);

       mBtZanting.setOnClickListener(this);

        mBtJixu =(Button) findViewById(R.id.bt_jixu);

       mBtJixu.setOnClickListener(this);

        mPro =(ProgressBar) findViewById(R.id.pro);

        mTvProgress= (TextView) findViewById(R.id.tv_progress);

       mBtXiangqing = (Button) findViewById(R.id.bt_xiangqing);

       mBtXiangqing.setOnClickListener(this);

        File f =new File(Environment.getExternalStorageDirectory() + "/wenjian/");

        if(!f.exists()) {

           f.mkdir();

        }

        //存储地址

        String path= Environment.getExternalStorageDirectory() + "/wenjian/ww.mp4";

        //设置最大度

       mPro.setMax(100);

        //实例化

       downLoadFile = new DownLoadFile(this,

               "http://mirror.aarnet.edu.au/pub/TED-talks/911Mothers_2010W-480p.mp4"

                ,path, 10, new DownLoadFile.DownLoadListener() {

           @Override

            publicvoid getProgress(int progress) {

               mTvProgress.setText("当前进度:" + progress + "%");

               mPro.setProgress(progress);

            }

 

           @Override

            publicvoid onComplete() {

               Toast.makeText(MainActivity.this, "下载完成", Toast.LENGTH_SHORT).show();

            }

 

           @Override

            publicvoid onFailure() {

               Toast.makeText(MainActivity.this, "下载失败", Toast.LENGTH_SHORT).show();

            }

        }

        );

    }

 

    @Override

    public voidonClick(View v) {

        switch(v.getId()) {

           default:

               break;

            caseR.id.bt_xiazai:

               downLoadFile.downLoad();

               break;

            caseR.id.bt_zanting:

               downLoadFile.onPause();

               break;

            caseR.id.bt_jixu:

               downLoadFile.onStart();

               break;

            caseR.id.bt_xiangqing:

               Intent intent = new Intent(MainActivity.this,ProductDetailActivity.class);

               startActivity(intent);

               break;

        }

    }

 

    @Override

    protected voidonDestroy() {

       super.onDestroy();

       downLoadFile.onDestroy();

    }

}

 

```

 

> CartActivity

--------------

 

```

public class CartActivity extends AppCompatActivityimplements ICartView{

    privateExpandableListView mElv;

    privateCheckBox mCbAll;

    /**

     * 全选

     */

    privateTextView mTvQuxuan;

    /**

     * 合计 :¥550.90

     */

    privateTextView mTvPrice;

    /**

     * 去支付(0)

     */

    privateTextView mTvNum;

    privateCartPresenter cartPresenter;

    privateList<List<CartBean.DataBean.ListBean>> lists;

    privateMyElvAdapter myElvAdapter;

    @Override

    protected voidonCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_cart);

        initView();

        //绑定EventBus

       EventBus.getDefault().register(this);

 

       cartPresenter = new CartPresenter(this);

       cartPresenter.getCart();

    }

    private voidinitView() {

        mElv =(ExpandableListView) findViewById(R.id.elv);

        mCbAll =(CheckBox) findViewById(R.id.cb_All);

        mTvQuxuan =(TextView) findViewById(R.id.tv_quxuan);

        mTvPrice =(TextView) findViewById(R.id.tv_price);

        mTvNum =(TextView) findViewById(R.id.tv_num);

       mTvNum.setOnClickListener(new View.OnClickListener() {

           @Override

            public voidonClick(View v) {

               Intent intent = new Intent(CartActivity.this,DingGoodsActivity.class);

               startActivity(intent);

            }

        });

 

        //全选

       mCbAll.setOnClickListener(new View.OnClickListener() {

            @Override

            publicvoid onClick(View v) {

               myElvAdapter.changeAllListCbState(mCbAll.isChecked());

            }

        });

    }

 

    @Override

    public voidgetCart(CartBean cartBean) {

        float price= 0;

        int num =0;

 

       List<CartBean.DataBean> dataBeans = cartBean.getData();

        lists = newArrayList<>();

        for (int i= 0; i < dataBeans.size(); i++) {

           List<CartBean.DataBean.ListBean> list =dataBeans.get(i).getList();

            lists.add(list);

        }

        //设置适配器

       myElvAdapter = new MyElvAdapter(this, dataBeans, lists);

       mElv.setAdapter(myElvAdapter);

        for (int i= 0; i < dataBeans.size(); i++) {

            //默认二级列表展开

           mElv.expandGroup(i);

        }

        //取消小箭头

       mElv.setGroupIndicator(null);

 

        //默认全选

        for (int i= 0; i < lists.size(); i++) {

            for(int j = 0; j < lists.get(i).size(); j++) {

               CartBean.DataBean.ListBean listBean = lists.get(i).get(j);

               price += listBean.getNum() * listBean.getPrice();

                num+= listBean.getNum();

            }

        }

       mTvNum.setText(num);

       mTvPrice.setText(price + "");

    }

 

    @Subscribe

    public voidonMessageEvent(MessageEvent event) {

       mCbAll.setChecked(event.isChecked());

    }

 

    @Subscribe

    public voidonMessageEvent(PriceAndCountEvent event) {

       mTvPrice.setText("合计:¥" +event.getPrice() * event.getCount());

       mTvPrice.setText("总额:¥" +event.getPrice() * event.getCount());

       mTvNum.setText("去结算(" +event.getCount() + ")");

    }

 

 

    /**

     * 取消绑定,防止内存溢出

     */

    @Override

    protected voidonDestroy() {

       super.onDestroy();

        //解除绑定

       EventBus.getDefault().unregister(this);

       cartPresenter.onDetach();

    }

}

 

```

 

> 接口

----

 

```

public interface ICartView {

    public voidgetCart(CartBean cartBean);

}

```

 

> ProductDetailActivity

-----------------------

 

```

 

public class ProductDetailActivity extendsAppCompatActivity implements View.OnClickListener, IProductDetailView {

    privateRecyclerView mXqRlv;

    privateImageView mIvGetcart;

    /**

     * 添加到购物车

     */

    private ButtonmBtAddcart;

    /**

     * 立即购买

     */

    private ButtonmBtTocart;

    privateProductDetailPresenter productDetailPresenter;

    @Override

    protected voidonCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_product_detail);

        initView();

        //设置布局管理器

       LinearLayoutManager layoutManager = new LinearLayoutManager(this);

        //加载线性布局

       mXqRlv.setLayoutManager(layoutManager);

 

       productDetailPresenter = new ProductDetailPresenter(this);

       productDetailPresenter.getProductDetail();

 

        /**

         * 播放视频

         */

        String path= Environment.getExternalStorageDirectory() + "/wenjian/ww.mp4";

        //Stringurl = Environment.getExternalStorageDirectory()+ "/wenjian/ww.mp4";

        newPlayerView(this)

               .setTitle("视屏播放")

               .setScaleType(PlayStateParams.fitparent)

               .hideMenu(true)

               .forbidTouch(false)

               .setPlaySource(path)

               .startPlay();

    }

    private voidinitView() {

        mXqRlv =(RecyclerView) findViewById(R.id.xq_rlv);

        mIvGetcart= (ImageView) findViewById(R.id.iv_getcart);

        mBtAddcart= (Button) findViewById(R.id.bt_addcart);

       mBtAddcart.setOnClickListener(this);

        mBtTocart =(Button) findViewById(R.id.bt_tocart);

       mBtTocart.setOnClickListener(this);

    }

 

    @Override

    public voidonClick(View v) {

        switch(v.getId()) {

            caseR.id.bt_addcart:

                //添加购物车

               productDetailPresenter.addCart();

               break;

            caseR.id.bt_tocart:

                //跳转到购物车

               Intent intent = new Intent(ProductDetailActivity.this,CartActivity.class);

               startActivity(intent);

               break;

        }

    }

 

    @Override

    public voidgetDetail(ProductDetailBean productDetailBean) {

       ProductDetailBean.DataBean dataBean = productDetailBean.getData();

       List<ProductDetailBean.DataBean> dataBeanList = newArrayList<>();

       dataBeanList.add(dataBean);

        //设置适配器

       DetailRlvAdapter detailRlvAdapter = new DetailRlvAdapter(this,dataBeanList);

        //展示数据

       mXqRlv.setAdapter(detailRlvAdapter);

    }

 

    @Override

    public voidaddCart(AddCartBean addCartBean) {

        if(addCartBean.getCode().equals("0")) {

           Toast.makeText(getApplicationContext(), addCartBean.getMsg(),Toast.LENGTH_SHORT).show();

        } else {

           Toast.makeText(getApplicationContext(), addCartBean.getMsg(),Toast.LENGTH_SHORT).show();

        }

    }

 

    /**

     * 取消绑定,防止内存溢出

     */

    @Override

    protected voidonDestroy() {

       super.onDestroy();

       productDetailPresenter.onDetach();

    }

}

 

```

 

> 接口

----

 

```

public interface IProductDetailView {

    //商品详情

    public voidgetDetail(ProductDetailBean productDetailBean);

 

    //添加购物车

    public voidaddCart(AddCartBean addCartBean);

}

```

 

> AddDeleteView

---------------

 

```

 

public class AddDeleteView extends LinearLayout {

    privateOnAddDelClickListener listener;

    privateEditText etNumber;

 

    //对外提供一个点击的回调接口

    publicinterface OnAddDelClickListener {

        voidonAddClick(View v);

 

        voidonDelClick(View v);

    }

 

    public voidsetOnAddDelClickListener(OnAddDelClickListener listener) {

        if(listener != null) {

           this.listener = listener;

        }

    }

 

    publicAddDeleteView(Context context) {

       this(context, null);

    }

 

    publicAddDeleteView(Context context, @Nullable AttributeSet attrs) {

        this(context,attrs, 0);

    }

 

    publicAddDeleteView(Context context, @Nullable AttributeSet attrs, int defStyleAttr){

       super(context, attrs, defStyleAttr);

 

       initView(context, attrs, defStyleAttr);

    }

 

    private voidinitView(Context context, AttributeSet attrs, int defStyleAttr) {

       View.inflate(context, R.layout.adddelete, this);

        TextViewtxtDelete = (TextView) findViewById(R.id.tv_delete);

        TextViewtxtAdd = (TextView) findViewById(R.id.tv_add);

        etNumber =(EditText) findViewById(R.id.ed_num);

 

 

        TypedArraytypedArray = context.obtainStyledAttributes(attrs,R.styleable.AddDeleteViewStyle);

 

        StringleftText = typedArray.getString(R.styleable.AddDeleteViewStyle_left_text);

        String rightText =typedArray.getString(R.styleable.AddDeleteViewStyle_right_text);

        StringmiddleText = typedArray.getString(R.styleable.AddDeleteViewStyle_middle_text);

 

       txtDelete.setText(leftText);

       txtAdd.setText(rightText);

       etNumber.setText(middleText);

 

        //回收

       typedArray.recycle();

 

 

       txtDelete.setOnClickListener(new OnClickListener() {

           @Override

            publicvoid onClick(View view) {

               listener.onDelClick(view);

            }

        });

 

       txtAdd.setOnClickListener(new OnClickListener() {

           @Override

            publicvoid onClick(View view) {

               listener.onAddClick(view);

            }

        });

 

    }

 

    //对外提供一个修改数字的方法

    public voidsetNumber(int number) {

        if (number> 0) {

           etNumber.setText(number + "");

        }

    }

 

    //对外提供一个获取当前数字的方法

    public intgetNumber() {

        Stringstring = etNumber.getText().toString();

        int i =Integer.parseInt(string);

        return i;

    }

}

 

```

 

> DingGoodsActivity

-------------------

 

```

 

public class DingGoodsActivity extends AppCompatActivity{

 

    @Override

    protected voidonCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_ding_goods);

    }

}

 

```

 

 presenter层

============

 

> CartPresenter

---------------

 

```

public class CartPresenter {

 

    privateICartView iCartView;

    private finalICartModel iCartModel;

 

    publicCartPresenter(ICartView iCartView) {

       this.iCartView = iCartView;

        iCartModel= new CartModel();

    }

 

    public voidgetCart() {

       iCartModel.getCarts("71", new OnNetListener<CartBean>(){

           @Override

            publicvoid onSuccess(CartBean cartBean) {

               iCartView.getCart(cartBean);

            }

 

           @Override

            publicvoid onFailure(Throwable throwable) {

 

            }

        });

    }

 

    //解绑,防止内存溢出

    public voidonDetach() {

        if(iCartView != null) {

           iCartView = null;

        }

    }

}

 

```

 

> ProductDetailPresenter

------------------------

 

```

public class ProductDetailPresenter {

    privateIProductDetailView iProductDetailView;

    private finalIProductDetailModel iProductDetailModel;

 

    publicProductDetailPresenter(IProductDetailView iProductDetailView) {

       this.iProductDetailView = iProductDetailView;

        iProductDetailModel= new ProductDetailModel();

    }

 

    /**

     * 商品详情

     */

    public voidgetProductDetail() {

       iProductDetailModel.getProductDetail("70", newOnNetListener<ProductDetailBean>() {

           @Override

            publicvoid onSuccess(ProductDetailBean productDetailBean) {

               iProductDetailView.getDetail(productDetailBean);

            }

 

           @Override

            publicvoid onFailure(Throwable throwable) {

 

            }

        });

    }

 

    /**

     * 添加购物车

     */

    public voidaddCart() {

       iProductDetailModel.addCart("70", "71", newOnNetListener<AddCartBean>() {

           @Override

            publicvoid onSuccess(AddCartBean addCartBean) {

               iProductDetailView.addCart(addCartBean);

            }

 

           @Override

            publicvoid onFailure(Throwable throwable) {

 

            }

        });

    }

 

    //解绑,防止内存溢出

    public voidonDetach() {

        if(iProductDetailView != null) {

           iProductDetailView = null;

        }

    }

}

 

```

 

model

=====

 

> CartModel

-----------

 

```

public class CartModel implements ICartModel {

 

    @Override

    public voidgetCarts(String uid, final OnNetListener<CartBean> onNetListener) {

        ServiceApiserviceApi = RetrofitHelper.getServiceApi();

       serviceApi.getCarts(uid)

               .subscribeOn(Schedulers.io())

               .observeOn(AndroidSchedulers.mainThread())

               .subscribe(new Consumer<CartBean>() {

                   @Override

                   public void accept(CartBean cartBean) throws Exception {

                       onNetListener.onSuccess(cartBean);

                   }

                },new Consumer<Throwable>() {

                   @Override

                   public void accept(Throwable throwable) throws Exception {

                       onNetListener.onFailure(throwable);

                   }

                });

    }

}

 

```

 

> 接口

----

 

```

public interface ICartModel {

    public voidgetCarts(String uid, OnNetListener<CartBean> onNetListener);

}

```

 

> ProductDetailModel

--------------------

 

```

public class ProductDetailModel implementsIProductDetailModel {

 

    @Override

    public voidgetProductDetail(String pid, final OnNetListener<ProductDetailBean>onNetListener) {

        ServiceApiserviceApi = RetrofitHelper.getServiceApi();

       serviceApi.getDetail(pid)

               .subscribeOn(Schedulers.io())

               .observeOn(AndroidSchedulers.mainThread())

               .subscribe(new Consumer<ProductDetailBean>() {

                   @Override

                   public void accept(ProductDetailBean productDetailBean) throws Exception{

                       onNetListener.onSuccess(productDetailBean);

                   }

                },new Consumer<Throwable>() {

                   @Override

                   public void accept(Throwable throwable) throws Exception {

                       onNetListener.onFailure(throwable);

                   }

                });

    }

 

    @Override

    public voidaddCart(String pid, String uid, final OnNetListener<AddCartBean>onNetListener) {

        ServiceApiserviceApi = RetrofitHelper.getServiceApi();

       serviceApi.addCart(pid, uid)

               .subscribeOn(Schedulers.io())

               .observeOn(AndroidSchedulers.mainThread())

               .subscribe(new Consumer<AddCartBean>() {

                   @Override

                   public void accept(AddCartBean addCartBean) throws Exception {

                       onNetListener.onSuccess(addCartBean);

                   }

                },new Consumer<Throwable>() {

                   @Override

                   public void accept(Throwable throwable) throws Exception {

                       onNetListener.onFailure(throwable);

                   }

                });

 

    }

}

 

```

 

> 接口

----

 

```

public interface IProductDetailModel {

    public voidgetProductDetail(String pid, OnNetListener<ProductDetailBean>onNetListener);

 

    public voidaddCart(String pid, String uid, OnNetListener<AddCartBean>onNetListener);

}

 

```

 

Adapter

=======

 

> DetailRlvAdapter

------------------

 

```

 

public class DetailRlvAdapter extendsRecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Contextcontext;

    privateList<ProductDetailBean.DataBean> dataList;

    privateLayoutInflater inflater;

 

    publicDetailRlvAdapter(Context context, List<ProductDetailBean.DataBean>dataList) {

       this.context = context;

       this.dataList = dataList;

        inflater =LayoutInflater.from(context);

    }

 

    @Override

    publicRecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view =inflater.inflate(R.layout.detail_rlv_adapter_item, null);

        return newMyViewHplder(view);

    }

 

    @Override

    public voidonBindViewHolder(RecyclerView.ViewHolder holder, int position) {

       MyViewHplder myViewHplder = (MyViewHplder) holder;

 

       ProductDetailBean.DataBean dataBean = dataList.get(position);

 

        String[]images = dataBean.getImages().split("\\!");

       myViewHplder.mDetailAdapterSdv.setImageURI(images[0]);

       myViewHplder.mTvDetailTitle.setText(dataBean.getTitle());

       myViewHplder.mTvDetailPrice.setText("¥" + dataBean.getPrice());

       myViewHplder.mTvDetailSj.setText("我是商家" + dataBean.getSellerid());

    }

 

    @Override

    public intgetItemCount() {

        if(dataList == null) {

            return0;

        }

        returndataList.size();

    }

 

    classMyViewHplder extends RecyclerView.ViewHolder {

       SimpleDraweeView mDetailAdapterSdv;

        TextViewmTvDetailTitle;

        TextViewmTvDetailPrice;

        TextViewmTvDetailSj;

 

        publicMyViewHplder(View itemView) {

           super(itemView);

           mDetailAdapterSdv = (SimpleDraweeView)itemView.findViewById(R.id.detail_adapter_sdv);

            mTvDetailTitle = (TextView)itemView.findViewById(R.id.tv_detail_title);

           mTvDetailPrice = (TextView) itemView.findViewById(R.id.tv_detail_price);

           mTvDetailSj = (TextView) itemView.findViewById(R.id.tv_detail_sj);

        }

    }

 

}

 

```

 

> MyElvAdapter

--------------

 

```

public class MyElvAdapter extendsBaseExpandableListAdapter {

    private Contextcontext;

        privateList<CartBean.DataBean> groupList;

        privateList<List<CartBean.DataBean.ListBean>> childList;

        privateLayoutInflater inflater;

 

        publicMyElvAdapter(Context context, List<CartBean.DataBean> groupList,List<List<CartBean.DataBean.ListBean>> childList) {

           this.context = context;

           this.groupList = groupList;

            this.childList = childList;

           inflater = LayoutInflater.from(context);

        }

 

        @Override

        public intgetGroupCount() {

            returngroupList.size();

        }

 

        @Override

        public intgetChildrenCount(int groupPosition) {

            returnchildList.get(groupPosition).size();

        }

 

        @Override

        publicObject getGroup(int groupPosition) {

            returngroupList.get(groupPosition);

        }

 

        @Override

        publicObject getChild(int groupPosition, int childPosition) {

            returnchildList.get(groupPosition).get(childPosition);

        }

 

        @Override

        public longgetGroupId(int groupPosition) {

            returngroupPosition;

        }

 

        @Override

        public longgetChildId(int groupPosition, int childPosition) {

            returnchildPosition;

        }

 

        @Override

        publicboolean hasStableIds() {

            returnfalse;

        }

 

        @Override

        public ViewgetGroupView(final int groupPosition, boolean isExpanded, View convertView,ViewGroup parent) {

            Viewview;

            finalGroupViewHolder holder;

            if(convertView == null) {

                holder= new GroupViewHolder();

               view = inflater.inflate(R.layout.cart_group_item, null);

               holder.cb_group = view.findViewById(R.id.cb_group);

               holder.tv_dian = view.findViewById(R.id.gou_dian);

                view.setTag(holder);

            } else{

               view = convertView;

               holder = (GroupViewHolder) view.getTag();

            }

            finalCartBean.DataBean dataBean = groupList.get(groupPosition);

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

           holder.tv_dian.setText(dataBean.getSellerName());

            //一级列表的Checkbox

           holder.cb_group.setOnClickListener(new View.OnClickListener() {

               @Override

               public void onClick(View v) {

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

                   //当一级选中时,改变二级列表CheckBox状态

                   changeChildCbState(groupPosition, holder.cb_group.isChecked());

                    //将对应的数量和价格传到PriceAndCountEvent

                   EventBus.getDefault().post(computer());

                   //当一级的全部选中是,改变全选CheckBox状态

                   changeAllCbState(isAllGroupCbSelected());

                   //刷新列表

                    notifyDataSetChanged();

                }

            });

            returnview;

        }

 

        @Override

        public ViewgetChildView(final int groupPosition, final int childPosition, booleanisLastChild, View convertView, ViewGroup parent) {

            Viewview;

            finalChildViewHolder holder;

            if(convertView == null) {

               holder = new ChildViewHolder();

               view = inflater.inflate(R.layout.cart_child_item, null);

               holder.cb_child = view.findViewById(R.id.cb_child);

               holder.del = view.findViewById(R.id.del);

               holder.sdv = view.findViewById(R.id.child_sdv);

               holder.adv_main = view.findViewById(R.id.adv_main);

               holder.tv_info = view.findViewById(R.id.child_info);

               holder.tv_price = view.findViewById(R.id.child_price);

               holder.tv_tit = view.findViewById(R.id.child_tit);

               view.setTag(holder);

            } else{

               view = convertView;

               holder = (ChildViewHolder) view.getTag();

            }

            finalCartBean.DataBean.ListBean listBean =childList.get(groupPosition).get(childPosition);

           holder.cb_child.setChecked(listBean.isChecked());

           String[] strings = listBean.getImages().split("\\!");

           holder.sdv.setImageURI(strings[0]);

           holder.tv_tit.setText(listBean.getSubhead());

           holder.tv_info.setText("日期:"+listBean.getCreatetime());

           holder.tv_price.setText("¥"+ listBean.getBargainPrice());

            //给二级CheckBox设置点击事件

           holder.cb_child.setOnClickListener(new View.OnClickListener() {

               @Override

               public void onClick(View v) {

                   //设置该条目对象里的checked属性值

                   listBean.setChecked(holder.cb_child.isChecked());

                   PriceAndCountEvent priceAndCountEvent = computer();

                   EventBus.getDefault().post(priceAndCountEvent);

 

                   if (holder.cb_child.isChecked()) {

                       //当前checkbox是选中状态

                       if (isAllChildCbSelected(groupPosition)) {

                           changeGroupCbState(groupPosition, true);

                           changeAllCbState(isAllGroupCbSelected());

                       }

                   } else {

                       changeGroupCbState(groupPosition, false);

                       changeAllCbState(isAllGroupCbSelected());

                   }

                   notifyDataSetChanged();

                }

            });

            //自定义View加减号

           holder.adv_main.setOnAddDelClickListener(newAddDeleteView.OnAddDelClickListener() {

               @Override

                public void onAddClick(View v) {

                   //加号

                   int num = listBean.getNum();

                   holder.adv_main.setNumber(++num);

                   listBean.setNum(num);

                   if (holder.cb_child.isChecked()) {

                       PriceAndCountEvent priceAndCountEvent = computer();

                       EventBus.getDefault().post(computer());

                   }

                }

 

               @Override

               public void onDelClick(View v) {

                   //减号

                   int num = listBean.getNum();

                   if (num == 1) {

                       return;

                   }

                   holder.adv_main.setNumber(--num);

                   listBean.setNum(num);

                   if (holder.cb_child.isChecked()) {

                       PriceAndCountEvent priceAndCountEvent = computer();

                       EventBus.getDefault().post(computer());

                    }

                }

            });

 

           holder.del.setOnLongClickListener(new View.OnLongClickListener() {

               @Override

               public boolean onLongClick(View view) {

                   AlertDialog.Builder builder = new AlertDialog.Builder(context);

                   builder.setIcon(R.mipmap.ic_launcher_round)

                            .setTitle("删除商品")

                            .setMessage("确定删除商品吗?");

                   builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {

                       @Override

                       public void onClick(DialogInterface dialog, int which) {

                           List<CartBean.DataBean.ListBean> datasBeen =childList.get(groupPosition);

                           CartBean.DataBean.ListBean remove = datasBeen.remove(childPosition);

                            if(datasBeen.size() == 0) {

                               childList.remove(groupPosition);

                               groupList.remove(groupPosition);

                            }

                           EventBus.getDefault().post(computer());

                           notifyDataSetChanged();

                       }

                   });

                   builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {

                       @Override

                       public void onClick(DialogInterface dialog, int which) {

                           Toast.makeText(context,"您取消了删除" + which,Toast.LENGTH_SHORT).show();

                       }

                   });

                   builder.show();

                   return true;

                }

            });

            returnview;

        }

 

        @Override

        publicboolean isChildSelectable(int groupPosition, int childPosition) {

            returntrue;

        }

 

        classGroupViewHolder {

           CheckBox cb_group;

           TextView tv_dian;

        }

 

        class ChildViewHolder {

           LinearLayout del;

           CheckBox cb_child;

           SimpleDraweeView sdv;

           TextView tv_tit;

           TextView tv_info;

           TextView tv_price;

           AddDeleteView adv_main;

        }

 

        /**

         * 改变全选CheckBox状态

         *

         * @paramflag

         */

        privatevoid changeAllCbState(boolean flag) {

           MessageEvent messageEvent = new MessageEvent();

           messageEvent.setChecked(flag);

           EventBus.getDefault().post(messageEvent);

        }

 

        /**

         * 改变二级列表CheckBox状态

         *

         * @paramgroupPosition

         * @paramflag

         */

        privatevoid changeChildCbState(int groupPosition, boolean flag) {

           List<CartBean.DataBean.ListBean> listBeans =childList.get(groupPosition);

            for(int i = 0; i < listBeans.size(); i++) {

               CartBean.DataBean.ListBean listBean = listBeans.get(i);

               listBean.setChecked(flag);

            }

        }

 

        /**

         * 改变一级列表CheckBox状态

         *

         * @paramgroupPosition

         * @paramflag

         */

        privatevoid changeGroupCbState(int groupPosition, boolean flag) {

           CartBean.DataBean dataBean = groupList.get(groupPosition);

           dataBean.setChecked(flag);

        }

 

        /**

         * 判断一级列表是否全部选中

         *

         * @return

         */

        publicboolean isAllGroupCbSelected() {

            for (int i = 0; i < groupList.size();i++) {

               CartBean.DataBean dataBean = groupList.get(i);

                if(!dataBean.isChecked()) {

                   return false;

                }

            }

            returntrue;

        }

 

        /**

         * 判断二级列表是否全部选中

         *

         * @paramgroupPosition

         * @return

         */

        publicboolean isAllChildCbSelected(int groupPosition) {

           List<CartBean.DataBean.ListBean> listBeans =childList.get(groupPosition);

            for(int i = 0; i < listBeans.size(); i++) {

               CartBean.DataBean.ListBean listBean = listBeans.get(i);

                if(!listBean.isChecked()) {

                   return false;

                }

            }

            returntrue;

        }

 

        /**

         * 设置全选、反选

         *

         * @paramflag

         */

        public voidchangeAllListCbState(boolean flag) {

            for(int i = 0; i < groupList.size(); i++) {

                //改变一级列表CheckBox状态

               changeGroupCbState(i, flag);

                //改变二级列表CheckBox状态

               changeChildCbState(i, flag);

            }

            //将数量和价格传值

           EventBus.getDefault().post(computer());

            //刷新列表

           notifyDataSetChanged();

        }

 

        /**

         * 计算列表中选中的钱和数量

         *

         * @return

         */

        privatePriceAndCountEvent computer() {

            intcount = 0;

            intprice = 0;

            for(int i = 0; i < childList.size(); i++) {

               List<CartBean.DataBean.ListBean> listBeans = childList.get(i);

                for(int j = 0; j < listBeans.size(); j++) {

                    CartBean.DataBean.ListBean listBean =listBeans.get(j);

                   if (listBean.isChecked()) {

                       count += listBean.getNum();

                       price += listBean.getNum() * listBean.getPrice();

                   }

                }

            }

           PriceAndCountEvent priceAndCountEvent = new PriceAndCountEvent();

           priceAndCountEvent.setCount(count);

           priceAndCountEvent.setPrice(price);

            returnpriceAndCountEvent;

        }

}

 

```

 

eventbus

========

 

> MessageEvent

--------------

 

```

public class MessageEvent {

    public booleanchecked;

 

    public booleanisChecked() {

        returnchecked;

    }

 

    public voidsetChecked(boolean checked) {

       this.checked = checked;

    }

}

 

```

 

> PriceAndCountEvent

--------------------

 

```

public class PriceAndCountEvent {

    private intprice;

    private intcount;

 

    public intgetPrice() {

        returnprice;

    }

 

    public voidsetPrice(int price) {

        this.price= price;

    }

 

    public intgetCount() {

        returncount;

    }

 

    public voidsetCount(int count) {

        this.count= count;

    }

}

 

```

 

Bean

====

 

> AddCartBean

-------------

 

```

package com.bwie.moni_demo.bean;

 

/**

 * Created byliyongkai on 2018-03-05.

 */

 

public class AddCartBean {

    /**

     * msg : 加购成功

     * code : 0

     */

 

    private Stringmsg;

    private Stringcode;

 

    public StringgetMsg() {

        return msg;

    }

 

    public voidsetMsg(String msg) {

        this.msg =msg;

    }

 

    public StringgetCode() {

        returncode;

    }

 

    public voidsetCode(String code) {

        this.code =code;

    }

}

 

```

 

> CartBean

----------

 

```

package com.bwie.moni_demo.bean;

 

import java.util.List;

 

/**

 * Created byliyongkai on 2018-03-05.

 */

 

public class CartBean {

 

 

    /**

     * msg : 请求成功

     * code : 0

     * data :[{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","num":3,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"}],"sellerName":"商家2","sellerid":"2"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:48:08","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":3,"pid":60,"price":13888,"pscid":40,"selected":0,"sellerid":4,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bari5/8G/256G"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-03T23:43:53","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":12,"price":256,"pscid":1,"selected":0,"sellerid":5,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家5","sellerid":"5"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-03T23:53:28","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":8,"pid":17,"price":299,"pscid":1,"selected":0,"sellerid":10,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家10","sellerid":"10"},{"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":3,"pid":18,"price":399,"pscid":1,"selected":0,"sellerid":11,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家11","sellerid":"11"},{"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":3,"pid":19,"price":499,"pscid":1,"selected":0,"sellerid":12,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家12","sellerid":"12"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":70,"price":17999,"pscid":40,"selected":0,"sellerid":14,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bari5/8G/256G"}],"sellerName":"商家14","sellerid":"14"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":8,"pid":71,"price":32999,"pscid":40,"selected":0,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bari5/8G/256G"}],"sellerName":"商家15","sellerid":"15"},{"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":9,"pid":1,"price":118,"pscid":1,"selected":0,"sellerid":17,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家17","sellerid":"17"}]

     */

 

    private Stringmsg;

    private Stringcode;

    privateList<DataBean> data;

 

    public StringgetMsg() {

        return msg;

    }

 

    public voidsetMsg(String msg) {

        this.msg =msg;

    }

 

    public StringgetCode() {

        returncode;

    }

 

    public voidsetCode(String code) {

        this.code =code;

    }

 

    publicList<DataBean> getData() {

        returndata;

    }

 

    public voidsetData(List<DataBean> data) {

        this.data =data;

    }

 

    public staticclass DataBean {

        /**

         * list :[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","num":3,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"}]

         * sellerName: 商家2

         * sellerid: 2

         */

        privateboolean checked = true;

        privateString sellerName;

        privateString sellerid;

        privateList<ListBean> list;

 

        publicboolean isChecked() {

            returnchecked;

        }

 

        public voidsetChecked(boolean checked) {

           this.checked = checked;

        }

 

        publicString getSellerName() {

            returnsellerName;

        }

 

        public voidsetSellerName(String sellerName) {

            this.sellerName = sellerName;

        }

 

        publicString getSellerid() {

            returnsellerid;

        }

 

        public voidsetSellerid(String sellerid) {

           this.sellerid = sellerid;

        }

 

        publicList<ListBean> getList() {

            returnlist;

        }

 

        public voidsetList(List<ListBean> list) {

           this.list = list;

        }

 

        publicstatic class ListBean {

            /**

             *bargainPrice : 11800

             *createtime : 2017-10-14T21:38:26

             *detailUrl :https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends

             *images : https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg

             * num: 3

             * pid: 58

             *price : 6399

             *pscid : 40

             *selected : 0

             *sellerid : 2

             *subhead : 升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!

             *title : 联想(Lenovo)拯救者R72015.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS黑)

             */

            privateboolean checked = true;

            private double bargainPrice;

            privateString createtime;

            privateString detailUrl;

            privateString images;

            privateint num;

            privateint pid;

            privatedouble price;

            privateint pscid;

            privateint selected;

            privateint sellerid;

            privateString subhead;

            privateString title;

 

            publicboolean isChecked() {

               return checked;

            }

 

            public voidsetChecked(boolean checked) {

               this.checked = checked;

            }

 

            publicdouble getBargainPrice() {

               return bargainPrice;

            }

 

            publicvoid setBargainPrice(double bargainPrice) {

               this.bargainPrice = bargainPrice;

            }

 

            publicString getCreatetime() {

               return createtime;

            }

 

            publicvoid setCreatetime(String createtime) {

               this.createtime = createtime;

            }

 

            publicString getDetailUrl() {

               return detailUrl;

            }

 

            publicvoid setDetailUrl(String detailUrl) {

               this.detailUrl = detailUrl;

            }

 

            publicString getImages() {

               return images;

            }

 

            publicvoid setImages(String images) {

               this.images = images;

            }

 

            publicint getNum() {

               return num;

            }

 

            publicvoid setNum(int num) {

               this.num = num;

            }

 

            publicint getPid() {

               return pid;

            }

 

            publicvoid setPid(int pid) {

               this.pid = pid;

            }

 

            publicdouble getPrice() {

               return price;

            }

 

            publicvoid setPrice(double price) {

               this.price = price;

            }

 

            publicint getPscid() {

               return pscid;

            }

 

            publicvoid setPscid(int pscid) {

               this.pscid = pscid;

            }

 

            publicint getSelected() {

               return selected;

            }

 

            publicvoid setSelected(int selected) {

               this.selected = selected;

            }

 

            publicint getSellerid() {

               return sellerid;

            }

 

            publicvoid setSellerid(int sellerid) {

               this.sellerid = sellerid;

            }

 

            publicString getSubhead() {

               return subhead;

            }

 

            publicvoid setSubhead(String subhead) {

               this.subhead = subhead;

            }

 

            public String getTitle() {

               return title;

            }

 

            publicvoid setTitle(String title) {

               this.title = title;

            }

        }

    }

}

 

```

 

> DingDBean

-----------

 

```

package com.bwie.moni_demo.bean;

 

import java.util.List;

 

/**

 * Created byliyongkai on 2018/3/5.

 */

 

public class DingDBean {

    /**

     * msg : 请求成功

     * code : 0

     * data :[{"createtime":"2017-11-09T09:17:20","orderid":1446,"price":99.99,"status":1,"title":"订单标题测试","uid":71},{"createtime":"2017-11-09T09:20:58","orderid":1448,"price":256.99,"status":1,"title":"订单标题测试","uid":71},{"createtime":"2017-11-09T09:22:41","orderid":1458,"price":999,"status":1,"title":"订单测试标题","uid":71},{"createtime":"2017-11-09T09:22:41","orderid":1464,"price":156,"status":1,"title":"订单测试标题","uid":71},{"createtime":"2017-12-18T14:55:20","orderid":3459,"price":99.99,"status":1,"title":"订单测试标题71","uid":71},{"createtime":"2017-12-19T20:13:37","orderid":3564,"price":99.99,"status":1,"title":"订单测试标题71","uid":71},{"createtime":"2017-12-20T11:01:10","orderid":3639,"price":1001,"status":1,"title":"订单测试标题71","uid":71},{"createtime":"2017-12-20T11:02:57","orderid":3640,"price":99.99,"status":1,"title":"订单测试标题71","uid":71},{"createtime":"2017-12-20T11:15:37","orderid":3645,"price":99.99,"status":1,"title":"订单测试标题71","uid":71},{"createtime":"2017-12-20T11:58:36","orderid":3723,"price":99.99,"status":1,"title":"订单测试标题71","uid":71}]

     * page : 1

     */

 

    private Stringmsg;

    private Stringcode;

    private Stringpage;

    privateList<DataBean> data;

 

    public StringgetMsg() {

        return msg;

    }

 

    public voidsetMsg(String msg) {

        this.msg =msg;

    }

 

    public StringgetCode() {

        return code;

    }

 

    public voidsetCode(String code) {

        this.code =code;

    }

 

    public StringgetPage() {

        returnpage;

    }

 

    public voidsetPage(String page) {

        this.page =page;

    }

 

    publicList<DataBean> getData() {

        returndata;

    }

 

    public voidsetData(List<DataBean> data) {

        this.data =data;

    }

 

    public staticclass DataBean {

        /**

         *createtime : 2017-11-09T09:17:20

         * orderid: 1446

         * price :99.99

         * status : 1

         * title : 订单标题测试

         * uid : 71

         */

 

        privateString createtime;

        private intorderid;

        privatedouble price;

        private intstatus;

        privateString title;

        private intuid;

 

        publicString getCreatetime() {

            returncreatetime;

        }

 

        public voidsetCreatetime(String createtime) {

           this.createtime = createtime;

        }

 

        public intgetOrderid() {

            returnorderid;

        }

 

        public voidsetOrderid(int orderid) {

           this.orderid = orderid;

        }

 

        publicdouble getPrice() {

            returnprice;

        }

 

        public voidsetPrice(double price) {

           this.price = price;

        }

 

        public intgetStatus() {

            returnstatus;

        }

 

        public voidsetStatus(int status) {

           this.status = status;

        }

 

        publicString getTitle() {

            returntitle;

        }

 

        public voidsetTitle(String title) {

           this.title = title;

        }

 

        public intgetUid() {

            returnuid;

        }

 

        public voidsetUid(int uid) {

           this.uid = uid;

        }

    }

}

 

```

 

> ProductDetailBean

-------------------

 

```

package com.bwie.moni_demo.bean;

 

/**

 * Created byliyongkai on 2018-03-05.

 */

 

public class ProductDetailBean {

 

    /**

     * msg :

     * seller :{"description":"我是商家14","icon":"http://120.27.23.105/images/icon.png","name":"商家14","productNums":999,"score":5,"sellerid":14}

     * code : 0

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

     */

 

    private Stringmsg;

    privateSellerBean seller;

    private Stringcode;

    privateDataBean data;

 

    public StringgetMsg() {

        return msg;

    }

 

    public voidsetMsg(String msg) {

        this.msg =msg;

    }

 

    publicSellerBean getSeller() {

        returnseller;

    }

 

    public voidsetSeller(SellerBean seller) {

        this.seller= seller;

    }

 

    public StringgetCode() {

        returncode;

    }

 

    public voidsetCode(String code) {

        this.code =code;

    }

 

    public DataBeangetData() {

        returndata;

    }

 

    public voidsetData(DataBean data) {

        this.data =data;

    }

 

    public staticclass SellerBean {

        /**

         *description : 我是商家14

         * icon :http://120.27.23.105/images/icon.png

         * name : 商家14

         *productNums : 999

         * score :5

         * sellerid: 14

         */

 

        privateString description;

        privateString icon;

        privateString name;

        private intproductNums;

        private intscore;

        private intsellerid;

 

        publicString getDescription() {

            returndescription;

        }

 

        public voidsetDescription(String description) {

           this.description = description;

        }

 

        publicString getIcon() {

            returnicon;

        }

 

        public voidsetIcon(String icon) {

           this.icon = icon;

        }

 

        publicString getName() {

            returnname;

        }

 

        public voidsetName(String name) {

           this.name = name;

        }

 

        public intgetProductNums() {

            returnproductNums;

        }

 

        public voidsetProductNums(int productNums) {

           this.productNums = productNums;

        }

 

        public intgetScore() {

            returnscore;

        }

 

        public voidsetScore(int score) {

           this.score = score;

        }

 

        public intgetSellerid() {

            returnsellerid;

        }

 

        public voidsetSellerid(int sellerid) {

           this.sellerid = sellerid;

        }

    }

 

    public staticclass DataBean {

        /**

         *bargainPrice : 11800

         *createtime : 2017-10-14T21:38:26

         *detailUrl :https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1

         * images :https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg

         * itemtype : 1

         * pid : 70

         * price :17999

         * pscid :40

         * salenum: 545

         * sellerid: 14

         * subhead: 购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)

         * title : 全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G

         */

 

        privatedouble bargainPrice;

        privateString createtime;

        privateString detailUrl;

        privateString images;

        private intitemtype;

        private intpid;

        privatedouble price;

        private intpscid;

        private intsalenum;

        private intsellerid;

        privateString subhead;

        privateString title;

 

        publicdouble getBargainPrice() {

            returnbargainPrice;

        }

 

        public voidsetBargainPrice(double bargainPrice) {

           this.bargainPrice = bargainPrice;

        }

 

        publicString getCreatetime() {

            returncreatetime;

        }

 

        public voidsetCreatetime(String createtime) {

           this.createtime = createtime;

        }

 

        publicString getDetailUrl() {

            returndetailUrl;

        }

 

        public voidsetDetailUrl(String detailUrl) {

           this.detailUrl = detailUrl;

        }

 

        publicString getImages() {

            returnimages;

        }

 

        public voidsetImages(String images) {

           this.images = images;

        }

 

        public intgetItemtype() {

            returnitemtype;

        }

 

        public voidsetItemtype(int itemtype) {

            this.itemtype = itemtype;

        }

 

        public intgetPid() {

            returnpid;

        }

 

        public voidsetPid(int pid) {

           this.pid = pid;

        }

 

        publicdouble getPrice() {

            returnprice;

        }

 

        public voidsetPrice(double price) {

           this.price = price;

        }

 

        public intgetPscid() {

            returnpscid;

        }

 

        public voidsetPscid(int pscid) {

           this.pscid = pscid;

        }

 

        public int getSalenum() {

            returnsalenum;

        }

 

        public voidsetSalenum(int salenum) {

           this.salenum = salenum;

        }

 

        public intgetSellerid() {

            returnsellerid;

        }

 

        public voidsetSellerid(int sellerid) {

           this.sellerid = sellerid;

        }

 

        publicString getSubhead() {

            returnsubhead;

        }

 

        public voidsetSubhead(String subhead) {

           this.subhead = subhead;

        }

 

        publicString getTitle() {

            returntitle;

        }

 

        public voidsetTitle(String title) {

           this.title = title;

        }

    }

}

 

```

 

布局

==

 

> activity_cart.xml

-------------------

 

```

<?xml version="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:app="http://schemas.android.com/apk/res-auto"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

    android:layout_height="match_parent"

   android:orientation="vertical"

   tools:context="com.bwie.moni_demo.CartActivity">

   <RelativeLayout

       android:layout_width="match_parent"

       android:layout_height="wrap_content">

 

       <TextView

           android:layout_width="30dp"

           android:layout_height="30dp"

           android:layout_centerVertical="true"

           android:background="@drawable/leftjiantou" />

 

       <TextView

           android:layout_width="match_parent"

           android:layout_height="40dp"

           android:gravity="center"

           android:text="购物车"

           android:textColor="#000"

           android:textSize="25sp" />

 

       <TextView

           android:layout_width="wrap_content"

            android:layout_height="wrap_content"

           android:layout_alignParentRight="true"

           android:layout_centerVertical="true"

           android:layout_marginRight="20dp"

           android:text="编辑"/>

   </RelativeLayout>

 

 

    <ExpandableListView

       android:id="@+id/elv"

       android:layout_width="match_parent"

       android:layout_height="match_parent"

       android:layout_weight="1" />

 

   <RelativeLayout

       android:layout_width="match_parent"

       android:layout_height="70dp"

       android:layout_alignParentBottom="true"

       android:background="@android:color/white"

       android:gravity="center_vertical">

 

       <CheckBox

           android:id="@+id/cb_All"

           android:layout_width="wrap_content"

           android:layout_height="wrap_content"

           android:layout_centerVertical="true"

           android:layout_marginLeft="10dp"

           android:checked="true"

           android:focusable="false" />

 

        <TextView

           android:id="@+id/tv_quxuan"

           android:layout_width="wrap_content"

           android:layout_height="50dp"

           android:layout_centerVertical="true"

           android:layout_marginLeft="10dp"

           android:layout_toRightOf="@+id/cb_All"

           android:gravity="center_vertical"

           android:text="全选"

           android:textSize="20sp" />

 

 

       <LinearLayout

           android:layout_width="wrap_content"

            android:layout_height="wrap_content"

           android:layout_toRightOf="@id/tv_quxuan"

           android:orientation="vertical">

 

           <TextView

               android:id="@+id/tv_price"

               android:layout_width="wrap_content"

                android:layout_height="wrap_content"

               android:layout_marginLeft="10dp"

               android:text="合计:¥550.90"

               android:textSize="25dp" />

 

           <TextView

               android:layout_width="wrap_content"

                android:layout_height="wrap_content"

               android:layout_marginLeft="100dp"

               android:text="不含运费"/>

 

       </LinearLayout>

 

       <TextView

           android:id="@+id/tv_num"

           android:layout_width="120dp"

           android:layout_height="match_parent"

           android:layout_alignParentRight="true"

           android:background="#FC7903"

           android:gravity="center"

           android:padding="10dp"

            android:text="去支付(0)"

           android:textColor="@android:color/white" />

   </RelativeLayout>

</LinearLayout>

 

```

 

> activity_ding_goods.xml

-------------------------

 

```

<?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.moni_demo.DingGoodsActivity">

   <!--<RelativeLayout-->

       <!--android:layout_width="match_parent"-->

       <!--android:layout_height="60dp"-->

       <!--&gt;-->

       <!--<TextView-->

           <!--android:layout_centerInParent="true"-->

           <!--android:layout_width="wrap_content"-->

           <!--android:layout_height="wrap_content"-->

           <!--android:textSize="20sp"-->

           <!--android:text="订单页面"-->

           <!--/>-->

       <!--<ImageView-->

           <!--android:src="@mipmap/ic_launcher"-->

           <!--android:layout_width="25dp"-->

           <!--android:layout_height="25dp"-->

           <!--android:id="@+id/imageView"-->

           <!--android:layout_alignParentRight="true"-->

            <!--android:layout_centerVertical="true"-->

           <!--/>-->

   <!--</RelativeLayout>-->

   <!--<TextView-->

       <!--android:layout_width="match_parent"-->

       <!--android:layout_height="1dp"-->

       <!--android:background="#000"-->

       <!--/>-->

   <!--<android.support.design.widget.TabLayout-->

       <!--android:id="@+id/tabLayout"-->

       <!--android:layout_width="match_parent"-->

       <!--android:layout_height="50dp"-->

        <!--&gt;-->

   <!--</android.support.design.widget.TabLayout>-->

 

   <!--<android.support.v4.view.ViewPager-->

       <!--android:id="@+id/viewPager"-->

       <!--android:layout_width="match_parent"-->

       <!--android:layout_height="match_parent"-->

       <!--&gt;-->

   <!--</android.support.v4.view.ViewPager>-->

</RelativeLayout>

 

```

 

> activity_main.xml

-------------------

 

```

<?xml version="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:app="http://schemas.android.com/apk/res-auto"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   android:orientation="vertical"

   tools:context="com.bwie.moni_demo.MainActivity">

 

   <LinearLayout

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:orientation="horizontal">

 

 

        <Button

           android:id="@+id/bt_xiazai"

           android:layout_width="wrap_content"

           android:layout_height="wrap_content"

           android:text="下载"/>

 

        <Button

           android:id="@+id/bt_zanting"

           android:layout_width="wrap_content"

           android:layout_height="wrap_content"

           android:text="暂停"/>

 

        <Button

           android:id="@+id/bt_jixu"

           android:layout_width="wrap_content"

           android:layout_height="wrap_content"

           android:text="继续"/>

   </LinearLayout>

 

    <ProgressBar

       android:id="@+id/pro"

       style="?android:attr/progressBarStyleHorizontal"

       android:layout_width="match_parent"

       android:layout_height="20dp" />

 

    <TextView

       android:id="@+id/tv_progress"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:layout_gravity="center"

       android:text="下载:0%"/>

 

    <Button

       android:id="@+id/bt_xiangqing"

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:layout_marginTop="50dp"

       android:layout_marginLeft="50dp"

       android:layout_marginRight="50dp"

       android:text="进入详情"/>

 

</LinearLayout>

 

```

 

> activity_product_detail.xml

-----------------------------

 

```

<?xml version="1.0"encoding="utf-8"?>

<RelativeLayoutxmlns: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.moni_demo.ProductDetailActivity">

 

   <LinearLayout

       android:id="@+id/lin_top"

       android:layout_width="match_parent"

       android:layout_height="wrap_content">

 

        <include

           layout="@layout/simple_player_view_player"

           android:layout_width="match_parent"

           android:layout_height="250dp" />

   </LinearLayout>

 

 

   <android.support.v7.widget.RecyclerView

       android:id="@+id/xq_rlv"

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:layout_below="@id/lin_top" />

 

   <LinearLayout

       android:layout_width="match_parent"

        android:layout_height="80dp"

       android:layout_alignParentBottom="true"

       android:orientation="horizontal">

 

       <ImageView

           android:layout_width="65dp"

           android:layout_height="match_parent"

           android:background="@drawable/kefu" />

 

       <ImageView

           android:layout_width="65dp"

           android:layout_height="match_parent"

           android:background="@drawable/dianjia" />

 

       <ImageView

           android:id="@+id/iv_getcart"

           android:layout_width="65dp"

           android:layout_height="match_parent"

           android:background="@drawable/shoucnag" />

 

        <Button

           android:id="@+id/bt_addcart"

           android:layout_width="150dp"

           android:layout_height="match_parent"

           android:background="#FDC302"

           android:text="添加到购物车"

           android:textColor="#fff"

           android:textSize="16sp" />

 

        <Button

           android:id="@+id/bt_tocart"

           android:layout_width="120dp"

           android:layout_height="match_parent"

           android:background="#FF6A04"

           android:text="立即购买"

           android:textColor="#fff"

           android:textSize="16sp" />

   </LinearLayout>

</RelativeLayout>

 

```

 

>adddelete.xml

--------------

 

```

<?xml version="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   android:layout_width="match_parent"

   android:layout_height="match_parent">

 

    <TextView

       android:id="@+id/tv_delete"

       android:layout_width="31dp"

       android:layout_height="31dp"

       android:background="#999999"

       android:gravity="center"

       android:text="-"

       android:textSize="20sp" />

 

    <EditText

       android:id="@+id/ed_num"

       android:layout_width="30dp"

       android:layout_height="30dp"

       android:background="@null"

       android:gravity="center" />

 

    <TextView

        android:id="@+id/tv_add"

       android:layout_width="31dp"

       android:layout_height="31dp"

       android:background="#999999"

       android:gravity="center"

       android:text="+"

       android:textSize="20sp" />

</LinearLayout>

```

 

> cart_child_item.xml

---------------------

 

```

<?xml version="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:app="http://schemas.android.com/apk/res-auto"

   android:id="@+id/del"

   android:layout_width="match_parent"

   android:layout_height="120dp"

   android:orientation="horizontal">

 

    <CheckBox

       android:id="@+id/cb_child"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

        android:layout_marginBottom="30dp"

       android:layout_marginLeft="20dp"

       android:layout_marginTop="45dp"

       android:focusable="false" />

 

 

   <com.facebook.drawee.view.SimpleDraweeView

       android:id="@+id/child_sdv"

        android:layout_width="100dp"

       android:layout_height="match_parent"

       android:layout_margin="8dp"

       app:placeholderImage="@mipmap/ic_launcher_round" />

 

   <LinearLayout

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:layout_marginLeft="20dp"

       android:orientation="vertical"

       android:padding="10dp">

 

       <TextView

           android:id="@+id/child_tit"

           android:layout_width="match_parent"

           android:layout_height="wrap_content"

           android:text="123"

           android:textStyle="bold" />

 

       <TextView

           android:id="@+id/child_info"

           android:layout_width="match_parent"

           android:layout_height="wrap_content"

           android:layout_marginTop="8dp"

           android:text="颜色:黑;尺寸:23L" />

 

       <RelativeLayout

           android:layout_width="match_parent"

           android:layout_height="wrap_content"

           android:layout_marginTop="30dp"

           android:orientation="horizontal">

 

           <TextView

               android:id="@+id/child_price"

               android:layout_width="wrap_content"

               android:layout_height="wrap_content"

               android:textSize="20sp"

               android:text="¥"

               android:textColor="#E17E52" />

 

           <com.bwie.moni_demo.view.AddDeleteView

               android:id="@+id/adv_main"

               android:layout_width="wrap_content"

               android:layout_height="wrap_content"

               android:layout_alignParentRight="true"

               android:layout_weight="1"

               app:left_text="-"

               app:middle_text="1"

                app:right_text="+"/>

       </RelativeLayout>

 

   </LinearLayout>

</LinearLayout>

```

 

> cart_group_item.xml

---------------------

 

```

<?xml version="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   android:layout_width="match_parent"

   android:layout_height="100dp"

   android:orientation="horizontal">

 

    <CheckBox

       android:id="@+id/cb_group"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

        android:layout_marginBottom="30dp"

       android:layout_marginLeft="10dp"

       android:layout_marginTop="30dp"

       android:focusable="false" />

 

    <ImageView

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:layout_marginLeft="10dp"

       android:layout_marginTop="30dp"

       android:background="@drawable/title" />

 

    <TextView

       android:id="@+id/gou_dian"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:layout_marginLeft="20dp"

       android:layout_marginTop="30dp"

       android:text="商家11>"

       android:textSize="20sp" />

</LinearLayout>

```

 

> detail_rlv_adapter_item.xml

-----------------------------

 

```

<?xml version="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:app="http://schemas.android.com/apk/res-auto"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   android:orientation="vertical">

 

   <com.facebook.drawee.view.SimpleDraweeView

       android:id="@+id/detail_adapter_sdv"

       android:layout_width="match_parent"

       android:layout_height="300dp"

       app:placeholderImage="@mipmap/ic_launcher" />

 

   <RelativeLayout

       android:layout_width="match_parent"

       android:layout_height="wrap_content">

 

       <LinearLayout

           android:layout_width="wrap_content"

           android:layout_height="wrap_content"

           android:orientation="vertical">

 

           <TextView

               android:id="@+id/tv_detail_title"

               android:layout_width="match_parent"

               android:layout_height="wrap_content"

                android:layout_margin="5dp"

               android:text="费卡机发电电费卡机发电电费卡机发电" />

 

           <TextView

               android:id="@+id/tv_detail_price"

               android:layout_width="match_parent"

               android:layout_height="wrap_content"

               android:layout_margin="5dp"

               android:text="¥1321.0"

               android:textColor="#E2791E" />

 

           <TextView

               android:id="@+id/tv_detail_sj"

               android:layout_width="match_parent"

               android:layout_height="wrap_content"

               android:layout_margin="5dp"

               android:text="我是商家11"/>

       </LinearLayout>

 

       <ImageView

           android:layout_width="wrap_content"

           android:layout_height="70dp"

           android:layout_alignParentRight="true"

           android:src="@drawable/fenxiang" />

   </RelativeLayout>

 

</LinearLayout>

```

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值