package com.unis.sxzcl.widget.banner;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.unis.model.bean.AnnounceBean;
import com.unis.sxzcl.R;
import com.xyxsbj.mylibrary.tool.DateTool;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.util.BannerUtils;

import java.util.List;


/**
 * 包名: com.unis.sxzcl.widget.banner
 * 类名: TopLineAdapter
 * 作用描述: 纵向轮播适配器
 * 创建人: mQ
 * 创建时间: 2020/11/30 21:01
 * 更新人:
 * 更新时间: 2020/11/30 21:01
 * 更新说明:
 * 版本号: 1.0
 */
public class TopLineAdapter extends BannerAdapter<AnnounceBean, TopLineAdapter.TopLineHolder> {

    public TopLineAdapter(List<AnnounceBean> list) {
        super(list);
    }

    @Override
    public TopLineHolder onCreateHolder(ViewGroup parent, int viewType) {
        return new TopLineHolder(BannerUtils.getView(parent, R.layout.item_notice_banner));
    }

    @Override
    public void onBindView(TopLineHolder holder, AnnounceBean data, int position, int size) {
        holder.tvTitle.setText(data.getTitle());
        String publishTime = data.getPublishTime();
        try {
            publishTime = DateTool.formatDate(publishTime, DateTool.GLNZSJ_DATE, DateTool.YTDTD_DATE);
        } catch (Exception e) {
        }
        holder.tvTime.setText(publishTime);
    }

    class TopLineHolder extends RecyclerView.ViewHolder {
        public TextView tvTitle;
        public TextView tvTime;

        public TopLineHolder(@NonNull View view) {
            super(view);
            tvTitle = view.findViewById(R.id.tv_title);
            tvTime = view.findViewById(R.id.tv_time);
        }
    }
}
