EventBus 全选中状态下的计算价格

public class dianjiEvent {
    private int postion;
    private int adapterpostion;
    private int sum;

    public int getPostion() {
        return postion;
    }

    public void setPostion(int postion) {
        this.postion = postion;
    }

    public int getAdapterpostion() {
        return adapterpostion;
    }

    public void setAdapterpostion(int adapterpostion) {
        this.adapterpostion = adapterpostion;
    }

    public int getSum() {
        return sum;
    }

    public void setSum(int sum) {
        this.sum = sum;
    }
 Context context;
    List<ShowBean.DataBean.SpusBean> spus;
    //拿去外层的下标
    int postion;
    public List<ShowBean.DataBean.SpusBean> getSpus() {
        return spus;
    }

    public void setSpus(List<ShowBean.DataBean.SpusBean> spus) {
        this.spus = spus;
    }

    public RecycleSP_Adapter(Context context, List<ShowBean.DataBean.SpusBean> spus, int postion) {
        this.context = context;
        this.spus = spus;
        this.postion = postion;
    }
 zdy.setOnAddListenter(new Zdy.OnAddListenter() {
                @Override
                public void numListenter(int sum) {
                    //获取里面的
                    int adapterPosition = getAdapterPosition();
                    //postion:主层的位置 // adapterPosition:内层的位置 sum:数据的数量
                    EventBus.getDefault().post(new dianjiEvent(postion,adapterPosition,sum));
                }
            });

//注解不能少@Subscribe

@Subscribe
    public void onDianjiEvent(dianjiEvent dianjiEvent){
        //获取两个下标
       int adapterpostion = dianjiEvent.getAdapterpostion();
        int postion = dianjiEvent.getPostion();
        //获取Recycke_View的Adaoter中
        List<ShowBean.DataBean> data = recycleYH_adapter.getData();
        //获取当前那列
        ShowBean.DataBean dataBean = data.get(postion);
        //哪行
        List<ShowBean.DataBean.SpusBean> spus = dataBean.getSpus();
        ShowBean.DataBean.SpusBean spusBean = spus.get(adapterpostion);
        //获取点击的数量 //自己去里层去设置一个数量
        int sum = dianjiEvent.getSum();
        //设置的值是你设置数量的值
        spusBean.setPraise_num(sum);
        //当里面的选中的时候
        if (spusBean.isThree()){
            CountPrice();
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值