From 5f80d44bd4795ffbd7605ae4b9d1f9cefe933be4 Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Fri, 14 Apr 2017 13:09:32 +0700 Subject: [PATCH 1/2] [fixbug] Save only part of save state which contains delegate's IDs --- .../com/arellomobile/mvp/MvpDelegate.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java b/moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java index 0253fba6..0ea6fe37 100644 --- a/moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java +++ b/moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java @@ -33,6 +33,7 @@ */ public class MvpDelegate { private static final String KEY_TAG = "com.arellomobile.mvp.MvpDelegate.KEY_TAG"; + public static final String MOXY_DELEGATE_TAGS_KEY = "MoxyDelegateBundle"; private String mKeyTag = KEY_TAG; private String mDelegateTag; @@ -42,12 +43,10 @@ public class MvpDelegate { private List> mPresenters; private List mChildDelegates; private Bundle mBundle; - private Bundle mChildKeyTagsBundle; public MvpDelegate(Delegated delegated) { mDelegated = delegated; mChildDelegates = new ArrayList<>(); - mChildKeyTagsBundle = new Bundle(); } public void setParentDelegate(MvpDelegate delegate, String childId) { @@ -55,7 +54,7 @@ public void setParentDelegate(MvpDelegate delegate, String childId) { throw new IllegalStateException("You should call setParentDelegate() before first onCreate()"); } if (mChildDelegates != null && mChildDelegates.size() > 0) { - throw new IllegalStateException("You could not set parent delegate when it already has child presenters"); + throw new IllegalStateException("You could not set parent delegate when there are already has child presenters"); } mParentDelegate = delegate; @@ -88,6 +87,10 @@ public void onCreate() { * @param bundle with saved state */ public void onCreate(Bundle bundle) { + if (mParentDelegate == null && bundle != null) { + bundle = bundle.getBundle(MOXY_DELEGATE_TAGS_KEY); + } + mIsAttached = false; mBundle = bundle != null ? bundle : new Bundle(); @@ -183,13 +186,11 @@ public void onDestroy() { */ public void onSaveInstanceState() { Bundle bundle = new Bundle(); - if (mParentDelegate != null) { - bundle = mParentDelegate.mChildKeyTagsBundle; + if (mParentDelegate != null && mParentDelegate.mBundle != null) { + bundle = mParentDelegate.mBundle; } onSaveInstanceState(bundle); - - mParentDelegate.mBundle.putAll(bundle); } /** @@ -198,8 +199,13 @@ public void onSaveInstanceState() { * @param outState out state from Android component */ public void onSaveInstanceState(Bundle outState) { + if (mParentDelegate == null) { + Bundle moxyDelegateBundle = new Bundle(); + outState.putBundle(MOXY_DELEGATE_TAGS_KEY, moxyDelegateBundle); + outState = moxyDelegateBundle; + } + outState.putAll(mBundle); - outState.putAll(mChildKeyTagsBundle); outState.putString(mKeyTag, mDelegateTag); for (MvpDelegate childDelegate : mChildDelegates) { From 438566c7a5f93724e05157f4ceff5a92d2badd7b Mon Sep 17 00:00:00 2001 From: Yuri Shmakov Date: Fri, 14 Apr 2017 13:56:11 +0700 Subject: [PATCH 2/2] [artifact] Prepare version 1.5.1 --- README.md | 10 +++++----- build.gradle | 4 ++-- sample-github/build.gradle | 6 +++--- sample-kotlin/build.gradle | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 25c0b8dd..feedf887 100644 --- a/README.md +++ b/README.md @@ -76,22 +76,22 @@ Base modules integration: ```groovy dependencies { ... - compile 'com.arello-mobile:moxy:1.5.0' - annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.0' + compile 'com.arello-mobile:moxy:1.5.1' + annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.1' } ``` For additional base view classes `MvpActivity` and `MvpFragment` add this: ```groovy dependencies { ... - compile 'com.arello-mobile:moxy-android:1.5.0' + compile 'com.arello-mobile:moxy-android:1.5.1' } ``` If you are planing to use AppCompat, then you can use `MvpAppCompatActivity` and `MvpAppCompatFragment`. Then add this: ```groovy dependencies { ... - compile 'com.arello-mobile:moxy-app-compat:1.5.0' + compile 'com.arello-mobile:moxy-app-compat:1.5.1' compile 'com.android.support:appcompat-v7:$support_version' } ``` @@ -100,7 +100,7 @@ If you are using kotlin, use `kapt` instead of `provided`/`apt` dependency type ```groovy dependencies { ... - kapt 'com.arello-mobile:moxy-compiler:1.5.0' + kapt 'com.arello-mobile:moxy-compiler:1.5.1' } kapt { generateStubs = true diff --git a/build.gradle b/build.gradle index 88233d0b..a5959b99 100644 --- a/build.gradle +++ b/build.gradle @@ -19,8 +19,8 @@ allprojects { } ext { - targetVersionCode = 40 - targetVersionName = "1.5.0" + targetVersionCode = 41 + targetVersionName = "1.5.1" } task clean(type: Delete) { diff --git a/sample-github/build.gradle b/sample-github/build.gradle index abc66036..d0ff6b96 100644 --- a/sample-github/build.gradle +++ b/sample-github/build.gradle @@ -68,7 +68,7 @@ dependencies { testCompile "org.hamcrest:hamcrest-all:1.3" testCompile "org.robolectric:robolectric:3.1-rc1" - compile 'com.arello-mobile:moxy:1.5.0' - compile 'com.arello-mobile:moxy-app-compat:1.5.0' - annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.0' + compile 'com.arello-mobile:moxy:1.5.1' + compile 'com.arello-mobile:moxy-app-compat:1.5.1' + annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.1' } \ No newline at end of file diff --git a/sample-kotlin/build.gradle b/sample-kotlin/build.gradle index 18c7a260..3a69fc72 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.5.0' - compile 'com.arello-mobile:moxy-app-compat:1.5.0' - kapt 'com.arello-mobile:moxy-compiler:1.5.0' + compile 'com.arello-mobile:moxy:1.5.1' + compile 'com.arello-mobile:moxy-app-compat:1.5.1' + kapt 'com.arello-mobile:moxy-compiler:1.5.1' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" }