仿京東首頁+商品詳情頁+購物車
阿新 • • 發佈:2019-01-05
IHomeApi:
package com.example.yuekaomoni.mvp.view.iview; import com.example.yuekaomoni.mvp.model.bean.Home; import io.reactivex.Observable; import retrofit2.http.GET; import retrofit2.http.Url; /** * Created by DELL on 2018/7/26. */ public interface IHomeApi { @GET() Observable<Home> home(@Url String url); }
首頁的Model —— HomeModel:
package com.example.yuekaomoni.mvp.model; import com.example.yuekaomoni.mvp.model.bean.Home; import com.example.yuekaomoni.mvp.view.iview.IHomeApi; import com.example.yuekaomoni.utils.RetrofitManager; import io.reactivex.Observable; /** * Created by DELL on 2018/7/26. */ public class HomeModel { public Observable<Home> home(String url) { return RetrofitManager.getDefault().create(IHomeApi.class).home("https://www.zhaoapi.cn/home/getHome"); } }
首頁的Presenter —— HomePresenter:
package com.example.yuekaomoni.mvp.presenter; import com.example.yuekaomoni.mvp.model.HomeModel; import com.example.yuekaomoni.mvp.model.bean.Home; import com.example.yuekaomoni.mvp.view.iview.IHomeView; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; /** * Created by DELL on 2018/7/26. */ public class HomePresenter { private HomeModel homeModel; IHomeView mIHomeView; public HomePresenter(IHomeView iHomeView){ mIHomeView = iHomeView; homeModel = new HomeModel(); } public void home(){ homeModel.home("https://www.zhaoapi.cn/home/getHome") .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<Home>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(Home home) { if(mIHomeView != null){ mIHomeView.onResponse(home); } } @Override public void onError(Throwable e) { if(mIHomeView != null){ mIHomeView.onFailure(e.toString()); } } @Override public void onComplete() { } }); } }
MainActivity:
package com.example.yuekaomoni.mvp.view.activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.yuekaomoni.DetailActivity;
import com.example.yuekaomoni.R;
import com.example.yuekaomoni.adapter.FenleiAdapter;
import com.example.yuekaomoni.adapter.MiaoshaAdapter;
import com.example.yuekaomoni.adapter.TuijianAdapter;
import com.example.yuekaomoni.mvp.model.bean.Home;
import com.example.yuekaomoni.mvp.presenter.HomePresenter;
import com.example.yuekaomoni.mvp.view.iview.IHomeView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.youth.banner.BannerConfig;
import com.youth.banner.loader.ImageLoader;
import com.youth.banner.loader.ImageLoaderInterface;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MainActivity extends AppCompatActivity implements IHomeView {
@BindView(R.id.banner)
com.youth.banner.Banner banner;
@BindView(R.id.fenlei_rv)
RecyclerView fenleiRv;
@BindView(R.id.miaosha_rv)
RecyclerView miaoshaRv;
@BindView(R.id.tuijian_rv)
RecyclerView tuijianRv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
HomePresenter homePresenter = new HomePresenter(this);
homePresenter.home();
//分類九宮格
GridLayoutManager gridLayoutManager = new GridLayoutManager(MainActivity.this, 2);
gridLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
fenleiRv.setLayoutManager(gridLayoutManager);
//京東秒殺
miaoshaRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
//為你推薦
GridLayoutManager gridLayoutManager1 = new GridLayoutManager(MainActivity.this, 2);
gridLayoutManager1.setOrientation(LinearLayoutManager.VERTICAL);
tuijianRv.setLayoutManager(gridLayoutManager1);
}
@Override
public void onResponse(Home home) {
Home.DataBean data = home.getData();
//輪播圖
List<Home.DataBean.BannerBean> dataBanner = data.getBanner();
List<String> list = new ArrayList<>();
List<String> title_list = new ArrayList<>();
for (int i = 0; i < dataBanner.size(); i++) {
String icon = dataBanner.get(i).getIcon();
String title = dataBanner.get(i).getTitle();
list.add(icon);
title_list.add(title);
}
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
banner.setImageLoader(new GlideImageLoader());
banner.setImages(list);
banner.setBannerTitles(title_list);
banner.start();
//分類九宮格
List<Home.DataBean.FenleiBean> fenlei = data.getFenlei();
FenleiAdapter adapter = new FenleiAdapter(MainActivity.this, fenlei);
fenleiRv.setAdapter(adapter);
//秒殺
Home.DataBean.MiaoshaBean miaosha = data.getMiaosha();
List<Home.DataBean.MiaoshaBean.ListBean> list1 = miaosha.getList();
MiaoshaAdapter adapter1 = new MiaoshaAdapter(MainActivity.this, list1);
miaoshaRv.setAdapter(adapter1);
//為你推薦
Home.DataBean.TuijianBean tuijian = data.getTuijian();
final List<Home.DataBean.TuijianBean.ListBeanX> list2 = tuijian.getList();
TuijianAdapter adapter2 = new TuijianAdapter(MainActivity.this, list2);
tuijianRv.setAdapter(adapter2);
adapter2.setOnItemClickListener(new TuijianAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
//Toast.makeText(MainActivity.this, position+"", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, DetailActivity.class);
intent.putExtra("pid", list2.get(position).getPid());
startActivity(intent);
}
});
//Log.e("TAG", "成功");
}
@Override
public void onFailure(String error) {
//Log.e("TAG", "失敗");
}
private class GlideImageLoader extends ImageLoader {
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
Uri uri = Uri.parse((String) path);
imageView.setImageURI(uri);
}
@Override
public ImageView createImageView(Context context) {
SimpleDraweeView simpleDraweeView = new SimpleDraweeView(context);
return simpleDraweeView;
}
}
}
IProductDetailApi:
package com.example.yuekaomoni.mvp.view.iview;
import com.example.yuekaomoni.mvp.model.bean.ProductDetail;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* Created by DELL on 2018/7/27.
*/
public interface IProductDetailApi {
@GET()
Observable<ProductDetail> detail(@Url String url, @Query("pid") int pid);
}
商品詳情頁的Model —— ProductDetailModel :
package com.example.yuekaomoni.mvp.model;
import com.example.yuekaomoni.mvp.model.bean.ProductDetail;
import com.example.yuekaomoni.mvp.view.iview.IProductDetailApi;
import com.example.yuekaomoni.utils.RetrofitManager;
import io.reactivex.Observable;
/**
* Created by DELL on 2018/7/27.
*/
public class ProductDetailModel {
public Observable<ProductDetail> detail(String url, int pid) {
return RetrofitManager.getDefault().create(IProductDetailApi.class).detail("https://www.zhaoapi.cn/product/getProductDetail", pid);
}
}
商品詳情頁的Presenter —— ProductDetailPresenter :
package com.example.yuekaomoni.mvp.presenter;
import com.example.yuekaomoni.mvp.model.ProductDetailModel;
import com.example.yuekaomoni.mvp.model.bean.ProductDetail;
import com.example.yuekaomoni.mvp.view.iview.IProductDetailView;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* Created by DELL on 2018/7/27.
*/
public class ProductDetailPresenter {
private ProductDetailModel productDetailModel;
IProductDetailView mIProductDetailView;
public ProductDetailPresenter(IProductDetailView iProductDetailView) {
mIProductDetailView = iProductDetailView;
productDetailModel = new ProductDetailModel();
}
public void detail(int pid) {
productDetailModel.detail("https://www.zhaoapi.cn/product/getProductDetail", pid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<ProductDetail>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(ProductDetail productDetail) {
if (mIProductDetailView != null) {
mIProductDetailView.onResponse(productDetail);
}
}
@Override
public void onError(Throwable e) {
if (mIProductDetailView != null) {
mIProductDetailView.onFailure(e.toString());
}
}
@Override
public void onComplete() {
}
});
}
}
展示商品詳情的Activity —— DetailActivity:
package com.example.yuekaomoni;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.yuekaomoni.mvp.model.bean.AddCart;
import com.example.yuekaomoni.mvp.model.bean.ProductDetail;
import com.example.yuekaomoni.mvp.presenter.AddCartPresenter;
import com.example.yuekaomoni.mvp.presenter.ProductDetailPresenter;
import com.example.yuekaomoni.mvp.view.activity.CartsActivity;
import com.example.yuekaomoni.mvp.view.iview.IAddCartView;
import com.example.yuekaomoni.mvp.view.iview.IProductDetailView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.loader.ImageLoader;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class DetailActivity extends AppCompatActivity implements IProductDetailView, IAddCartView {
@BindView(R.id.banner)
Banner banner;
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.tv_subhead)
TextView tvSubhead;
@BindView(R.id.tv_price)
TextView tvPrice;
@BindView(R.id.tv_add)
TextView tvAdd;
private ProductDetailPresenter productDetailPresenter;
private AddCartPresenter addCartPresenter;
private int pid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
ButterKnife.bind(this);
productDetailPresenter = new ProductDetailPresenter(this);
addCartPresenter = new AddCartPresenter(this);
Intent intent = getIntent();
pid = intent.getIntExtra("pid", -1);
if (pid != -1) {
productDetailPresenter.detail(pid);
}
}
@Override
public void onResponse(ProductDetail productDetail) {
//Log.e("TAG", "成功");
ProductDetail.DataBean data = productDetail.getData();
tvTitle.setText(data.getTitle());
tvSubhead.setText(data.getSubhead());
tvPrice.setText("¥" + data.getPrice() + "");
String images = data.getImages();
String[] strings = images.split("\\|");
List<String> list = new ArrayList<>();
for (int i = 0; i < strings.length; i++) {
list.add(strings[i]);
}
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
banner.setImageLoader(new GlideImageLoader());
banner.setImages(list);
banner.start();
}
@Override
public void onResponse(AddCart addCart) {
Log.e("TAG","成功");
Toast.makeText(DetailActivity.this, addCart.getMsg() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(String error) {
Log.e("TAG", "失敗"+error.toString());
}
@OnClick(R.id.tv_add)
public void onViewClicked() {
addCartPresenter.addCart("71", pid);
Intent intent = new Intent(DetailActivity.this, CartsActivity.class);
intent.putExtra("pid",pid);
startActivity(intent);
}
private class GlideImageLoader extends ImageLoader {
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
Uri uri = Uri.parse((String) path);
imageView.setImageURI(uri);
}
@Override
public ImageView createImageView(Context context) {
SimpleDraweeView simpleDraweeView = new SimpleDraweeView(context);
return simpleDraweeView;
}
}
}
IAddCartApi:
package com.example.yuekaomoni.mvp.view.iview;
import com.example.yuekaomoni.mvp.model.bean.AddCart;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* Created by DELL on 2018/7/27.
*/
public interface IAddCartApi {
@GET()
Observable<AddCart> addCart(@Url String url, @Query("uid") String uid, @Query("pid") int pid);
}
加入購物車的Model —— AddCartModel:
package com.example.yuekaomoni.mvp.model;
import com.example.yuekaomoni.mvp.model.bean.AddCart;
import com.example.yuekaomoni.mvp.view.iview.IAddCartApi;
import com.example.yuekaomoni.utils.RetrofitManager;
import io.reactivex.Observable;
/**
* Created by DELL on 2018/7/27.
*/
public class AddCartModel {
public Observable<AddCart> addCart(String url, String uid, int pid) {
return RetrofitManager.getDefault().create(IAddCartApi.class).addCart("http://www.zhaoapi.cn/product/addCart", uid, pid);
}
}
加入購物車的Presenter —— AddCartPresenter:
package com.example.yuekaomoni.mvp.presenter;
import android.util.Log;
import com.example.yuekaomoni.mvp.model.AddCartModel;
import com.example.yuekaomoni.mvp.model.bean.AddCart;
import com.example.yuekaomoni.mvp.view.iview.IAddCartView;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Predicate;
import io.reactivex.schedulers.Schedulers;
/**
* Created by DELL on 2018/7/27.
*/
public class AddCartPresenter {
private AddCartModel addCartModel;
IAddCartView mIAddCartView;
public AddCartPresenter(IAddCartView iAddCartView) {
mIAddCartView = iAddCartView;
addCartModel = new AddCartModel();
}
public void addCart(String uid, int pid) {
addCartModel.addCart("http://www.zhaoapi.cn/product/addCart", uid, pid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<AddCart>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(AddCart addCart) {
mIAddCartView.onResponse(addCart);
}
@Override
public void onError(Throwable e) {
mIAddCartView.onFailure(e.toString());
}
@Override
public void onComplete() {
}
});
}
}
IGetCartsApi:
package com.example.yuekaomoni.mvp.view.iview;
import com.example.yuekaomoni.mvp.model.bean.Carts;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* Created by DELL on 2018/7/28.
*/
public interface IGetCartsApi {
@GET()
Observable<Carts> getCarts(@Url String url, @Query("uid") String uid);
}
購物車的Model —— GetCartsModel:
package com.example.yuekaomoni.mvp.model;
import com.example.yuekaomoni.mvp.model.bean.Carts;
import com.example.yuekaomoni.mvp.view.iview.IGetCartsApi;
import com.example.yuekaomoni.utils.RetrofitManager;
import io.reactivex.Observable;
/**
* Created by DELL on 2018/7/28.
*/
public class GetCartsModel {
public Observable<Carts> getCarts(String url, String uid) {
return RetrofitManager.getDefault().create(IGetCartsApi.class).getCarts(url, uid);
}
}
購物車的Presenter —— GetCartsPresenter:
package com.example.yuekaomoni.mvp.presenter;
import com.example.yuekaomoni.mvp.model.GetCartsModel;
import com.example.yuekaomoni.mvp.model.bean.Carts;
import com.example.yuekaomoni.mvp.view.iview.IGetCartsView;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* Created by DELL on 2018/7/28.
*/
public class GetCartsPresenter {
private GetCartsModel getCartsModel;
IGetCartsView mIGetCartsView;
public GetCartsPresenter(IGetCartsView iGetCartsView) {
mIGetCartsView = iGetCartsView;
getCartsModel = new GetCartsModel();
}
public void getCarts(String uid) {
getCartsModel.getCarts("http://www.zhaoapi.cn/product/getCarts", uid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Carts>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Carts carts) {
mIGetCartsView.onCartsResponse(carts);
}
@Override
public void onError(Throwable e) {
mIGetCartsView.onCartsFailure(e.toString());
}
@Override
public void onComplete() {
}
});
}
}
購物車的介面卡:
package com.example.yuekaomoni.adapter;
import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import com.example.yuekaomoni.MyAddSubView;
import com.example.yuekaomoni.R;
import com.example.yuekaomoni.mvp.model.bean.Carts;
import com.facebook.drawee.view.SimpleDraweeView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by DELL on 2018/7/28.
*/
public class MAdapter extends BaseExpandableListAdapter {
private Context context;
private List<Carts.DataBean> list;
public MAdapter(Context context, List<Carts.DataBean> list) {
this.context = context;
this.list = list;
}
@Override
public int getGroupCount() {
return list == null ? 0 : list.size();
}
@Override
public int getChildrenCount(int i) {
return list.get(i).getList() == null ? 0 : list.get(i).getList().size();
}
@Override
public Object getGroup(int i) {
return null;
}
@Override
public Object getChild(int i, int i1) {
return null;
}
@Override
public long getGroupId(int i) {
return 0;
}
@Override
public long getChildId(int i, int i1) {
return 0;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
ParentViewHolder parentHolder = null;
if (view == null) {
view = View.inflate(context, R.layout.cart_parent_item_layout, null);
parentHolder = new ParentViewHolder(view);
view.setTag(parentHolder);
} else {
parentHolder = (ParentViewHolder) view.getTag();
}
parentHolder.sellerNameTv.setText(list.get(i).getSellerName());
boolean currentSellerAllProductSelected = isCurrentSellerAllProductSelected(i);
parentHolder.sellerCk.setChecked(currentSellerAllProductSelected);
parentHolder.sellerCk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mOnCartListChangeListener != null) {
mOnCartListChangeListener.onSellerCheckedChange(i);
}
}
});
return view;
}
//判斷當前商家下所有商品是否被選中
public boolean isCurrentSellerAllProductSelected(int i) {
List<Carts.DataBean.ListBean> list = this.list.get(i).getList();
for (Carts.DataBean.ListBean listBean : list) {
if (listBean.getSelected() == 0) {
return false;
}
}
return true;
}
@Override
public View getChildView(final int i, final int i1, boolean b, View view, ViewGroup viewGroup) {
List<Carts.DataBean.ListBean> list = this.list.get(i).getList();
Carts.DataBean.ListBean listBean = list.get(i1);
ChildViewHolder childHolder = null;
if (view == null) {
view = View.inflate(context, R.layout.cart_child_item_layout, null);
childHolder = new ChildViewHolder(view);
view.setTag(childHolder);
} else {
childHolder = (ChildViewHolder) view.getTag();
}
childHolder.tvProductTitleName.setText(listBean.getTitle());
childHolder.tvProductPrice.setText("¥" + listBean.getPrice() + "");
String images = listBean.getImages();
String[] strings = images.split("\\|");
Uri uri = Uri.parse(strings[0]);
childHolder.sdvProductIcon.setImageURI(uri);
childHolder.childCk.setChecked(listBean.getSelected() == 1);
childHolder.childCk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mOnCartListChangeListener != null) {
mOnCartListChangeListener.onProductCheckedChange(i, i1);
}
}
});
childHolder.addSubView.setNum(listBean.getNum());
childHolder.addSubView.setOnNumChangeListener(new MyAddSubView.OnNumChangeListener() {
@Override
public void onNumChange(int number) {
mOnCartListChangeListener.onProductNumberChange(i, i1, number);
}
});
return view;
}
@Override
public boolean isChildSelectable(int i, int i1) {
return false;
}
//判斷所有商品是否被選中
public boolean isAllProductSelected() {
for (int i = 0; i < list.size(); i++) {
List<Carts.DataBean.ListBean> list = this.list.get(i).getList();
for (int j = 0; j < list.size(); j++) {
if (list.get(j).getSelected() == 0) {
return false;
}
}
}
return true;
}
//計算總價
public double calculateTotalPrice() {
double totalPrice = 0;
for (int i = 0; i < list.size(); i++) {
List<Carts.DataBean.ListBean> list = this.list.get(i).getList();
for (int j = 0; j < list.size(); j++) {
if (list.get(j).getSelected() == 1) {
double price = list.get(j).getPrice();
int num = list.get(j).getNum();
totalPrice += num * price;
}
}
}
return totalPrice;
}
//計算總量
public int calculateTotalNumber() {
int totalNumber = 0;
for (int i = 0; i < list.size(); i++) {
List<Carts.DataBean.ListBean> list = this.list.get(i).getList();
for (int j = 0; j < list.size(); j++) {
if (list.get(j).getSelected() == 1) {
int num = list.get(j).getNum();
totalNumber += num;
}
}
}
return totalNumber;
}
//當商家前的CheckBox被點選的時候設定當前商家下的所有商品的狀態
public void changeCurrentSellerAllProductsStatus(int i, boolean isSelected) {
List<Carts.DataBean.ListBean> list = this.list.get(i).getList();
for (int j = 0; j < list.size(); j++) {
Carts.DataBean.ListBean listBean = list.get(j);
listBean.setSelected(isSelected ? 1 : 0);
}
}
//當商品前的CheckBox被點選的時候改變商品的狀態
public void changeCurrentProductStatus(int i, int i1) {
Carts.DataBean dataBean = list.get(i);
List<Carts.DataBean.ListBean> list = dataBean.getList();
Carts.DataBean.ListBean listBean = list.get(i1);
listBean.setSelected(listBean.getSelected() == 0 ? 1 : 0);
}
//當點選加減按鈕時改變商品的數量
public void changeCurrentProductNumber(int i, int i1, int number) {
Carts.DataBean dataBean = list.get(i);
List<Carts.DataBean.ListBean> list = dataBean.getList();
Carts.DataBean.ListBean listBean = list.get(i1);
listBean.setNum(number);
}
//設定所有商品的狀態
public void changeAllProductsStatus(boolean selected) {
for (int i = 0; i < list.size(); i++) {
List<Carts.DataBean.ListBean> list = this.list.get(i).getList();
for (int j = 0; j < list.size(); j++) {
list.get(j).setSelected(selected ? 1 : 0);
}
}
}
static class ParentViewHolder {
@BindView(R.id.seller_ck)
CheckBox sellerCk;
@BindView(R.id.seller_name_tv)
TextView sellerNameTv;
ParentViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
static class ChildViewHolder {
@BindView(R.id.child_ck)
CheckBox childCk;
@BindView(R.id.sdv_product_icon)
SimpleDraweeView sdvProductIcon;
@BindView(R.id.tv_product_title_name)
TextView tvProductTitleName;
@BindView(R.id.tv_product_price)
TextView tvProductPrice;
@BindView(R.id.add_sub_view)
MyAddSubView addSubView;
ChildViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
private OnCartListChangeListener mOnCartListChangeListener;
public void setOnCartListChangeListener(OnCartListChangeListener mOnCartListChangeListener) {
this.mOnCartListChangeListener = mOnCartListChangeListener;
}
public interface OnCartListChangeListener {
void onSellerCheckedChange(int i);
void onProductCheckedChange(int i, int i1);
void onProductNumberChange(int i, int i1, int number);
}
}