// 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
// public class TaskAddEditActivity extends BaseActivity {
// 
//   public static Intent newIntent(Context context) {
//     return newIntent(context, null);
//   }
// 
//   public static Intent newIntent(Context context, String taskId) {
//     Intent intent = new Intent(context, TaskAddEditActivity.class);
//     Bundle bundle = new Bundle();
//     bundle.putString(Constants.Extra.ID, taskId);
//     intent.putExtras(bundle);
//     return intent;
//   }
// 
//   private TaskAddEditActivityBinding mBinding;
// 
//   private TaskAddEditViewModel mViewModel;
// 
//   @Override
//   public boolean onCreateOptionsMenu(Menu menu) {
//     getMenuInflater().inflate(R.menu.menu_task_add_edit, menu);
//     ResourceUtils.supportDrawableTint(this, menu, ResourceUtils.Palette.PRIMARY);
//     return super.onCreateOptionsMenu(menu);
//   }
// 
//   @Override
//   public void onInitializeViewModels() {
//     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()) {
//         case CREATED_TASK:
//           finish();
//           break;
//         case CREATING_TASK:
//           // TODO: should handle progressbar
//           break;
//         case MISSING_TITLE:
//           Snackbar.make(findViewById(R.id.container), R.string.empty_task_message, Snackbar.LENGTH_SHORT).show();
//           break;
//         case UPDATING_TASK:
//           // TODO: should handle progressbar
//           break;
//         case UPDATED_TASK:
//           finish();
//           break;
//       }
//     }), UnsubscribeLifeCycle.DESTROY_VIEW);
//   }
// }


import me.henrytao.mvvmlifecycledemo.ui.taskaddedit.TaskAddEditActivity;
import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
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.TaskDetailActivityBinding;
import me.henrytao.mvvmlifecycledemo.ui.base.BaseActivity;
import me.henrytao.mvvmlifecycledemo.ui.base.Constants;
/*
 * Copyright 2016 "Henry Tao <hi@henrytao.me>"
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.henrytao.mvvmlifecycledemo.ui.taskdetail;



/**
 * Created by henrytao on 4/2/16.
 */
public class TaskDetailActivity extends BaseActivity {

  public static Intent newIntent(Context context, String taskId) {
    Intent intent = new Intent(context, TaskDetailActivity.class);
    Bundle bundle = new Bundle();
    bundle.putString(Constants.Extra.ID, taskId);
    intent.putExtras(bundle);
    return intent;
  }

  private TaskDetailActivityBinding mBinding;

  private TaskDetailViewModel mViewModel;

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_task_detail, menu);
    ResourceUtils.supportDrawableTint(this, menu, ResourceUtils.Palette.PRIMARY);
    return super.onCreateOptionsMenu(menu);
  }

  @Override
  public void onInitializeViewModels() {
    Bundle bundle = getIntent().getExtras();
// 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
// public class TaskAddEditActivity extends BaseActivity {
// 
//   public static Intent newIntent(Context context) {
//     return newIntent(context, null);
//   }
// 
//   public static Intent newIntent(Context context, String taskId) {
//     Intent intent = new Intent(context, TaskAddEditActivity.class);
//     Bundle bundle = new Bundle();
//     bundle.putString(Constants.Extra.ID, taskId);
//     intent.putExtras(bundle);
//     return intent;
//   }
// 
//   private TaskAddEditActivityBinding mBinding;
// 
//   private TaskAddEditViewModel mViewModel;
// 
//   @Override
//   public boolean onCreateOptionsMenu(Menu menu) {
//     getMenuInflater().inflate(R.menu.menu_task_add_edit, menu);
//     ResourceUtils.supportDrawableTint(this, menu, ResourceUtils.Palette.PRIMARY);
//     return super.onCreateOptionsMenu(menu);
//   }
// 
//   @Override
//   public void onInitializeViewModels() {
//     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()) {
//         case CREATED_TASK:
//           finish();
//           break;
//         case CREATING_TASK:
//           // TODO: should handle progressbar
//           break;
//         case MISSING_TITLE:
//           Snackbar.make(findViewById(R.id.container), R.string.empty_task_message, Snackbar.LENGTH_SHORT).show();
//           break;
//         case UPDATING_TASK:
//           // TODO: should handle progressbar
//           break;
//         case UPDATED_TASK:
//           finish();
//           break;
//       }
//     }), UnsubscribeLifeCycle.DESTROY_VIEW);
//   }
// }


// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/ui/taskdetail/TaskDetailActivity.java
import me.henrytao.mvvmlifecycledemo.ui.taskaddedit.TaskAddEditActivity;
import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
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.TaskDetailActivityBinding;
import me.henrytao.mvvmlifecycledemo.ui.base.BaseActivity;
import me.henrytao.mvvmlifecycledemo.ui.base.Constants;

/*
 * Copyright 2016 "Henry Tao <hi@henrytao.me>"
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.henrytao.mvvmlifecycledemo.ui.taskdetail;



/**
 * Created by henrytao on 4/2/16.
 */
public class TaskDetailActivity extends BaseActivity {

  public static Intent newIntent(Context context, String taskId) {
    Intent intent = new Intent(context, TaskDetailActivity.class);
    Bundle bundle = new Bundle();
    bundle.putString(Constants.Extra.ID, taskId);
    intent.putExtras(bundle);
    return intent;
  }

  private TaskDetailActivityBinding mBinding;

  private TaskDetailViewModel mViewModel;

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_task_detail, menu);
    ResourceUtils.supportDrawableTint(this, menu, ResourceUtils.Palette.PRIMARY);
    return super.onCreateOptionsMenu(menu);
  }

  @Override
  public void onInitializeViewModels() {
    Bundle bundle = getIntent().getExtras();
    String taskId = bundle.getString(Constants.Extra.ID);