From eeddf4e3f5873ca06b3abbff7b0d7bf8a6bf2fa4 Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Tue, 6 Dec 2016 17:35:56 +0700 Subject: [PATCH 1/6] [fixbug] Fixed bug of error dialog --- .../sample/github/ui/activities/SignInActivity.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java b/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java index d4165c59..0c214003 100644 --- a/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java +++ b/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java @@ -116,5 +116,15 @@ public void successSignIn() { startActivity(intent); } + + @Override + protected void onDestroy() { + super.onDestroy(); + + if (mErrorDialog != null) { + mErrorDialog.setOnCancelListener(null); + mErrorDialog.dismiss(); + } + } } From 4898071b877a6cb73c6154d8242ed786295a7757 Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Tue, 6 Dec 2016 17:38:24 +0700 Subject: [PATCH 2/6] [fixbug] Attach view to presenters at onResume() instead of onCreate() --- .../src/main/java/com/arellomobile/mvp/MvpActivity.java | 4 ++-- .../main/java/com/arellomobile/mvp/MvpAppCompatActivity.java | 4 ++-- .../main/java/android/support/v7/app/AppCompatActivity.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java b/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java index 82568024..9a4fc59a 100644 --- a/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java +++ b/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java @@ -37,8 +37,8 @@ protected void onSaveInstanceState(Bundle outState) { } @Override - protected void onStop() { - super.onStop(); + protected void onResume() { + super.onResume(); getMvpDelegate().onDetach(); } diff --git a/moxy-app-compat/src/main/java/com/arellomobile/mvp/MvpAppCompatActivity.java b/moxy-app-compat/src/main/java/com/arellomobile/mvp/MvpAppCompatActivity.java index 23a61b47..c9efd7d2 100644 --- a/moxy-app-compat/src/main/java/com/arellomobile/mvp/MvpAppCompatActivity.java +++ b/moxy-app-compat/src/main/java/com/arellomobile/mvp/MvpAppCompatActivity.java @@ -23,8 +23,8 @@ protected void onCreate(Bundle savedInstanceState) { } @Override - protected void onStart() { - super.onStart(); + protected void onResume() { + super.onResume(); getMvpDelegate().onAttach(); } diff --git a/moxy-app-compat/stub-appcompat/src/main/java/android/support/v7/app/AppCompatActivity.java b/moxy-app-compat/stub-appcompat/src/main/java/android/support/v7/app/AppCompatActivity.java index a50b80c9..4042450c 100644 --- a/moxy-app-compat/stub-appcompat/src/main/java/android/support/v7/app/AppCompatActivity.java +++ b/moxy-app-compat/stub-appcompat/src/main/java/android/support/v7/app/AppCompatActivity.java @@ -13,7 +13,7 @@ protected void onCreate(Bundle savedInstanceState) { throw new RuntimeException("Stub!"); } - protected void onStart() { + protected void onResume() { throw new RuntimeException("Stub!"); } From 0abbb2acbd64169550d41b48bb981cfb91f7a677 Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Tue, 6 Dec 2016 17:59:25 +0700 Subject: [PATCH 3/6] [fixbug] Fixed bug of error dialog visibility --- .../mvp/sample/github/ui/activities/SignInActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java b/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java index 0c214003..67b9e8dc 100644 --- a/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java +++ b/sample-github/src/main/java/com/arellomobile/mvp/sample/github/ui/activities/SignInActivity.java @@ -119,12 +119,12 @@ public void successSignIn() { @Override protected void onDestroy() { - super.onDestroy(); - if (mErrorDialog != null) { mErrorDialog.setOnCancelListener(null); mErrorDialog.dismiss(); } + + super.onDestroy(); } } From de2f271e6f3c61d1d70325caaa51b29c0c0ae7a0 Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Tue, 6 Dec 2016 18:01:21 +0700 Subject: [PATCH 4/6] [feature][issue-60] Fixed a potential NullPointerException --- .../mvp/compiler/ViewStateClassGenerator.java | 2 +- .../arellomobile/mvp/viewstate/MvpViewState.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/moxy-compiler/src/main/java/com/arellomobile/mvp/compiler/ViewStateClassGenerator.java b/moxy-compiler/src/main/java/com/arellomobile/mvp/compiler/ViewStateClassGenerator.java index cb918997..980bb61e 100644 --- a/moxy-compiler/src/main/java/com/arellomobile/mvp/compiler/ViewStateClassGenerator.java +++ b/moxy-compiler/src/main/java/com/arellomobile/mvp/compiler/ViewStateClassGenerator.java @@ -158,8 +158,8 @@ public boolean generate(TypeElement typeElement, List cla "\t\t}\n" + "\n" + "\t\tfor(" + mViewClassName + " view : mViews) {\n" + - "\t\t\tview." + method.name + "(" + argumentsString + ");\n" + "\t\t\tgetCurrentState(view).add(" + commandFieldName + ");\n" + + "\t\t\tview." + method.name + "(" + argumentsString + ");\n" + "\t\t}\n" + "\n" + "\t\tmViewCommands.afterApply(" + commandFieldName + ");\n" + diff --git a/moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java b/moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java index 33b07d4f..8ee5bff0 100644 --- a/moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java +++ b/moxy/src/main/java/com/arellomobile/mvp/viewstate/MvpViewState.java @@ -53,13 +53,7 @@ public void attachView(View view) { mInRestoreState.add(view); - Set> currentState = getCurrentState(view); - if (currentState == null) { - currentState = new HashSet<>(); - mViewStates.put(view, currentState); - } - - restoreState(view, currentState); + restoreState(view, getCurrentState(view)); mInRestoreState.remove(view); } @@ -85,7 +79,13 @@ public void destroyView(View view) { * @return commands that was applied already */ protected Set> getCurrentState(View view) { - return mViewStates.get(view); + Set> currentState = mViewStates.get(view); + if (currentState == null) { + currentState = new HashSet<>(); + mViewStates.put(view, currentState); + } + + return currentState; } /** From 17d5bd39fb0e34a021828857c5f9639845a49b85 Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Tue, 6 Dec 2016 18:16:12 +0700 Subject: [PATCH 5/6] [fixbug] Fixed wrong call of onAttach and onDetach within MvpActivity --- .../src/main/java/com/arellomobile/mvp/MvpActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java b/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java index 9a4fc59a..86368a70 100644 --- a/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java +++ b/moxy-android/src/main/java/com/arellomobile/mvp/MvpActivity.java @@ -22,8 +22,8 @@ protected void onCreate(Bundle savedInstanceState) { } @Override - protected void onStart() { - super.onStart(); + protected void onResume() { + super.onResume(); getMvpDelegate().onAttach(); } @@ -37,8 +37,8 @@ protected void onSaveInstanceState(Bundle outState) { } @Override - protected void onResume() { - super.onResume(); + protected void onStop() { + super.onStop(); getMvpDelegate().onDetach(); } From a57a61c0b83829234996042f3d3ed0d4eae552a8 Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Tue, 6 Dec 2016 18:25:45 +0700 Subject: [PATCH 6/6] [artifact] Prepare version 1.3.3 --- README.md | 12 ++++++------ build.gradle | 4 ++-- sample-github/build.gradle | 6 +++--- sample-kotlin/build.gradle | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 41e0c94f..a09f86c6 100644 --- a/README.md +++ b/README.md @@ -76,29 +76,29 @@ Base modules integration: ```groovy dependencies { ... - compile 'com.arello-mobile:moxy:1.3.2' - provided 'com.arello-mobile:moxy-compiler:1.3.2' + compile 'com.arello-mobile:moxy:1.3.3' + provided 'com.arello-mobile:moxy-compiler:1.3.3' } ``` If you want to see generated code, use `apt` instead of `provided` dependency type: ```groovy dependencies { ... - apt 'com.arello-mobile:moxy-compiler:1.3.2' + apt 'com.arello-mobile:moxy-compiler:1.3.3' } ``` For additional base view classes `MvpActivity` and `MvpFragment` add this: ```groovy dependencies { ... - compile 'com.arello-mobile:moxy-android:1.3.2' + compile 'com.arello-mobile:moxy-android:1.3.3' } ``` If you planing to use AppCompat, then you can use `MvpAppCompatActivity` and `MvpAppCompatFragment`. Then add this: ```groovy dependencies { ... - compile 'com.arello-mobile:moxy-app-compat:1.3.2' + compile 'com.arello-mobile:moxy-app-compat:1.3.3' compile 'com.android.support:appcompat-v7:$support_version' } ``` @@ -107,7 +107,7 @@ If you are using kotlin, use `kapt` instead of `provided`/`apt` dependency type ```groovy dependencies { ... - kapt 'com.arello-mobile:moxy-compiler:1.3.2' + kapt 'com.arello-mobile:moxy-compiler:1.3.3' } kapt { generateStubs = true diff --git a/build.gradle b/build.gradle index b6011d21..e680b15b 100644 --- a/build.gradle +++ b/build.gradle @@ -20,8 +20,8 @@ allprojects { } ext { - targetVersionCode = 31 - targetVersionName = "1.3.2" + targetVersionCode = 32 + targetVersionName = "1.3.3" } task clean(type: Delete) { diff --git a/sample-github/build.gradle b/sample-github/build.gradle index 3d2aba89..b322bd02 100644 --- a/sample-github/build.gradle +++ b/sample-github/build.gradle @@ -69,7 +69,7 @@ dependencies { testCompile "org.hamcrest:hamcrest-all:1.3" testCompile "org.robolectric:robolectric:3.1-rc1" - compile 'com.arello-mobile:moxy:1.3.2' - compile 'com.arello-mobile:moxy-app-compat:1.3.2' - apt 'com.arello-mobile:moxy-compiler:1.3.2' + compile 'com.arello-mobile:moxy:1.3.3' + compile 'com.arello-mobile:moxy-app-compat:1.3.3' + apt 'com.arello-mobile:moxy-compiler:1.3.3' } \ No newline at end of file diff --git a/sample-kotlin/build.gradle b/sample-kotlin/build.gradle index d676c4e8..f71af186 100644 --- a/sample-kotlin/build.gradle +++ b/sample-kotlin/build.gradle @@ -40,9 +40,9 @@ android { dependencies { compile 'com.android.support:appcompat-v7:25.0.0' - compile 'com.arello-mobile:moxy:1.3.2' - compile 'com.arello-mobile:moxy-app-compat:1.3.2' - kapt 'com.arello-mobile:moxy-compiler:1.3.2' + compile 'com.arello-mobile:moxy:1.3.3' + compile 'com.arello-mobile:moxy-app-compat:1.3.3' + kapt 'com.arello-mobile:moxy-compiler:1.3.3' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" }