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.Group;
import com.taikor.investment.utils.DegreeUtils;
import com.taikor.investment.utils.TimeUtils;

/**
 * 达人组合列表适配器
 * Created by Any on 2017/3/30.
 */

public class MasterAdapter extends BaseAdapter<Group> {

    public MasterAdapter(Activity context) {
        super(context);
    }

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

    @Override
    protected void handleItem(int itemViewType, int position, Group item, ViewHolder holder, boolean reused) {
        ImageView imageView = holder.get(R.id.iv_master_rank, ImageView.class);
        if (position == 0) {
            imageView.setImageResource(R.drawable.group_rank1);
        } else if (position == 1) {
            imageView.setImageResource(R.drawable.group_rank2);
        } else if (position == 2) {
            imageView.setImageResource(R.drawable.group_rank3);
        } else if (position == 3) {
            imageView.setImageResource(R.drawable.group_rank4);
        } else if (position == 4) {
            imageView.setImageResource(R.drawable.group_rank5);
        } else {
            imageView.setImageResource(0);
        }

        holder.get(R.id.tv_master_group_name, TextView.class).setText(item.getPortfolioName());
        holder.get(R.id.tv_master_name, TextView.class).setText(item.getManager());
        long createTime = item.getCreateTime();
        if (createTime == 0) {
            holder.get(R.id.tv_master_time, TextView.class).setText("创建于 ——");
        } else {
            holder.get(R.id.tv_master_time, TextView.class).setText("创建于 " + TimeUtils.getStringDate(createTime));
        }
        holder.get(R.id.tv_master_net_worth, TextView.class).setText(DegreeUtils.setDoubleFour(item.getNetWorth()));
        holder.get(R.id.tv_master_year_income, TextView.class).setText(DegreeUtils.setDoubleTwo(item.getAnnualizedProfit()) + "%");
        holder.get(R.id.tv_master_month_income, TextView.class).setText(DegreeUtils.setDoubleTwo(item.getMonthlyProfit()) + "%");
    }

}
