package com.taikor.investment.adapter;

import android.app.Activity;
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 OfficialAdapter extends BaseAdapter<Group> {

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

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

    @Override
    protected void handleItem(int itemViewType, int position, Group item, ViewHolder holder, boolean reused) {
        holder.get(R.id.tv_off_group_name, TextView.class).setText(item.getPortfolioName());
        long createTime = item.getCreateTime();
        if(createTime==0){
            holder.get(R.id.tv_off_time, TextView.class).setText("创建于 ——");
        }else{
            holder.get(R.id.tv_off_time, TextView.class).setText("创建于 "+TimeUtils.getStringDate(createTime));
        }
        holder.get(R.id.tv_off_net_worth, TextView.class).setText(DegreeUtils.setDoubleFour(item.getNetWorth()));
        holder.get(R.id.tv_off_year_income, TextView.class).setText(DegreeUtils.setDoubleTwo(item.getAnnualizedProfit()) + "%");
        holder.get(R.id.tv_off_month_income, TextView.class).setText(DegreeUtils.setDoubleTwo(item.getMonthlyProfit()) + "%");
    }
}
