package com.phlx.wool.ui.work.unit;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;


import com.phlx.wool.entity.Unit;

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

/**
 * <pre>
 *     author : lei
 *     e-mail : 18600395998@163.com
 *     time   : 2020/04/26
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class UnitItem extends ItemViewModel<UnitVM> {

    public ObservableField<Unit> entity = new ObservableField<>();

    public UnitItem(@NonNull UnitVM viewModel, Unit entity) {
        super(viewModel);
        this.entity.set(entity);
    }

    /**
     * 下标
     */
    public int getPosition() {
        return viewModel.getItemPosition(this);
    }

    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            viewModel.selectItemLiveData.setValue(UnitItem.this);
        }
    });

}
