package com.example.newframtool.adapter;

import android.annotation.TargetApi;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.newframtool.R;
import com.example.newframtool.bean.MyCarBean;
import com.example.newframtool.util.LogUtil;

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

/**
 * Created by WuXiaolong
 * on 2015/7/2.
 */
public class RiLiRecyclerViewAdapter extends RecyclerView.Adapter<RiLiRecyclerViewAdapter.ViewHolder> {

    private Context mContext;
    private List<MyCarBean.DataBean> dataList = new ArrayList<>();
    private List<String> rilidataList = new ArrayList<>();
    private ClickListenr listenr;



//    public void addAllData(List<MyCarBean.DataBean> dataList) {
//        this.dataList.clear();
//        this.dataList.addAll(dataList);
//        notifyDataSetChanged();
//    }

    public void addAllData(List<String> dataList) {
        this.rilidataList.clear();
        this.rilidataList.addAll(dataList);
        notifyDataSetChanged();
    }



    public RiLiRecyclerViewAdapter(Context context) {
        mContext = context;
    }

    public void setListenr(ClickListenr listenr) {
        this.listenr = listenr;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        public TextView carNumber;

        public View rootView;

        public ViewHolder(View itemView) {
            super(itemView);
            rootView = itemView;
            carNumber = (TextView) itemView.findViewById(R.id.text1);
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.rili_item, parent, false);
        return new ViewHolder(v);
    }

    @TargetApi(16)
    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {

        holder.carNumber.setText("position :"+position);


    }

    @Override
    public int getItemCount() {
        return 10;
    }


    public interface ClickListenr{
        void onClickEvent(int positon);
    }

}