// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/AddTodoAction.java
// public class AddTodoAction implements Action {
//     public static final String TAG = AddTodoAction.class.getSimpleName();
// 
//     private final String text;
// 
//     public AddTodoAction(String text) {
//         this.text = text;
//     }
// 
//     public String getText() {
//         return text;
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }
// 
// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/ClearCompletedTodoAction.java
// public class ClearCompletedTodoAction implements Action {
//     public static final String TAG = ClearCompletedTodoAction.class.getSimpleName();
// }
// 
// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/DeleteTodoAction.java
// public class DeleteTodoAction implements Action {
//     public static final String TAG = DeleteTodoAction.class.getSimpleName();
// 
//     private final long id;
// 
//     public DeleteTodoAction(long id) {
//         this.id = id;
//     }
// 
//     public long getId() {
//         return id;
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }
// 
// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/ToggleCompletedTodoAction.java
// public class ToggleCompletedTodoAction implements Action {
//     public static final String TAG = ToggleCompletedTodoAction.class.getSimpleName();
// 
//     private final int id;
// 
//     public ToggleCompletedTodoAction(int id) {
//         this.id = id;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }


import android.support.v7.app.AlertDialog;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import info.izumin.android.droidux.example.todomvc.action.AddTodoAction;
import info.izumin.android.droidux.example.todomvc.action.ClearCompletedTodoAction;
import info.izumin.android.droidux.example.todomvc.action.DeleteTodoAction;
import info.izumin.android.droidux.example.todomvc.action.ToggleCompletedTodoAction;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.SingleSubject;

        observeOnClickBtnAddTodo()
                .filter(s -> !s.isEmpty())
                .flatMap(s -> store.dispatch(new AddTodoAction(s)))
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(action -> {
                    editNewTodo.setText("");
                    Toast.makeText(activity, R.string.toast_add_todo, Toast.LENGTH_SHORT).show();
                });

        observeOnClickListItem()
                .flatMap(id -> store.dispatch(new ToggleCompletedTodoAction(id.intValue())))
                .subscribe();

        observeOnLongClickListItem()
                .flatMap(id -> store.dispatch(new DeleteTodoAction(id)))
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(action -> {
                    Toast.makeText(activity, R.string.toast_delete_todo, Toast.LENGTH_SHORT).show();
                });

        listTodo.setAdapter(new TodoListAdapter(activity));
    }

    public boolean onOptionItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_clear_completed_todo:
                store.dispatch(new ClearCompletedTodoAction()).subscribe();
                return true;
            default:
// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/AddTodoAction.java
// public class AddTodoAction implements Action {
//     public static final String TAG = AddTodoAction.class.getSimpleName();
// 
//     private final String text;
// 
//     public AddTodoAction(String text) {
//         this.text = text;
//     }
// 
//     public String getText() {
//         return text;
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }
// 
// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/ClearCompletedTodoAction.java
// public class ClearCompletedTodoAction implements Action {
//     public static final String TAG = ClearCompletedTodoAction.class.getSimpleName();
// }
// 
// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/DeleteTodoAction.java
// public class DeleteTodoAction implements Action {
//     public static final String TAG = DeleteTodoAction.class.getSimpleName();
// 
//     private final long id;
// 
//     public DeleteTodoAction(long id) {
//         this.id = id;
//     }
// 
//     public long getId() {
//         return id;
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }
// 
// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/action/ToggleCompletedTodoAction.java
// public class ToggleCompletedTodoAction implements Action {
//     public static final String TAG = ToggleCompletedTodoAction.class.getSimpleName();
// 
//     private final int id;
// 
//     public ToggleCompletedTodoAction(int id) {
//         this.id = id;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }


// Path: examples/todomvc/src/main/java/info/izumin/android/droidux/example/todomvc/MainActivityHelper.java
import android.support.v7.app.AlertDialog;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import info.izumin.android.droidux.example.todomvc.action.AddTodoAction;
import info.izumin.android.droidux.example.todomvc.action.ClearCompletedTodoAction;
import info.izumin.android.droidux.example.todomvc.action.DeleteTodoAction;
import info.izumin.android.droidux.example.todomvc.action.ToggleCompletedTodoAction;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.SingleSubject;


        observeOnClickBtnAddTodo()
                .filter(s -> !s.isEmpty())
                .flatMap(s -> store.dispatch(new AddTodoAction(s)))
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(action -> {
                    editNewTodo.setText("");
                    Toast.makeText(activity, R.string.toast_add_todo, Toast.LENGTH_SHORT).show();
                });

        observeOnClickListItem()
                .flatMap(id -> store.dispatch(new ToggleCompletedTodoAction(id.intValue())))
                .subscribe();

        observeOnLongClickListItem()
                .flatMap(id -> store.dispatch(new DeleteTodoAction(id)))
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(action -> {
                    Toast.makeText(activity, R.string.toast_delete_todo, Toast.LENGTH_SHORT).show();
                });

        listTodo.setAdapter(new TodoListAdapter(activity));
    }

    public boolean onOptionItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_clear_completed_todo:
                store.dispatch(new ClearCompletedTodoAction()).subscribe();
                return true;
            default:
                return false;