package com.app.duck.adapter;

import android.content.res.ColorStateList;

import androidx.core.widget.ImageViewCompat;

import com.app.duck.R;
import com.app.duck.database.Config;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import frpclib.Frpclib;

public class FileListAdapter extends BaseQuickAdapter<Config, BaseViewHolder> {


    public FileListAdapter() {
        super(R.layout.item_recycler_main);
    }



    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, Config file) {
        baseViewHolder.setText(R.id.tv_name, file.getName());
        boolean running =(file.getConnecting() != null && file.getConnecting())|| Frpclib.isRunning(file.getUid());
        baseViewHolder.setImageResource(R.id.iv_play, running ? R.drawable.ic_stop_white : R.drawable.ic_play_white);
        ImageViewCompat.setImageTintList(baseViewHolder.getView(R.id.iv_play), ColorStateList.valueOf(getContext().getResources().getColor(running ? R.color.colorStop : R.color.black)));




    }


}
