// 商家控制商品全选
((ViewHolder) viewHolder).sj_check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO: 2019/4/7 改变本组商品状态
/**
* 1、得到本组商品
* 2、改变本组商品
* 3、刷新适配器
* 4、通知总价栏刷新
*/
//本个商家
CarBean.DataBean dataBean = data.get(i);
dataBean.setSjCheck(isChecked);
//本商家中的商品
List<CarBean.DataBean.ListBean> list = dataBean.getList();
for (int j = 0; j < list.size(); j++) {
//获取每个商品
CarBean.DataBean.ListBean bean = list.get(j);
//更改商品状态
bean.setSpCheck(isChecked);
}
//刷新适配器
new Handler().post(new Runnable() {
@Override
public void run() {
notifyDataSetChanged();
//通知总价栏刷新
if (groupCheckListener != null) {
groupCheckListener.onGroupCheck();
}
}
});
}
});
public void setGroupCheckListener(GroupCheckListener groupCheckListener) {
this.groupCheckListener = groupCheckListener;
}
private GroupCheckListener groupCheckListener;
public interface GroupCheckListener{
void onGroupCheck();
}