Skip to content

Commit

Permalink
Merge branch 'release/1.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
senneco committed Apr 14, 2017
2 parents 147fce0 + 438566c commit 7ddb348
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
```
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ allprojects {
}

ext {
targetVersionCode = 40
targetVersionName = "1.5.0"
targetVersionCode = 41
targetVersionName = "1.5.1"
}

task clean(type: Delete) {
Expand Down
22 changes: 14 additions & 8 deletions moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/
public class MvpDelegate<Delegated> {
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;
Expand All @@ -42,20 +43,18 @@ public class MvpDelegate<Delegated> {
private List<MvpPresenter<? super Delegated>> mPresenters;
private List<MvpDelegate> 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) {
if (mBundle != null) {
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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions sample-github/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
6 changes: 3 additions & 3 deletions sample-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 7ddb348

Please sign in to comment.