package com.bc_chat.im.activity.envelopes.adapter;

import android.content.Context;
import android.widget.TextView;

import com.bc_chat.bc_base.entity.wallet.RedPacketRecordEntity;
import com.bc_chat.im.R;
import com.zhaohaoting.framework.imagepicker.camera.util.LogUtil;
import com.zhaohaoting.framework.view.recyclerview.BasicRecyclerAdapter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Author: hxm
 * Date: 2019/5/8
 * Desc:
 * Version: 1.0
 */
public class RedPacketRecordAdapter extends BasicRecyclerAdapter<RedPacketRecordEntity> {

    public RedPacketRecordAdapter(Context context, List<RedPacketRecordEntity> list) {
        super(context, list, R.layout.item_redpacket_record);
    }

    @Override
    public void convert(ViewHolder holder, RedPacketRecordEntity item, int position) {
        if (item != null) {
            try {
                TextView tvContent = holder.getView(R.id.tvContent);
                TextView tvTime = holder.getView(R.id.tvTime);
                TextView tvAmount = holder.getView(R.id.tvAmount);

                tvContent.setText(item.getString());

                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                long lcc_time = Long.valueOf(item.getTime());
                tvTime.setText(sdf.format(new Date(lcc_time * 1000L)));
                tvAmount.setText(item.getMark() + item.getAmount() + "元");

            } catch (Exception e) {
                LogUtil.d(e.getMessage());
            }
        }
    }
}
