package com.phlx.anchorcollect.ui.labelchange.list;

import android.os.Bundle;
import android.view.View;

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

import com.phlx.anchorcollect.entity.CattleResumeEntity;
import com.phlx.anchorcollect.entity.InspectEntity;
import com.phlx.anchorcollect.ui.labelchange.LabelChangeActivity;

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

public class ExchangeItem extends ItemViewModel<ExchangeListVM> {

    public ObservableField<InspectEntity>  inspectEntity = new ObservableField<>();
    public ObservableField<CattleResumeEntity> entity = new ObservableField<>();
    public ObservableField<String> inspectString = new ObservableField<>("");

    public ExchangeItem(@NonNull ExchangeListVM viewModel,CattleResumeEntity entity, InspectEntity inspectEntity) {
        super(viewModel);

        this.inspectEntity.set(inspectEntity);
        this.entity.set(entity);

        //1 电子耳标重复
        //     * 2 可视耳标重复
        //     * 3 全部重复
        switch (inspectEntity.getType()) {
            case 1:
                inspectString.set("电子耳标重复");
                break;
            case 2:
                inspectString.set("可视耳标重复");
                break;
            case 3:
                inspectString.set("电子耳标、可视耳标全部重复");
                break;
            default:
                break;
        }
    }


    public BindingCommand onItemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle mBundle = new Bundle();
            mBundle.putParcelable("entity", entity.get());
            mBundle.putParcelable("inspectEntity", inspectEntity.get());
            viewModel.startActivity(LabelChangeActivity.class, mBundle);
        }
    });
}
