package com.phlx.wool.ui.cattle.activity;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModelProviders;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.phlx.wool.R;
import com.phlx.wool.data.VMFactory;
import com.phlx.wool.databinding.ActivityCattleMainBinding;
import com.phlx.wool.ui.base.BaseActivity;
import com.phlx.wool.ui.cattle.vm.CattleMainVM;
import com.phlx.wool.ui.inventory.InventoryVM;

import me.tatarka.bindingcollectionadapter2.BR;

public class CattleMainActivity extends BaseActivity<ActivityCattleMainBinding, CattleMainVM> {
    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_cattle_main;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initParam() {
        super.initParam();
    }

    @Override
    public CattleMainVM initViewModel() {
        VMFactory factory = VMFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(CattleMainVM.class);
    }

    @Override
    public void initData() {
        super.initData();
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();

        viewModel.nullEvent.observe(this, aBoolean -> {
            new MaterialDialog.Builder(this).title("系统信息").content("请先选择养殖户!!!")
                    .cancelable(false).canceledOnTouchOutside(false)
                    .positiveText("确定").onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    if (which == DialogAction.POSITIVE) {
                        dialog.dismiss();
                    }
                }
            }).show();
        });

    }
}
