package com.genlot.ninglottery.module.cash;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.genlot.ninglottery.R;

import java.util.List;

public class WinDetailAdapter extends BaseAdapter {

    private Context context;
    private List<WinDetailBean> mList;

    public WinDetailAdapter(Context context, List<WinDetailBean> list) {
        this.context = context;
        this.mList = list;
    }

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

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

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_win_detail, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.tvBet = convertView.findViewById(R.id.tv_detail_bet);
            viewHolder.tvLevel = convertView.findViewById(R.id.tv_detail_level);
            viewHolder.tvBetNum = convertView.findViewById(R.id.tv_detail_betNum);
            viewHolder.tvTimes = convertView.findViewById(R.id.tv_detail_time);
            viewHolder.tvPrize = convertView.findViewById(R.id.tv_detail_prize);
            viewHolder.tvTax = convertView.findViewById(R.id.tv_detail_tax);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        WinDetailBean winDetailBean = mList.get(position);
        viewHolder.tvBet.setText(winDetailBean.getBetSN());
        viewHolder.tvLevel.setText(winDetailBean.getWinLevel());
        viewHolder.tvBetNum.setText(winDetailBean.getBetCount());
        viewHolder.tvTimes.setText(winDetailBean.getMultiTimes());
        viewHolder.tvPrize.setText(winDetailBean.getPrizeMoney());
        viewHolder.tvTax.setText(winDetailBean.getPrizeTax());
        return convertView;
    }

    class ViewHolder{
        TextView tvBet;
        TextView tvLevel;
        TextView tvBetNum;
        TextView tvTimes;
        TextView tvPrize;
        TextView tvTax;
    }
}
