在kotlin中如何使用BaseRecyclerViewAdapterHelper的BaseQuickAdapter适配器

为了更好的进行理解先来对比下
Java代码

public class WithdrawRecordAdapter2 extends BaseQuickAdapter<TestWithdrawalRecordBena, BaseViewHolder> {

    public WithdrawRecordAdapter2(int layoutResId, @Nullable List<TestWithdrawalRecordBena> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, TestWithdrawalRecordBena item) {
        TextView status = helper.getView(R.id.withdraw_state);
        helper.setText(R.id.withdraw_number, "-¥" + item.getMoney()).setText(R.id.withdraw_date, item.getDate());
        if (item.getState() == 1) {
            status.setText("提现中");
            status.setTextColor(Color.parseColor("#1A66FF"));

        } else if (item.getState() == 0) {
            status.setText("已提现");
            status.setTextColor(Color.parseColor("#3DC637"));
        } else if (item.getState() == -1) {
            status.setText("未通过");
            status.setTextColor(Color.parseColor("#FF661A"));
        }
    }
}

Kotlin代码

class WithdrawRecordAdapter2(layoutResId: Int, data: List<TestWithdrawalRecordBena?>?) : BaseQuickAdapter<TestWithdrawalRecordBena, BaseViewHolder>(layoutResId, data) {
    override fun convert(helper: BaseViewHolder, item: TestWithdrawalRecordBena) {
        val status = helper.getView<TextView>(R.id.withdraw_state)
        helper.setText(R.id.withdraw_number, "-¥" + item.money).setText(R.id.withdraw_date, item.date)
        if (item.state == 1) {
            status.text = "提现中"
            status.setTextColor(Color.parseColor("#1A66FF"))
        } else if (item.state == 0) {
            status.text = "已提现"
            status.setTextColor(Color.parseColor("#3DC637"))
        } else if (item.state == -1) {
            status.text = "未通过"
            status.setTextColor(Color.parseColor("#FF661A"))
        }
    }
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容