MVP-详情-自定义view-购物车
依赖:
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'//Retrofit2所需要的包 compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'//ConverterFactory的Gson依赖包 compile 'com.squareup.retrofit2:converter-scalars:2.0.0-beta4'//ConverterFactory的String依赖包 compile 'io.reactivex.rxjava2:rxjava:2.1.3' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' compile 'de.greenrobot:eventbus:3.0.0-beta1' compile 'com.facebook.fresco:fresco:0.11.0' //拦截器的依赖 compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
工具类:net public interface OnNetListener<T> { public void onSuccess(T t); public void onFailure(Exception e); } RetrofitHelper :::::: public class RetrofitHelper { private static Retrofit retrofit; private static ServiceApi serviceApi; /** * 初始化Retrofit 单例模式 */ private static Retrofit getRetrofit() { //线程安全 if (retrofit == null) { synchronized (RetrofitHelper.class) { if (retrofit == null) { //设置拦截器 HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(new MyInterceptor()) .connectTimeout(5, TimeUnit.SECONDS)//设置连接超时 .addInterceptor(logging)//添加拦截器 //.addNetworkInterceptor() //网路拦截器 .build(); retrofit = new Retrofit.Builder() .baseUrl(Urls.BASE_URL) .client(client) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .build(); } } } return retrofit; } public static ServiceApi getAPI() { if (serviceApi == null) { synchronized (RetrofitHelper.class) { if (serviceApi == null) { serviceApi = getRetrofit().create(ServiceApi.class); } } } return serviceApi; } /** * 添加公共参数拦截器 */ static class MyInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); HttpUrl httpUrl = request .url() .newBuilder() .addQueryParameter("source", "android") .build(); Request requestNew = request .newBuilder() .url(httpUrl) .build(); return chain.proceed(requestNew); } } } ServiceApi : public interface ServiceApi { //商品列表 @GET(Urls.PRODUCTDETAIL) Observable<ProductDetailBean> getProductDetail(@Query("pid") String pid); //添加购物车 @GET(Urls.ADDCART) Observable<AddCartBean> getAddCart(@Query("uid") String uid, @Query("pid") String pid); //查询购物车 @GET(Urls.GETCARTS) Observable<CartBean> getCarts(@Query("uid") String uid); } Urls :--- public class Urls { public static final String BASE_URL = "https://www.zhaoapi.cn/"; //商品详情 public static final String PRODUCTDETAIL = "product/getProductDetail"; //添加购物车 public static final String ADDCART = "product/addCart"; //查询购物车 public static final String GETCARTS = "product/getCarts"; }
M层 IProductDetaiModell添加和详情接口 public interface IProductDetaiModell { public void getDetail(String pid, OnNetListener<ProductDetailBean> onNetListener); public void addCart(String uid, String pid, OnNetListener<AddCartBean> onNetListener); } ProductDetailModel M方法 public class ProductDetailModel implements IProductDetaiModell { @Override public void getDetail(String pid, final OnNetListener<ProductDetailBean> onNetListener) { ServiceApi serviceApi = RetrofitHelper.getAPI(); serviceApi.getProductDetail(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((Exception) throwable); } }); } @Override public void addCart(String uid, String pid, final OnNetListener<AddCartBean> onNetListener) { ServiceApi serviceApi = RetrofitHelper.getAPI(); serviceApi.getAddCart(uid, pid) .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((Exception) throwable); } }); } } 购物车M层接口和方法 public interface ICartModel { public void getCart(String uid, OnNetListener<CartBean> onNetListener); } public class CartModel implements ICartModel { @Override public void getCart(String uid, final OnNetListener<CartBean> onNetListener) { ServiceApi serviceApi = RetrofitHelper.getAPI(); 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((Exception) throwable); } }); } }
P层 处理逻辑 //可写可不写 public interface BasePresenter { /** * 当页面销毁的时候,需要把View=null, * 然后调用 System.gc();//尽管不会马上回收,只是通知jvm可以回收了,等jvm高兴就会回收 */ void detachView(); } public class ProductDetailPresenter implements BasePresenter { private final IProductDetaiModell iProductDetaiModell; private IDetailView iDetailView; public ProductDetailPresenter(IDetailView iDetailView) { this.iDetailView = iDetailView; iProductDetaiModell = new ProductDetailModel(); } public void getDetail() { iProductDetaiModell.getDetail("100", new OnNetListener<ProductDetailBean>() { @Override public void onSuccess(ProductDetailBean productDetailBean) { iDetailView.showDetail(productDetailBean); } @Override public void onFailure(Exception e) { } }); } public void addCart() { iProductDetaiModell.addCart("71", "100", new OnNetListener<AddCartBean>() { @Override public void onSuccess(AddCartBean addCartBean) { iDetailView.addCart(addCartBean); } @Override public void onFailure(Exception e) { } }); } /** * 当页面销毁的时候,需要把View=null, * 然后调用 System.gc();//尽管不会马上回收,只是通知jvm可以回收了,等jvm高兴就会回收 */ @Override public void detachView() { //防止内存泄露 if (iDetailView != null) { iDetailView = null; System.gc(); } } } //购物车p层 public class CartPresenter implements BasePresenter { private final ICartModel iCartModel; private ICartView iCartView; public CartPresenter(ICartView iCartView) { this.iCartView = iCartView; iCartModel = new CartModel(); } public void getCarts() { iCartModel.getCart("71", new OnNetListener<CartBean>() { @Override public void onSuccess(CartBean cartBean) { iCartView.getCarts(cartBean); } @Override public void onFailure(Exception e) { } }); } @Override public void detachView() { //防止内存泄露 if (iCartView != null) { iCartView = null; System.gc(); } } }
V层 接口 详情 添加购物车 public interface IDetailView { public void showDetail(ProductDetailBean productDetailBean); public void addCart(AddCartBean addCartBean); } 查询购物车 public interface ICartView { public void getCarts(CartBean cartBean); } 可写可不写的一个类===== public abstract class BaseMvpActivity extends AppCompatActivity{ private BasePresenter presenter = null; /** * 绑定presenter,主要用于销毁工作 * * @return */ protected abstract BasePresenter bindPresenter(); /** * 如果重写了此方法,一定要调用super.onDestroy(); */ @Override public void onDestroy() { super.onDestroy(); if (presenter != null) { presenter.detachView(); presenter = null; } } }
详情和添加购物车的主类 public class MainActivity extends AppCompatActivity implements View.OnClickListener, IDetailView { private SimpleDraweeView mSdv; /** * ¥19.90 */ private TextView mTvDetailPrice; /** * ¥10000.0 */ private TextView mTvDetailYuPrice; /** * 全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G */ private TextView mTvDetailTitle; /** * 购买电脑办公部分商品满1元返火车票5元优惠券(返完即止) */ private TextView mTvDetailSubhead; private TextView mTvCarts; /** * 加入购物车 */ private Button mBtAddcart; private ProductDetailPresenter productDetailPresenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); productDetailPresenter = new ProductDetailPresenter(this); productDetailPresenter.getDetail(); } private void initView() { mSdv = (SimpleDraweeView) findViewById(R.id.sdv); mTvDetailPrice = (TextView) findViewById(R.id.tv_detail_price); mTvDetailYuPrice = (TextView) findViewById(R.id.tv_detail_yu_price); mTvDetailTitle = (TextView) findViewById(R.id.tv_detail_title); mTvDetailSubhead = (TextView) findViewById(R.id.tv_detail_subhead); mTvCarts = (TextView) findViewById(R.id.tv_carts); mBtAddcart = (Button) findViewById(R.id.bt_addcart); mBtAddcart.setOnClickListener(this); mSdv.setOnClickListener(this); mTvDetailPrice.setOnClickListener(this); mTvDetailYuPrice.setOnClickListener(this); mTvDetailTitle.setOnClickListener(this); mTvDetailSubhead.setOnClickListener(this); mTvCarts.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()) { default: break; case R.id.bt_addcart: //添加购物车 productDetailPresenter.addCart(); break; case R.id.sdv: break; case R.id.tv_detail_price: break; case R.id.tv_detail_yu_price: break; case R.id.tv_detail_title: break; case R.id.tv_detail_subhead: break; case R.id.tv_carts: //跳转到购物车 Intent intent = new Intent(MainActivity.this, CartActivity.class); startActivity(intent); break; } } @Override public void showDetail(ProductDetailBean productDetailBean) { String images = productDetailBean.getData().getImages(); String[] strings = images.split("\\|"); mSdv.setImageURI(strings[0]); mTvDetailPrice.setText("¥" + productDetailBean.getData().getBargainPrice()); mTvDetailYuPrice.setText("¥" + productDetailBean.getData().getPrice()); //添加删除线 mTvDetailYuPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); mTvDetailTitle.setText(productDetailBean.getData().getTitle()); mTvDetailSubhead.setText(productDetailBean.getData().getSubhead()); } @Override public void addCart(AddCartBean addCartBean) { if ("0".equals(addCartBean.getCode())) { Toast.makeText(getApplicationContext(), addCartBean.getMsg(), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), addCartBean.getMsg(), Toast.LENGTH_SHORT).show(); } } } //查询购物车的主类 public class CartActivity extends AppCompatActivity implements ICartView { private ExpandableListView mElv; private CheckBox mCbAll; /** * 全选 */ private TextView mTvQuxuan; /** * 合计 :¥550.90 */ private TextView mTvPrice; /** * 总额:582.70 立减:¥31.80 */ private TextView mTvCartsPrice; /** * 去结算(0) */ private TextView mTvNum; private List<List<CartBean.DataBean.ListBean>> lists; private MyElvAdapter myElvAdapter; private CartPresenter cartPresenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cart); initView(); EventBus.getDefault().register(this); cartPresenter = new CartPresenter(this); cartPresenter.getCarts(); } @Override public void onDestroy() { super.onDestroy(); EventBus.getDefault().unregister(this); } @Override public void getCarts(CartBean cartBean) { List<CartBean.DataBean> dataBeans = cartBean.getData(); lists = new ArrayList<>(); 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); } private void initView() { 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); mTvCartsPrice = (TextView) findViewById(R.id.tv_carts_price); mTvNum = (TextView) findViewById(R.id.tv_num); //全选 mCbAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myElvAdapter.changeAllListCbState(mCbAll.isChecked()); } }); } @Subscribe public void onMessageEvent(MessageEvent event) { mCbAll.setChecked(event.isChecked()); } @Subscribe public void onMessageEvent(PriceAndCountEvent event) { mTvPrice.setText("合计:¥" + event.getPrice() * event.getCount()); mTvCartsPrice.setText("总额:¥" + event.getPrice() * event.getCount()); mTvNum.setText("去结算(" + event.getCount() + ")"); } } 自定义view public class AddDeleteView extends LinearLayout { private OnAddDelClickListener listener; private EditText etNumber; //对外提供一个点击的回调接口 public interface OnAddDelClickListener { void onAddClick(View v); void onDelClick(View v); } public void setOnAddDelClickListener(OnAddDelClickListener listener) { if (listener != null) { this.listener = listener; } } public AddDeleteView(Context context) { this(context, null); } public AddDeleteView(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public AddDeleteView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initView(context, attrs, defStyleAttr); } private void initView(Context context, AttributeSet attrs, int defStyleAttr) { View.inflate(context, R.layout.adddelete, this); TextView txtDelete = (TextView) findViewById(R.id.tv_delete); TextView txtAdd = (TextView) findViewById(R.id.tv_add); etNumber = (EditText) findViewById(R.id.ed_num); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AddDeleteViewStyle); String leftText = typedArray.getString(R.styleable.AddDeleteViewStyle_left_text); String rightText = typedArray.getString(R.styleable.AddDeleteViewStyle_right_text); String middleText = typedArray.getString(R.styleable.AddDeleteViewStyle_middle_text); txtDelete.setText(leftText); txtAdd.setText(rightText); etNumber.setText(middleText); //回收 typedArray.recycle(); txtDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { listener.onDelClick(view); } }); txtAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { listener.onAddClick(view); } }); } //对外提供一个修改数字的方法 public void setNumber(int number) { if (number > 0) { etNumber.setText(number + ""); } } //对外提供一个获取当前数字的方法 public int getNumber() { String string = etNumber.getText().toString(); int i = Integer.parseInt(string); return i; } }
购物车适配器 public class MyElvAdapter extends BaseExpandableListAdapter { private Context context; private List<CartBean.DataBean> groupList; private List<List<CartBean.DataBean.ListBean>> childList; private LayoutInflater inflater; public MyElvAdapter(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 int getGroupCount() { return groupList.size(); } @Override public int getChildrenCount(int groupPosition) { return childList.get(groupPosition).size(); } @Override public Object getGroup(int groupPosition) { return groupList.get(groupPosition); } @Override public Object getChild(int groupPosition, int childPosition) { return childList.get(groupPosition).get(childPosition); } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public boolean hasStableIds() { return false; } @Override public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View view; final GroupViewHolder holder; if (convertView == null) { holder = new GroupViewHolder(); view = 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(); } final CartBean.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(); } }); return view; } @Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View view; final ChildViewHolder holder; if (convertView == null) { holder = new ChildViewHolder(); view = 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(); } final CartBean.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.getTitle()); 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(new AddDeleteView.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; } }); return view; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } class GroupViewHolder { 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状态 * * @param flag */ private void changeAllCbState(boolean flag) { MessageEvent messageEvent = new MessageEvent(); messageEvent.setChecked(flag); EventBus.getDefault().post(messageEvent); } /** * 改变二级列表CheckBox状态 * * @param groupPosition * @param flag */ private void 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状态 * * @param groupPosition * @param flag */ private void changeGroupCbState(int groupPosition, boolean flag) { CartBean.DataBean dataBean = groupList.get(groupPosition); dataBean.setChecked(flag); } /** * 判断一级列表是否全部选中 * * @return */ public boolean isAllGroupCbSelected() { for (int i = 0; i < groupList.size(); i++) { CartBean.DataBean dataBean = groupList.get(i); if (!dataBean.isChecked()) { return false; } } return true; } /** * 判断二级列表是否全部选中 * * @param groupPosition * @return */ public boolean 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; } } return true; } /** * 设置全选、反选 * * @param flag */ public void changeAllListCbState(boolean flag) { for (int i = 0; i < groupList.size(); i++) { //改变一级列表CheckBox状态 changeGroupCbState(i, flag); //改变二级列表CheckBox状态 changeChildCbState(i, flag); } //将数量和价格传值 EventBus.getDefault().post(computer()); //刷新列表 notifyDataSetChanged(); } /** * 计算列表中选中的钱和数量 * * @return */ private PriceAndCountEvent computer() { int count = 0; int price = 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); return priceAndCountEvent; } } Myapp里的图片加载及磁盘缓存 public class Myapp extends Application { @Override public void onCreate() { super.onCreate(); Fresco.initialize(this); //配置磁盘缓存 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(); } }
布局: values下的attrs.xml <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="AddDeleteViewStyle"> <attr name="left_text" format="string" /> <attr name="right_text" format="string" /> <attr name="middle_text" format="string" /> </declare-styleable> </resources> 自定义加减:adddelete <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <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> 详情main <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:fresco="http://schemas.android.com/apk/res-auto" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="30dp" android:layout_height="30dp" android:layout_centerVertical="true" android:background="@drawable/leftjiantou" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="商品详情" android:textSize="25sp" /> <TextView android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:background="@drawable/sandian" /> </RelativeLayout> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/sdv" android:layout_width="match_parent" android:layout_height="400dp" fresco:failureImage="@mipmap/ic_launcher" fresco:placeholderImage="@mipmap/ic_launcher" fresco:progressBarImage="@mipmap/ic_launcher" /> <TextView android:id="@+id/tv_detail_price" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:text="¥19.90" android:textSize="25sp" /> <TextView android:id="@+id/tv_detail_yu_price" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="¥10000.0" /> <TextView android:id="@+id/tv_detail_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:text="全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G" /> <TextView android:id="@+id/tv_detail_subhead" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:text="购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)" android:textColor="#ff00" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:text="白条 【白条支付】首单立减5元" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="70dp" android:layout_alignParentBottom="true"> <TextView android:layout_width="70dp" android:layout_height="match_parent" android:background="@drawable/dsa01" /> <TextView android:layout_width="70dp" android:layout_height="match_parent" android:background="@drawable/dsa02" /> <TextView android:id="@+id/tv_carts" android:layout_width="70dp" android:layout_height="match_parent" android:background="@drawable/dsa03" /> <Button android:id="@+id/bt_addcart" android:layout_width="150dp" android:layout_height="match_parent" android:background="#FEBF14" android:text="加入购物车" android:textColor="#fff" android:textSize="20sp" /> <Button android:layout_width="120dp" android:layout_height="match_parent" android:background="#F23030" android:text="立即购买" android:textColor="#fff" android:textSize="20sp" /> </LinearLayout> </RelativeLayout> //购物车cart <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <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: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:id="@+id/tv_carts_price" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="总额:582.70 立减:¥31.80" /> </LinearLayout> <TextView android:id="@+id/tv_num" android:layout_width="120dp" android:layout_height="match_parent" android:layout_alignParentRight="true" android:background="@android:color/holo_red_dark" android:gravity="center" android:padding="10dp" android:text="去结算(0)" android:textColor="@android:color/white" /> </RelativeLayout> </LinearLayout> 二级列表的布局 child: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" 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:text="¥" android:textColor="@color/colorAccent" /> <com.bwei.wsq.gouwu11.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> group: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="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" /> <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="标记" /> </LinearLayout>
bean ProductDetailBean : public class ProductDetailBean { /** * msg : * seller : {"description":"我是商家11","icon":"http://120.27.23.105/images/icon.png","name":"商家11","productNums":999,"score":5,"sellerid":11} * code : 0 * data : {"bargainPrice":159,"createtime":"2017-10-14T21:49:15","detailUrl":"https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8716/197/1271594444/173291/2f40bb4f/59b743bcN8509428e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8347/264/1286771527/92188/5cf5ec04/59b7420fN65378e9e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7363/165/3000956253/190883/179a372/59b743bfNd0c79d93.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7399/112/2935531768/183594/b77c7d4a/59b7441aNc3d40133.jpg!q70.jpg","itemtype":0,"pid":100,"price":2200,"pscid":112,"salenum":456,"sellerid":11,"subhead":"针织针织闪闪闪亮你的眼","title":"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL"} */ 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 : 我是商家11 * icon : http://120.27.23.105/images/icon.png * name : 商家11 * productNums : 999 * score : 5 * sellerid : 11 */ private String description; private String icon; private String name; private int productNums; private int score; private int sellerid; public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getProductNums() { return productNums; } public void setProductNums(int productNums) { this.productNums = productNums; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getSellerid() { return sellerid; } public void setSellerid(int sellerid) { this.sellerid = sellerid; } } public static class DataBean { /** * bargainPrice : 159 * createtime : 2017-10-14T21:49:15 * detailUrl : https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends * images : https://m.360buyimg.com/n0/jfs/t8716/197/1271594444/173291/2f40bb4f/59b743bcN8509428e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8347/264/1286771527/92188/5cf5ec04/59b7420fN65378e9e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7363/165/3000956253/190883/179a372/59b743bfNd0c79d93.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7399/112/2935531768/183594/b77c7d4a/59b7441aNc3d40133.jpg!q70.jpg * itemtype : 0 * pid : 100 * price : 2200 * pscid : 112 * salenum : 456 * sellerid : 11 * subhead : 针织针织闪闪闪亮你的眼 * title : 维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL */ private int bargainPrice; private String createtime; private String detailUrl; private String images; private int itemtype; private int pid; private int price; private int pscid; private int salenum; private int sellerid; private String subhead; private String title; public int getBargainPrice() { return bargainPrice; } public void setBargainPrice(int bargainPrice) { this.bargainPrice = bargainPrice; } public String getCreatetime() { return createtime; } public void setCreatetime(String createtime) { this.createtime = createtime; } public String getDetailUrl() { return detailUrl; } public void setDetailUrl(String detailUrl) { this.detailUrl = detailUrl; } public String getImages() { return images; } public void setImages(String images) { this.images = images; } public int getItemtype() { return itemtype; } public void setItemtype(int itemtype) { this.itemtype = itemtype; } public int getPid() { return pid; } public void setPid(int pid) { this.pid = pid; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } public int getPscid() { return pscid; } public void setPscid(int pscid) { this.pscid = pscid; } public int getSalenum() { return salenum; } public void setSalenum(int salenum) { this.salenum = salenum; } public int getSellerid() { return sellerid; } public void setSellerid(int sellerid) { this.sellerid = sellerid; } public String getSubhead() { return subhead; } public void setSubhead(String subhead) { this.subhead = subhead; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } } } AddCartBean : public class AddCartBean { /** * msg : 加购成功 * code : 0 */ private String msg; private String code; public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } } CartBean ====== public class CartBean { /** * msg : 请求成功 * code : 0 * data : [{"list":[{"bargainPrice":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg","num":9,"pid":57,"price":5199,"pscid":40,"selected":0,"sellerid":1,"subhead":"【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统","title":"小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银 "}],"sellerName":"商家1","sellerid":"1"},{"list":[{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":1,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"},{"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":9,"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":1599,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/1993026402.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5863/302/8961270302/97126/41feade1/5981c81cNc1b1fbef.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7003/250/1488538438/195825/53bf31ba/5981c57eN51e95176.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5665/100/8954482513/43454/418611a9/5981c57eNd5fc97ba.jpg!q70.jpg","num":2,"pid":47,"price":111,"pscid":39,"selected":0,"sellerid":3,"subhead":"碳黑色 32GB 全网通 官方标配 1件","title":"锤子 坚果Pro 特别版 巧克力色 酒红色 全网通 移动联通电信4G手机 双卡双待 碳黑色 32GB 全网通"},{"bargainPrice":5599,"createtime":"2017-10-10T17:30:32","detailUrl":"https://item.m.jd.com/product/4824715.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n12/jfs/t7768/184/1153704394/148460/f42e1432/599a930fN8a85626b.jpg!q70.jpg","num":5,"pid":59,"price":5599,"pscid":40,"selected":0,"sellerid":3,"subhead":"游戏本选择4G独显,拒绝掉帧】升级版IPS全高清防眩光显示屏,WASD方向键颜色加持,三大出风口立体散热!","title":"戴尔DELL灵越游匣15PR-6648B GTX1050 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 128GSSD+1T 4G独显 IPS)黑"}],"sellerName":"商家3","sellerid":"3"},{"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":2,"pid":60,"price":13888,"pscid":40,"selected":0,"sellerid":4,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":2999,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2385655.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t2068/298/2448145915/157953/7be197df/56d51a42Nd86f1c8e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2437/128/1687178395/117431/bcc190c1/56d3fcbaNb2963d21.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2467/222/2263160610/95597/927b8a2f/56d3eafeNdecebeb6.jpg!q70.jpg","num":1,"pid":53,"price":777,"pscid":39,"selected":0,"sellerid":9,"subhead":"Super AMOLED三星双曲面2K 屏,支持无线充电!","title":"三星 Galaxy S7 edge(G9350)4GB+32GB 铂光金 移动联通电信4G手机 双卡双待"}],"sellerName":"商家9","sellerid":"9"},{"list":[{"bargainPrice":159,"createtime":"2017-10-14T21:49:15","detailUrl":"https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8716/197/1271594444/173291/2f40bb4f/59b743bcN8509428e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8347/264/1286771527/92188/5cf5ec04/59b7420fN65378e9e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7363/165/3000956253/190883/179a372/59b743bfNd0c79d93.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7399/112/2935531768/183594/b77c7d4a/59b7441aNc3d40133.jpg!q70.jpg","num":1,"pid":100,"price":2200,"pscid":112,"selected":0,"sellerid":11,"subhead":"针织针织闪闪闪亮你的眼","title":"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL"}],"sellerName":"商家11","sellerid":"11"},{"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":1,"pid":71,"price":32999,"pscid":40,"selected":0,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家15","sellerid":"15"}] */ 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":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg","num":9,"pid":57,"price":5199,"pscid":40,"selected":0,"sellerid":1,"subhead":"【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统","title":"小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银 "}] * sellerName : 商家1 * sellerid : 1 */ private boolean checked; private String sellerName; private String sellerid; private List<ListBean> list; public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } 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 : 11800 * createtime : 2017-10-10T17:33:37 * detailUrl : https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends * images : https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg * num : 9 * pid : 57 * price : 5199 * pscid : 40 * selected : 0 * sellerid : 1 * subhead : 【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统 * title : 小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银 */ private boolean checked; private double bargainPrice; private String createtime; private String detailUrl; private String images; private int num; private int pid; private double price; private int pscid; private int selected; private int sellerid; private String subhead; private String title; public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public double getBargainPrice() { return bargainPrice; } public void setBargainPrice(double bargainPrice) { this.bargainPrice = bargainPrice; } public String getCreatetime() { return createtime; } public void setCreatetime(String createtime) { this.createtime = createtime; } public String getDetailUrl() { return detailUrl; } public void setDetailUrl(String detailUrl) { this.detailUrl = detailUrl; } public String getImages() { return images; } public void setImages(String images) { this.images = images; } public int getNum() { return num; } public void setNum(int num) { this.num = num; } public int getPid() { return pid; } public void setPid(int pid) { this.pid = pid; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public int getPscid() { return pscid; } public void setPscid(int pscid) { this.pscid = pscid; } public int getSelected() { return selected; } public void setSelected(int selected) { this.selected = selected; } public int getSellerid() { return sellerid; } public void setSellerid(int sellerid) { this.sellerid = sellerid; } public String getSubhead() { return subhead; } public void setSubhead(String subhead) { this.subhead = subhead; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } } } }