package com.qhclh.ytzh.index.planorder;

import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity;
import com.qhclh.ytzh.bean.CarsBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by 青花瓷 on 2017/11/29.
 */
///< 派车老板看到的所有车辆
public class CarsActivity extends BaseActivity {
    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.gv_cars)
    GridView gv_cars;
    private List<CarsBean> carsBeanList;
    private CarsAdapter carsAdapter;

    @Override
    protected int setLayoutId() {
        return R.layout.act_cars;
    }

    @Override
    protected void initView() {
        initToolbar(mToolbar, "车辆", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    protected void initData() {
        carsBeanList = new ArrayList<>();
        for (int i=0;i<10;i++){
            carsBeanList.add(new CarsBean(i+11,"aa"+i,"bb"+i));
        }
        carsAdapter = new CarsAdapter(this,carsBeanList);
        gv_cars.setAdapter(carsAdapter);
    }

    @Override
    protected void initOper() {
        gv_cars.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                showToast(l+"");
            }
        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.find, menu);
        menu.findItem(R.id.findcar).setVisible(true);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.findcar:
                findcar();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    private void findcar() {
        startActivity(new Intent(this,ChickenDriverBillActivity.class));
    }

}
