// Path: mvvm-life-cycle/src/main/java/me/henrytao/mvvmlifecycle/rx/UnsubscribeLifeCycle.java
// public enum UnsubscribeLifeCycle {
//   PAUSE,
//   STOP,
//   DESTROY_VIEW,
//   DESTROY
// }
// 
// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/ui/base/BaseActivity.java
// public abstract class BaseActivity extends MVVMActivity {
// 
// }
// 
// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/ui/base/Constants.java
// public class Constants {
// 
//   public interface Animation {
// 
//     int LONG = 600;
//     int MEDIUM = 400;
//     int SHORT = 200;
//   }
// 
//   public interface Extra {
// 
//     String ID = "ID";
//   }
// 
//   public interface Key {
// 
//     String ID = "ID";
//     String INDEX = "INDEX";
//   }
// }


import me.henrytao.mvvmlifecycledemo.ui.base.Constants;
import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import me.henrytao.mdcore.utils.ResourceUtils;
import me.henrytao.mvvmlifecycle.rx.UnsubscribeLifeCycle;
import me.henrytao.mvvmlifecycledemo.R;
import me.henrytao.mvvmlifecycledemo.databinding.TaskAddEditActivityBinding;
import me.henrytao.mvvmlifecycledemo.ui.base.BaseActivity;
    Bundle bundle = getIntent().getExtras();
    String taskId = bundle.getString(Constants.Extra.ID);

    setTitle(!TextUtils.isEmpty(taskId) ? R.string.edit_task : R.string.add_task);

    mViewModel = new TaskAddEditViewModel(taskId);
    addViewModel(mViewModel);
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.action_done:
        mViewModel.onDoneClick();
        break;
    }
    return true;
  }

  @Override
  public void onSetContentView(Bundle savedInstanceState) {
    mBinding = DataBindingUtil.setContentView(this, R.layout.task_add_edit_activity);
    mBinding.setViewModel(mViewModel);

    setSupportActionBar(mBinding.toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mBinding.toolbar.setNavigationOnClickListener(v -> onBackPressed());
    ResourceUtils.supportDrawableTint(this, mBinding.toolbar, ResourceUtils.Palette.PRIMARY);

    manageSubscription(mViewModel.getState().subscribe(state -> {
// Path: mvvm-life-cycle/src/main/java/me/henrytao/mvvmlifecycle/rx/UnsubscribeLifeCycle.java
// public enum UnsubscribeLifeCycle {
//   PAUSE,
//   STOP,
//   DESTROY_VIEW,
//   DESTROY
// }
// 
// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/ui/base/BaseActivity.java
// public abstract class BaseActivity extends MVVMActivity {
// 
// }
// 
// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/ui/base/Constants.java
// public class Constants {
// 
//   public interface Animation {
// 
//     int LONG = 600;
//     int MEDIUM = 400;
//     int SHORT = 200;
//   }
// 
//   public interface Extra {
// 
//     String ID = "ID";
//   }
// 
//   public interface Key {
// 
//     String ID = "ID";
//     String INDEX = "INDEX";
//   }
// }


// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/ui/taskaddedit/TaskAddEditActivity.java
import me.henrytao.mvvmlifecycledemo.ui.base.Constants;
import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import me.henrytao.mdcore.utils.ResourceUtils;
import me.henrytao.mvvmlifecycle.rx.UnsubscribeLifeCycle;
import me.henrytao.mvvmlifecycledemo.R;
import me.henrytao.mvvmlifecycledemo.databinding.TaskAddEditActivityBinding;
import me.henrytao.mvvmlifecycledemo.ui.base.BaseActivity;

    Bundle bundle = getIntent().getExtras();
    String taskId = bundle.getString(Constants.Extra.ID);

    setTitle(!TextUtils.isEmpty(taskId) ? R.string.edit_task : R.string.add_task);

    mViewModel = new TaskAddEditViewModel(taskId);
    addViewModel(mViewModel);
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.action_done:
        mViewModel.onDoneClick();
        break;
    }
    return true;
  }

  @Override
  public void onSetContentView(Bundle savedInstanceState) {
    mBinding = DataBindingUtil.setContentView(this, R.layout.task_add_edit_activity);
    mBinding.setViewModel(mViewModel);

    setSupportActionBar(mBinding.toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mBinding.toolbar.setNavigationOnClickListener(v -> onBackPressed());
    ResourceUtils.supportDrawableTint(this, mBinding.toolbar, ResourceUtils.Palette.PRIMARY);

    manageSubscription(mViewModel.getState().subscribe(state -> {
      switch (state.getName()) {