package com.wd.workoffice.ui.adapter;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.app.Config;

import java.util.List;

/**
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class FilterBaseAdapter extends BaseAdapter {
    int choosePos = 0;

    List<String> dataList;

    public FilterBaseAdapter(List<String> dataList) {
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(
                    R.layout.item_filter, parent, false);
        }
        TextView result = convertView.findViewById(R.id.tv_name);
        if (position == choosePos) {
            result.setBackgroundColor(Color.parseColor("#ffeaf3fe"));
            result.setTextColor(Color.parseColor("#2F89FC"));
        } else {
            result.setTextColor(parent.getContext().getResources().
                    getColor(R.color.flexible_text_color));
            result.setBackgroundColor(Color.WHITE);
        }
        result.setText(dataList.get(position));
        return convertView;
    }

    public int getChoosePos() {
        return choosePos;
    }

    public void setChoosePos(int choosePos) {
        this.choosePos = choosePos;
    }
}
