package com.cooleshow.teacher.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.BaseLoadMoreModule;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.cooleshow.base.utils.TimeUtils;
import com.cooleshow.base.utils.UiUtils;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.bean.MusicSheetListBean;
import com.cooleshow.teacher.bean.UserAccountBean;

import java.util.Date;
import java.util.List;

/**
 * 创建日期：2022/5/23 14:49
 *
 * @author Ryan
 * 类说明：
 */
public class MineIncomeAdapter extends BaseQuickAdapter<UserAccountBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public MineIncomeAdapter() {
        super(R.layout.layout_mine_income_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, UserAccountBean.RowsBean item) {
        TextView tv_time = helper.getView(R.id.tv_time);
        ImageView im_state = helper.getView(R.id.im_state);
        TextView tv_name = helper.getView(R.id.tv_name);
        TextView tv_date = helper.getView(R.id.tv_date);
        TextView tv_price = helper.getView(R.id.tv_price);
        if (getItemPosition(item) > 0) {
            int lastPosition = getItemPosition(item) - 1;
            if (getData().get(lastPosition).timeDay.equals(item.timeDay)) {
                tv_time.setVisibility(View.GONE);
            } else {
                tv_time.setVisibility(View.VISIBLE);
                tv_time.setText(item.timeDay);
            }
        } else {
            tv_time.setVisibility(View.VISIBLE);
            tv_time.setText(item.timeDay);
        }
        switch (item.bizType) {
            case "PRACTICE":
                im_state.setBackgroundResource(R.drawable.icon_item_practice);
                tv_date.setText(UiUtils.getCourseTimeString(item.startTime, item.endTime));
                break;
            case "LIVE":
                im_state.setBackgroundResource(R.drawable.icon_item_live);
                tv_date.setText(UiUtils.getCourseTimeString(item.startTime, item.endTime));
                break;
            case "VIDEO":
                im_state.setBackgroundResource(R.drawable.icon_item_video);
                tv_date.setText(item.createTime);
                break;
            case "MUSIC":
                im_state.setBackgroundResource(R.drawable.icon_item_music);
                tv_date.setText(item.createTime);
                break;
        }
        tv_name.setText(item.bizName);
        tv_price.setText(item.transAmount);
    }

    @NonNull
    @Override
    public BaseLoadMoreModule addLoadMoreModule(@NonNull BaseQuickAdapter<?, ?> baseQuickAdapter) {
        return new BaseLoadMoreModule(baseQuickAdapter);
    }
}
