package com.taikor.investment.adapter;

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

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 RandomReportAdapter extends BaseAdapter<Report> {

    public RandomReportAdapter(Activity activity) {
        super(activity);
    }

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

    @Override
    protected void handleItem(int itemViewType, int position, Report item, ViewHolder holder, boolean reused) {
        ImageView imageView = holder.get(R.id.iv_rank_icon, ImageView.class);
        if (position == 0) {
            imageView.setImageResource(R.drawable.report_rank1);
        } else if (position == 1) {
            imageView.setImageResource(R.drawable.report_rank2);
        } else if (position == 2)
            imageView.setImageResource(R.drawable.report_rank3);
        String fileName = item.getFileName();
        String[] split = fileName.split(".pdf");
        holder.get(R.id.tv_random_report_title, TextView.class).setText(split[0]);
        holder.get(R.id.tv_random_report_time, TextView.class).setText(TimeUtils.getDate(item.getUpdateTime()));
    }
}
