package com.ysnows.base.binding;

import android.content.res.ColorStateList;

import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButtonDrawable;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundFrameLayout;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout;

import androidx.databinding.BindingAdapter;

public class QMUIRountLayoutBindingAdapter {

    @BindingAdapter("qmui_backgroundColor")
    public static void setQmuiBackgroundColor(QMUIRoundFrameLayout view, int color) {
        QMUIRoundButtonDrawable background = (QMUIRoundButtonDrawable) view.getBackground();
        background.setBgData(ColorStateList.valueOf(color));
        view.setBackground(background);
    }

    @BindingAdapter("qmui_backgroundColor")
    public static void setQmuiBackgroundColor(QMUIRoundLinearLayout view, int color) {
        QMUIRoundButtonDrawable background = (QMUIRoundButtonDrawable) view.getBackground();
        background.setBgData(ColorStateList.valueOf(color));
        view.setBackground(background);
    }

    @BindingAdapter("qmui_borderColor")
    public static void setQmuiBorderColor(QMUIRoundLinearLayout view, int color) {
        QMUIRoundButtonDrawable background = (QMUIRoundButtonDrawable) view.getBackground();
        background.setStrokeColors(ColorStateList.valueOf(color));
        view.setBackground(background);
    }

}
