package com.taikor.investment.adapter;

import android.app.Activity;
import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.taikor.investment.R;
import com.taikor.investment.base.BaseAdapter;
import com.taikor.investment.bean.Report;
import com.taikor.investment.utils.TimeUtils;

/**
 * 研究报告
 * Created by Any on 2017/3/31.
 */

public class ReportAdapter extends BaseAdapter<Report> {

    private Context mContext;
    public ReportAdapter(Activity context) {
        super(context);
        mContext=context;
    }

    @Override
    protected int getItemLayoutId(int itemViewType) {
        return R.layout.item_find_report;
    }

    @Override
    protected void handleItem(int itemViewType, int position, Report item, BaseAdapter.ViewHolder holder, boolean reused) {
        holder.get(R.id.iv_type, ImageView.class).setImageResource(0);
        String fileName = item.getFileName();
        String[] split = fileName.split(".pdf");
        holder.get(R.id.tv_report_title, TextView.class).setText(split[0]);
        holder.get(R.id.tv_report_time, TextView.class).setText(TimeUtils.getDate(item.getUpdateTime()));

        ImageView imageView = holder.get(R.id.iv_type, ImageView.class);
        Glide.with(mContext)// /b/680f6fd237afb6336835a8678cc4623d_big.jpg
                .load("http://www.taikorcdn.com/reader/"+item.getImg())
                .placeholder(R.drawable.default_image)
                .error(R.drawable.default_image)
                .into(imageView);
//        holder.get(R.id.iv_type,ImageView.class).setImageResource(R.drawable.default_image);
    }
}
