package com.cooleshow.teacher.adapter;

import android.text.TextUtils;
import android.view.View;
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.teacher.R;
import com.cooleshow.teacher.bean.WithdrawalRecordBean;

import java.util.List;

/**
 * 创建日期：2022/5/24 10:27
 *
 * @author Ryan
 * 类说明：
 */
public class WithdrawalRecordAdapter extends BaseQuickAdapter<WithdrawalRecordBean.RowsBean, BaseViewHolder> implements LoadMoreModule {

    public WithdrawalRecordAdapter() {
        super(R.layout.layout_withdrawal_record_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, WithdrawalRecordBean.RowsBean item) {
        TextView tv_bank_card = helper.getView(R.id.tv_bank_card);
        TextView tv_date = helper.getView(R.id.tv_date);
        TextView tv_price = helper.getView(R.id.tv_price);
        TextView tv_state = helper.getView(R.id.tv_state);
        tv_bank_card.setText(item.bankCard);
        tv_date.setText(item.createTime);
        tv_price.setText("￥" + item.amount);
        // pending、交易处理中 succeeded、交易成功 failed、交易失败 ,可用值:pending,succeeded,failed,close
        if (!TextUtils.isEmpty(item.withdrawStatus)) {
            tv_state.setVisibility(View.VISIBLE);
            switch (item.withdrawStatus) {
                case "DOING":
                    tv_state.setText("审核中");
                    tv_state.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_666666));
                    break;
                case "SUCCESS":
                    tv_state.setText("结算成功");
                    tv_state.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
                    break;
                case "FAILED":
                    tv_state.setText("结算失败");
                    tv_state.setTextColor(getContext().getResources().getColor(com.cooleshow.base.R.color.color_ff5c5f));
                    break;
            }
        } else {
            tv_state.setVisibility(View.GONE);
        }

    }

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