购物车主界面和view层

package com.lbp.yuekao.view;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.TextView;

import com.lbp.yuekao.R;
import com.lbp.yuekao.adapter.MyAdapter;
import com.lbp.yuekao.adapter.MyExAdapter;
import com.lbp.yuekao.bean.GoosBean;
import com.lbp.yuekao.bean.MessageEvent;
import com.lbp.yuekao.bean.PriceAndCountEvent;
import com.lbp.yuekao.presenter.MainPresenter;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.List;

public class ContextActivity extends AppCompatActivity implements IContextView {

    private ExpandableListView elv;
    private TextView tv_num;
    private TextView tv_price;
    private CheckBox checkBox2;
    private MyExAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_context);
        initViews();
        new MainPresenter(this).getGoods();
        checkBox2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                adapter.changeAllListCbState(checkBox2.isChecked());
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);

    }

    private void initViews() {
        elv = (ExpandableListView) findViewById(R.id.elv);
        checkBox2 = (CheckBox) findViewById(R.id.checkbox2);
        tv_price = (TextView) findViewById(R.id.tv_price);
        tv_num = (TextView) findViewById(R.id.tv_num);
    }

    @Override
    public void showList(List<GoosBean.DataBean> groupList, List<List<GoosBean.DataBean.DatasBean>> childList) {
        adapter = new MyExAdapter(this, groupList, childList);
        elv.setAdapter(adapter);
        elv.setGroupIndicator(null);
        //默认让其全部展开
        for (int i = 0; i < groupList.size(); i++) {
            elv.expandGroup(i);
        }
    }

    @Subscribe
    public void onMessageEvent(MessageEvent event) {
        checkBox2.setChecked(event.isChecked());
    }

    @Subscribe
    public void onMessageEvent(PriceAndCountEvent event) {
        tv_num.setText("结算(" + event.getCount() + ")");
        tv_price.setText(event.getPrice() + "");
    }
}
view层 
package com.lbp.yuekao.view;

import com.lbp.yuekao.bean.GoosBean;

import java.util.List;

/**
 * Created by Administrator on 2018/1/17 0017.
 */

public interface IContextView {
    void showList(List<GoosBean.DataBean> groupList, List<List<GoosBean.DataBean.DatasBean>> childList);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值