package it.integry.integrywmsnative.core.model;

import androidx.databinding.Observable;
import it.integry.integrywmsnative.core.di.BindableBoolean;
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_mtbcolr_list.DialogChooseArtsFromMtbColrListItemModel;

public class CheckableMtbColr {


    private DialogChooseArtsFromMtbColrListItemModel item;
    private BindableBoolean checked = new BindableBoolean(false);
    private BindableBoolean hidden = new BindableBoolean(false);

    public CheckableMtbColr(DialogChooseArtsFromMtbColrListItemModel item) {
        this.item = item;

        this.item.getHidden().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {
                hidden.set(item.isHidden());
            }
        });
    }

    public DialogChooseArtsFromMtbColrListItemModel getItem() {
        return item;
    }

    public CheckableMtbColr setItem(DialogChooseArtsFromMtbColrListItemModel item) {
        this.item = item;

        this.item.getHidden().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {
                hidden.set(item.isHidden());
            }
        });

        return this;
    }

    public BindableBoolean getChecked() {
        return checked;
    }

    public CheckableMtbColr setChecked(BindableBoolean checked) {
        this.checked = checked;
        return this;
    }

    public BindableBoolean getHidden() {
        return hidden;
    }

    public boolean isHidden() {
        return hidden.get();
    }

    public CheckableMtbColr setHidden(BindableBoolean hidden) {
        this.hidden = hidden;
        return this;
    }
}
