package com.sheep.gamegroup.view.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sheep.gamegroup.model.entity.VoucherUseLog;
import com.sheep.gamegroup.util.GlideImageLoader;
import com.sheep.gamegroup.util.ViewHolder;
import com.sheep.gamegroup.util.ViewUtil;
import com.sheep.jiuyan.samllsheep.R;

import java.util.List;

/**
 * Created by realicing on 2018/8/28.
 * realicing@sina.com
 */
public class VoucherUseLogAdapter extends AdbCommonRecycler<VoucherUseLog>{
    public VoucherUseLogAdapter(Context context, List<VoucherUseLog> list) {
        super(context, list);
    }
    @Override
    public int getViewIdByType(int type) {
        return R.layout.item_download_welfare;
    }

    @Override
    public void convert(ViewHolder holder, final VoucherUseLog item) {
        ImageView item_download_welfare_iv = (ImageView)holder.getView(R.id.item_download_welfare_iv);
        ImageView item_download_welfare_iv2 = (ImageView)holder.getView(R.id.item_download_welfare_iv2);
        TextView item_download_welfare_name_tv = (TextView)holder.getView(R.id.item_download_welfare_name_tv);
        TextView item_download_welfare_money = (TextView)holder.getView(R.id.item_download_welfare_money);
        TextView item_download_welfare_money_bottom = (TextView)holder.getView(R.id.item_download_welfare_money_bottom);
        TextView item_download_welfare_num_tv = (TextView)holder.getView(R.id.item_download_welfare_num_tv);
        TextView item_download_welfare_num_tv1 = (TextView)holder.getView(R.id.item_download_welfare_num_tv1);
        TextView item_download_welfare_date_tv = (TextView)holder.getView(R.id.item_download_welfare_date_tv);
        TextView item_download_welfare_btn_bottom = (TextView)holder.getView(R.id.item_download_welfare_btn_bottom);
        View item_download_welfare_line = holder.getView(R.id.item_download_welfare_line);

        item_download_welfare_iv2.setVisibility(View.GONE);
        item_download_welfare_num_tv1.setVisibility(View.GONE);
        item_download_welfare_btn_bottom.setVisibility(View.GONE);
        item_download_welfare_money_bottom.setVisibility(View.VISIBLE);
        item_download_welfare_money.setTextColor(Color.parseColor("#ff999999"));
        item_download_welfare_line.setVisibility(holder.getAdapterPosition() + 1 == getItemCount() ? View.GONE : View.VISIBLE);
        if(item == null){
            ViewUtil.setDefaultText(item_download_welfare_name_tv);
            ViewUtil.setDefaultText(item_download_welfare_num_tv);
            ViewUtil.setDefaultText(item_download_welfare_num_tv1);
            ViewUtil.setDefaultText(item_download_welfare_date_tv);
            ViewUtil.setDefaultText(item_download_welfare_money);
        } else if(context instanceof Activity){
            GlideImageLoader.setGameImage(item_download_welfare_iv, item.getIcon());
            ViewUtil.setText(item_download_welfare_name_tv, item.getName());
            ViewUtil.setText(item_download_welfare_num_tv, item.getGiftRatioText());
            ViewUtil.setH5Text(item_download_welfare_money, item.getSurplusText());
            ViewUtil.setText(item_download_welfare_money_bottom, item.getConsumptionAmountText());
            ViewUtil.setText(item_download_welfare_date_tv, item.getDateText());
        }
    }

}
