From 4b9265c8255ef7938e47ea8082a8d0714b877c46 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Sun, 29 Nov 2015 22:54:09 +0900 Subject: [PATCH 1/4] Move todos-with-dagger to examples/ --- .../todos-with-dagger}/.gitignore | 0 .../todos-with-dagger}/build.gradle | 0 .../todos-with-dagger}/proguard-rules.pro | 0 .../example/todoswithdagger/ApplicationTest.java | 0 .../todos-with-dagger}/src/main/AndroidManifest.xml | 0 .../droidux/example/todoswithdagger/App.java | 0 .../example/todoswithdagger/AppComponent.java | 0 .../droidux/example/todoswithdagger/AppModule.java | 0 .../droidux/example/todoswithdagger/RootStore.java | 0 .../todoswithdagger/action/AddTodoAction.java | 0 .../action/ClearCompletedTodoAction.java | 0 .../todoswithdagger/action/DeleteTodoAction.java | 0 .../action/ToggleCompletedTodoAction.java | 0 .../todoswithdagger/adapter/TodoListAdapter.java | 0 .../example/todoswithdagger/entity/TodoList.java | 0 .../todoswithdagger/module/main/MainActivity.java | 0 .../module/main/MainActivityComponent.java | 0 .../module/main/MainActivityHelper.java | 0 .../module/main/MainActivityModule.java | 0 .../todoswithdagger/reducer/TodoListReducer.java | 0 .../src/main/res/layout/activity_main.xml | 0 .../src/main/res/layout/list_item_todo.xml | 0 .../src/main/res/menu/main_manu.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/colors.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../example/todoswithdagger/ExampleUnitTest.java | 0 settings.gradle | 3 ++- 35 files changed, 2 insertions(+), 1 deletion(-) rename {todos-with-dagger => examples/todos-with-dagger}/.gitignore (100%) rename {todos-with-dagger => examples/todos-with-dagger}/build.gradle (100%) rename {todos-with-dagger => examples/todos-with-dagger}/proguard-rules.pro (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/androidTest/java/info/izumin/android/droidux/example/todoswithdagger/ApplicationTest.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/AndroidManifest.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/App.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppComponent.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppModule.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/RootStore.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/AddTodoAction.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ClearCompletedTodoAction.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/DeleteTodoAction.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ToggleCompletedTodoAction.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/adapter/TodoListAdapter.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/entity/TodoList.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivity.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityComponent.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityHelper.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityModule.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/java/info/izumin/android/droidux/example/todoswithdagger/reducer/TodoListReducer.java (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/layout/activity_main.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/layout/list_item_todo.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/menu/main_manu.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/values-w820dp/dimens.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/values/colors.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/values/dimens.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/values/strings.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/main/res/values/styles.xml (100%) rename {todos-with-dagger => examples/todos-with-dagger}/src/test/java/info/izumin/android/droidux/example/todoswithdagger/ExampleUnitTest.java (100%) diff --git a/todos-with-dagger/.gitignore b/examples/todos-with-dagger/.gitignore similarity index 100% rename from todos-with-dagger/.gitignore rename to examples/todos-with-dagger/.gitignore diff --git a/todos-with-dagger/build.gradle b/examples/todos-with-dagger/build.gradle similarity index 100% rename from todos-with-dagger/build.gradle rename to examples/todos-with-dagger/build.gradle diff --git a/todos-with-dagger/proguard-rules.pro b/examples/todos-with-dagger/proguard-rules.pro similarity index 100% rename from todos-with-dagger/proguard-rules.pro rename to examples/todos-with-dagger/proguard-rules.pro diff --git a/todos-with-dagger/src/androidTest/java/info/izumin/android/droidux/example/todoswithdagger/ApplicationTest.java b/examples/todos-with-dagger/src/androidTest/java/info/izumin/android/droidux/example/todoswithdagger/ApplicationTest.java similarity index 100% rename from todos-with-dagger/src/androidTest/java/info/izumin/android/droidux/example/todoswithdagger/ApplicationTest.java rename to examples/todos-with-dagger/src/androidTest/java/info/izumin/android/droidux/example/todoswithdagger/ApplicationTest.java diff --git a/todos-with-dagger/src/main/AndroidManifest.xml b/examples/todos-with-dagger/src/main/AndroidManifest.xml similarity index 100% rename from todos-with-dagger/src/main/AndroidManifest.xml rename to examples/todos-with-dagger/src/main/AndroidManifest.xml diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/App.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/App.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/App.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/App.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppComponent.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppComponent.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppComponent.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppComponent.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppModule.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppModule.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppModule.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/AppModule.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/RootStore.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/RootStore.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/RootStore.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/RootStore.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/AddTodoAction.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/AddTodoAction.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/AddTodoAction.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/AddTodoAction.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ClearCompletedTodoAction.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ClearCompletedTodoAction.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ClearCompletedTodoAction.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ClearCompletedTodoAction.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/DeleteTodoAction.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/DeleteTodoAction.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/DeleteTodoAction.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/DeleteTodoAction.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ToggleCompletedTodoAction.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ToggleCompletedTodoAction.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ToggleCompletedTodoAction.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/action/ToggleCompletedTodoAction.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/adapter/TodoListAdapter.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/adapter/TodoListAdapter.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/adapter/TodoListAdapter.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/adapter/TodoListAdapter.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/entity/TodoList.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/entity/TodoList.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/entity/TodoList.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/entity/TodoList.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivity.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivity.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivity.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivity.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityComponent.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityComponent.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityComponent.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityComponent.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityHelper.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityHelper.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityHelper.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityHelper.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityModule.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityModule.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityModule.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/module/main/MainActivityModule.java diff --git a/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/reducer/TodoListReducer.java b/examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/reducer/TodoListReducer.java similarity index 100% rename from todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/reducer/TodoListReducer.java rename to examples/todos-with-dagger/src/main/java/info/izumin/android/droidux/example/todoswithdagger/reducer/TodoListReducer.java diff --git a/todos-with-dagger/src/main/res/layout/activity_main.xml b/examples/todos-with-dagger/src/main/res/layout/activity_main.xml similarity index 100% rename from todos-with-dagger/src/main/res/layout/activity_main.xml rename to examples/todos-with-dagger/src/main/res/layout/activity_main.xml diff --git a/todos-with-dagger/src/main/res/layout/list_item_todo.xml b/examples/todos-with-dagger/src/main/res/layout/list_item_todo.xml similarity index 100% rename from todos-with-dagger/src/main/res/layout/list_item_todo.xml rename to examples/todos-with-dagger/src/main/res/layout/list_item_todo.xml diff --git a/todos-with-dagger/src/main/res/menu/main_manu.xml b/examples/todos-with-dagger/src/main/res/menu/main_manu.xml similarity index 100% rename from todos-with-dagger/src/main/res/menu/main_manu.xml rename to examples/todos-with-dagger/src/main/res/menu/main_manu.xml diff --git a/todos-with-dagger/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/todos-with-dagger/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from todos-with-dagger/src/main/res/mipmap-hdpi/ic_launcher.png rename to examples/todos-with-dagger/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/todos-with-dagger/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/todos-with-dagger/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from todos-with-dagger/src/main/res/mipmap-mdpi/ic_launcher.png rename to examples/todos-with-dagger/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/todos-with-dagger/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/todos-with-dagger/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from todos-with-dagger/src/main/res/mipmap-xhdpi/ic_launcher.png rename to examples/todos-with-dagger/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/todos-with-dagger/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/todos-with-dagger/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from todos-with-dagger/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to examples/todos-with-dagger/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/todos-with-dagger/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/todos-with-dagger/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from todos-with-dagger/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to examples/todos-with-dagger/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/todos-with-dagger/src/main/res/values-w820dp/dimens.xml b/examples/todos-with-dagger/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from todos-with-dagger/src/main/res/values-w820dp/dimens.xml rename to examples/todos-with-dagger/src/main/res/values-w820dp/dimens.xml diff --git a/todos-with-dagger/src/main/res/values/colors.xml b/examples/todos-with-dagger/src/main/res/values/colors.xml similarity index 100% rename from todos-with-dagger/src/main/res/values/colors.xml rename to examples/todos-with-dagger/src/main/res/values/colors.xml diff --git a/todos-with-dagger/src/main/res/values/dimens.xml b/examples/todos-with-dagger/src/main/res/values/dimens.xml similarity index 100% rename from todos-with-dagger/src/main/res/values/dimens.xml rename to examples/todos-with-dagger/src/main/res/values/dimens.xml diff --git a/todos-with-dagger/src/main/res/values/strings.xml b/examples/todos-with-dagger/src/main/res/values/strings.xml similarity index 100% rename from todos-with-dagger/src/main/res/values/strings.xml rename to examples/todos-with-dagger/src/main/res/values/strings.xml diff --git a/todos-with-dagger/src/main/res/values/styles.xml b/examples/todos-with-dagger/src/main/res/values/styles.xml similarity index 100% rename from todos-with-dagger/src/main/res/values/styles.xml rename to examples/todos-with-dagger/src/main/res/values/styles.xml diff --git a/todos-with-dagger/src/test/java/info/izumin/android/droidux/example/todoswithdagger/ExampleUnitTest.java b/examples/todos-with-dagger/src/test/java/info/izumin/android/droidux/example/todoswithdagger/ExampleUnitTest.java similarity index 100% rename from todos-with-dagger/src/test/java/info/izumin/android/droidux/example/todoswithdagger/ExampleUnitTest.java rename to examples/todos-with-dagger/src/test/java/info/izumin/android/droidux/example/todoswithdagger/ExampleUnitTest.java diff --git a/settings.gradle b/settings.gradle index 4f76d70..8c91e41 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ -include ':droidux', ':droidux-processor', ':middlewares:droidux-thunk', ':examples:todomvc', ':examples:todos-with-undo', ':todos-with-dagger' +include ':droidux', ':droidux-processor', ':middlewares:droidux-thunk' +include ':examples:todomvc', ':examples:todos-with-undo', ':examples:todos-with-dagger' From daf94fc1cb09bba79c85daa6fd39936036c92332 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Sun, 29 Nov 2015 22:58:41 +0900 Subject: [PATCH 2/4] Refactor upload task --- build.gradle | 3 +++ droidux-processor/build.gradle | 6 +++--- droidux/build.gradle | 6 +++--- middlewares/droidux-thunk/build.gradle | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index b85a555..f4f1558 100644 --- a/build.gradle +++ b/build.gradle @@ -35,4 +35,7 @@ ext { def versionBuild = 0 VERSION = "${versionMajor}.${versionMinor}.${versionPatch}" + USER_ORG = 'izumin5210' + GROUP_ID = 'info.izumin.android' + WEBSITE = 'https://github.com/izumin5210/Droidux' } \ No newline at end of file diff --git a/droidux-processor/build.gradle b/droidux-processor/build.gradle index 580ec40..b1b2af5 100644 --- a/droidux-processor/build.gradle +++ b/droidux-processor/build.gradle @@ -31,11 +31,11 @@ dependencies { } publish { - userOrg = 'izumin5210' - groupId = 'info.izumin.android' + userOrg = USER_ORG + groupId = GROUP_ID artifactId = 'droidux-processor' version = VERSION description = 'Code generator for info.izumin.android.droidux' - website = 'https://github.com/izumin5210/Droidux' + website = WEBSITE } diff --git a/droidux/build.gradle b/droidux/build.gradle index de4a2ab..849068c 100644 --- a/droidux/build.gradle +++ b/droidux/build.gradle @@ -37,10 +37,10 @@ dependencies { } publish { - userOrg = 'izumin5210' - groupId = 'info.izumin.android' + userOrg = USER_ORG + groupId = GROUP_ID artifactId = 'droidux' version = VERSION description = '"Predictable state container" implementation, inspired by Redux for JS.' - website = 'https://github.com/izumin5210/Droidux' + website = WEBSITE } diff --git a/middlewares/droidux-thunk/build.gradle b/middlewares/droidux-thunk/build.gradle index 3b9176a..d1be6ab 100644 --- a/middlewares/droidux-thunk/build.gradle +++ b/middlewares/droidux-thunk/build.gradle @@ -29,10 +29,10 @@ dependencies { } publish { - userOrg = 'izumin5210' - groupId = 'info.izumin.android' + userOrg = USER_ORG + groupId = GROUP_ID artifactId = 'droidux-thunk' version = '0.1.0' description = 'Thunk middleware for Droidux.' - website = 'https://github.com/izumin5210/Droidux' + website = WEBSITE } From a849e7551a23b5b3f9e132cb5837f89cdc725896 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Sun, 29 Nov 2015 23:23:38 +0900 Subject: [PATCH 3/4] Update README --- README.md | 145 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 99 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index d84925a..89b1671 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Features of Droidux are following: see also: [Introduction to Redux // Speaker Deck](https://speakerdeck.com/axross/introduction-to-redux) (in Japanese) ## Installation +Droidux depends on [RxJava][rxjava] and [Data Binding][databinding]. Add to your project build.gradle file: ```groovy @@ -41,13 +42,19 @@ apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' dependencies { - compile 'info.izumin.android:droidux:0.3.0' - apt 'info.izumin.android:droidux:0.3.0' + compile 'io.reactivex:rxjava:1.0.16' + compile 'info.izumin.android:droidux:0.4.0' + apt 'info.izumin.android:droidux:0.4.0' } ``` And also you need to setup [Data Binding][databinding]. +When you use `AsyncAction`, you need to add [droidux-thunk](https://github.com/izumin5210/Droidux/tree/master/middlewares/droidux-thunk). + +```groovy +compile 'info.izumin.android:droidux-thunk:0.1.0' +``` ## Usage ### Quick example @@ -79,7 +86,7 @@ public class CounterReducer { /** * This is a method to handle actions. - * It should be applied @Dispatchable annotation is given an action class as ano argument. + * It should be applied @Dispatchable annotation is given an action class as an parameter. * It describe how to transform the state into the next state when dispatched actions. * It should return the next state instance, and it is preferred instantiate the new state. * @@ -87,27 +94,40 @@ public class CounterReducer { + and it returns new counter instance that state is incremented. */ @Dispatchable(IncrementCountAction.class) - public Counter increment(Counter state, IncrementCountAction action) { + public Counter increment(Counter state) { return new Counter(state.getCount() + 1); } @Dispatchable(DecrementCountAction.class) - public Counter decrement(Counter state, DecrementCountAction action) { + public Counter decrement(Counter state) { return new Counter(state.getCount() - 1); } @Dispatchable(ClearCountAction.class) - public Counter clear(Counter state, ClearCountAction action) { + public Counter clear() { return new Counter(0); } } + +/** + * This is a store interface. + * It should be applied @Store annotation and passing reducer classes as parameters. + * Droidux generates an implementation of getter method, observe method and dispatch method from user-defined interface. + */ +@Store(CounterReducer.class) +public interface CounterStore { + Counter counter(); + Observable observeCounter(); + Observable dispatch(Action action); +} + /** * They are action classes. They should extend Action class. */ -public class IncrementCountAction extends Action {} -public class DecrementCountAction extends Action {} -public class ClearCountAction extends Action {} +public class IncrementCountAction implements Action {} +public class DecrementCountAction implements Action {} +public class ClearCountAction implements Action {} // Instantiate a Droidux store holding the state of your app. @@ -118,9 +138,9 @@ public class ClearCountAction extends Action {} // // Its APIs in this example are following: // - rx.Observable dispatch(Action action) -// - rx.Observable observe() -// - Counter getState() -DroiduxCounterStore store = new DroiduxCounterStore.Builder() +// - rx.Observable observeCounter() +// - Counter counter() +CounterStore store = DroiduxCounterStore.builder() .setReducer(new CounterReducer()) .setInitialState(new Counter(0)) .build(); // Counter: 0 @@ -138,15 +158,20 @@ store.dispatch(new DecrementCountAction()).subscribe(); // Counter: 2 store.dispatch(new ClearCountAction()).subscribe(); // Counter: 0 ``` -### Combined reducer/store +### Combined store ```java -@CombinedReducer({CounterReducer.class, TodoListReducer.class}) -class RootReducer { +@Store({CounterReducer.class, TodoListReducer.class}) +class RootStore { + Counter counter(); + Observable observeCounter(); + TodoList todoList(); + Observable observeTodoList(); + Observable dispatch(Action action); } -DroiduxRootStore store = new DroiduxRootStore.Builder() +RootStore store = DroiduxRootStore.builder() .setReducer(new CounterReducer()) .setInitialState(new Counter(0)) .setReducer(new TodoListReducer()) @@ -161,27 +186,23 @@ store.dispatch(new AddTodoAction("new task")).subscribe(); // Counter: 1, Todo: ### Middleware ```java -class Logger extends Middleware { +class Logger extends Middleware { @Override public Observable beforeDispatch(Action action) { - Log.d("[prev counter]", String.valueOf(getCount())); + Log.d("[prev counter]", String.valueOf(getStore().count())); Log.d("[action]", action.getClass().getSimpleName()); return Observable.just(action); } @Override public Observable afterDispatch(Action action) { - Log.d("[next counter]", String.valueOf(getCount())); + Log.d("[next counter]", String.valueOf(getStore().count())); return Observable.just(action); } - - private int getCount() { - return ((DroiduxCounterStore) getStore()).getState().getCount(); - } } // Instantiate store class -DroiduxCounterStore store = new DroiduxCounterStore.Builder() +CounterStore store = DroiduxCounterStore.builder() .setReducer(new CounterReducer()) .setInitialState(new Counter(0)) .addMiddleware(new Logger()) // apply logger middleware @@ -209,41 +230,48 @@ store.dispatch(new ClearCountAction()).subscribe(); ### Undo / Redo ```java -@Undoable -@Reducer(TodoList.class) -class TodoListReducer { - @Dispatchable(AddTodoAction.class) - public TodoList addTodo(TodoList state, AddTodoAction action) { +class TodoList extends ArrayList implements UndoableState { + @Override + public TodoList clone() { // ... } - @Dispatchable(CompleteTodoAction.class) - public TodoList completeTodo(TodoList state, CompleteTodoAction action) { + public static Todo { // ... } } -class TodoList extends ArrayList implements UndoableStore { - @Override - public TodoList clone() { +@Undoable +@Reducer(TodoList.class) +class TodoListReducer { + @Dispatchable(AddTodoAction.class) + public TodoList add(TodoList state, AddTodoAction action) { // ... } - public static Todo { + @Dispatchable(CompleteTodoAction.class) + public TodoList complete(TodoList state, CompleteTodoAction action) { // ... } } -class AddTodoAction extends Action { +@Store(TodoListReducer.class) +public interface TodoListStore { + TodoList todoList(); + Observable observeTodoList(); + Observable dispatch(Action action); +} + +class AddTodoAction implements Action { // ... } -class CompleteTodoAction extends Action { +class CompleteTodoAction implements Action { // ... } -DroiduxTodoListStore store = new DroiduxTodoListStore.Builder() +TodoListStore store = DroiduxTodoListStore.builder() .setReducer(new TodoListReducer()) .setInitialState(new TodoList()) .build(); @@ -254,34 +282,58 @@ store.dispatch(new AddTodoAction("item 3")).subscribe(); // ["item 1", "i store.dispatch(new CompleteTodoAction("item 2")).subscribe(); // ["item 1", "item 3"] store.dispatch(new AddTodoAction("item 4")).subscribe(); // ["item 1", "item 3", "item 4"] -store.dispatch(new UndoAction(DroiduxTodoListStore.class)).subscribe(); +store.dispatch(new UndoAction(TodoList.class)).subscribe(); // => ["item 1", "item 3"] -store.dispatch(new UndoAction(DroiduxTodoListStore.class)).subscribe(); +store.dispatch(new UndoAction(TodoList.class)).subscribe(); // => ["item 1", "item 2", "item 3"] -store.dispatch(new RedoAction(DroiduxTodoListStore.class)).subscribe(); +store.dispatch(new RedoAction(TodoList.class)).subscribe(); // => ["item 1", "item 3"] ``` ### Async action +Use [droidux-thunk](https://github.com/izumin5210/Droidux/tree/master/middlewares/droidux-thunk). + ```java -class FetchTodoListAction extends Action { - public Observable fetch() { +class FetchTodoListAction implements AsyncAction { + private final TodoListApi client; + + public ReceiveTodoListAction(TodoListApi client) { + this.client = client; + } + + public Observable call() { return client.fetch() .map(todoList -> { this.todoList = todoList; - return this; + return new ReceiveTodoListAction(todoList); }); } - +} + +class ReceiveTodoListAction implements Action { + private final TodoList todoList; + + public ReceiveTodoListAction(TodoList todoList) { + this.todoList = todoList; + } + public TodoList getTodoList() { return todoList; } } -new FetchTodoAction().fetch().flatMap(store::dispatch).subscribe(); + +TodoListStore store = DroiduxTodoListStore.builder() + .setReducer(new TodoListReducer()) + .setInitialState(new TodoList()) + .addMiddleware(new ThunkMiddleware()) + .build(); + + +store.dispatch(new FetchTodoListAction(client)).subscribe(); ``` ### Bindable methods @@ -295,6 +347,7 @@ new FetchTodoAction().fetch().flatMap(store::dispatch).subscribe(); * [TodoMVC](https://github.com/izumin5210/Droidux/tree/master/examples/todomvc) * [Todos with Undo](https://github.com/izumin5210/Droidux/tree/master/examples/todos-with-undo) +* [Todos with Dagger 2](https://github.com/izumin5210/Droidux/tree/master/examples/todos-with-dagger) ## License From b7fe98c987621ff86dea3f01e6b6e3f52f69c02a Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Mon, 30 Nov 2015 00:01:43 +0900 Subject: [PATCH 4/4] v0.4.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f4f1558..745a1c2 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ task clean(type: Delete) { ext { def versionMajor = 0 - def versionMinor = 3 + def versionMinor = 4 def versionPatch = 0 def versionBuild = 0