package com.android.chmo.ui.adpater;

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.android.chmo.R;
import com.android.chmo.model.WalletRecord;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MyWalletAdapter extends RecyclerView.Adapter<MyWalletAdapter.MyWalletHolder> {
    private List<WalletRecord> data;
    private Context            context;

    public MyWalletAdapter(List<WalletRecord> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public MyWalletHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyWalletHolder(LayoutInflater.from(context).inflate(R.layout.list_wallet, parent, false));
    }

    @Override
    public void onBindViewHolder(MyWalletHolder holder, int position) {
        WalletRecord record = data.get(position);
        holder.tvAmount.setText(record.getCoin());
        holder.tvName.setText(record.getAtype());
        holder.tvTime.setText(record.getAdate());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    class MyWalletHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_amount)
        TextView tvAmount;
        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_time)
        TextView tvTime;

        public MyWalletHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
