Skip to content

Commit

Permalink
Merge pull request #1 from Arello-Mobile/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AlexeyKorshun committed Mar 20, 2017
2 parents 7aac5bf + 7185980 commit 42f8518
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 92 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,36 @@ Base modules integration:
```groovy
dependencies {
...
compile 'com.arello-mobile:moxy:1.4.5'
provided 'com.arello-mobile:moxy-compiler:1.4.5'
compile 'com.arello-mobile:moxy:1.4.6'
provided 'com.arello-mobile:moxy-compiler:1.4.6'
}
```
If you want to see generated code, use `apt` instead of `provided` dependency type:
```groovy
dependencies {
...
apt 'com.arello-mobile:moxy-compiler:1.4.5'
apt 'com.arello-mobile:moxy-compiler:1.4.6'
}
```
Note: if you use gradle plugin verion 2.2.2 and above, so you can use `annotationProcessor` instead of `apt`:
```groovy
dependencies {
...
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.5'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.6'
}
```
For additional base view classes `MvpActivity` and `MvpFragment` add this:
```groovy
dependencies {
...
compile 'com.arello-mobile:moxy-android:1.4.5'
compile 'com.arello-mobile:moxy-android:1.4.6'
}
```
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.4.5'
compile 'com.arello-mobile:moxy-app-compat:1.4.6'
compile 'com.android.support:appcompat-v7:$support_version'
}
```
Expand All @@ -114,7 +114,7 @@ If you are using kotlin, use `kapt` instead of `provided`/`apt` dependency type
```groovy
dependencies {
...
kapt 'com.arello-mobile:moxy-compiler:1.4.5'
kapt 'com.arello-mobile:moxy-compiler:1.4.6'
}
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 = 38
targetVersionName = "1.4.5"
targetVersionCode = 39
targetVersionName = "1.4.6"
}

task clean(type: Delete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,20 @@ public void onDestroyView() {
public void onDestroy() {
super.onDestroy();

//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}

// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}

// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;

if (Build.VERSION.SDK_INT >= 17) {
Expand All @@ -74,7 +83,7 @@ public void onDestroy() {
}
}

if (isRemoving() || anyParentIsRemoving || getActivity().isFinishing()) {
if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}
Expand Down
12 changes: 10 additions & 2 deletions moxy-android/src/main/java/com/arellomobile/mvp/MvpFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Fragment;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

/**
* Date: 19-Dec-15
Expand Down Expand Up @@ -70,11 +69,20 @@ public void onDestroyView() {
public void onDestroy() {
super.onDestroy();

//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}

// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}

// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;

if (Build.VERSION.SDK_INT >= 17) {
Expand All @@ -85,7 +93,7 @@ public void onDestroy() {
}
}

if (isRemoving() || anyParentIsRemoving || getActivity().isFinishing()) {
if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,85 @@
@SuppressWarnings({"ConstantConditions", "unused"})
public class MvpAppCompatDialogFragment extends AppCompatDialogFragment {

private boolean mIsStateSaved;
private MvpDelegate<? extends MvpAppCompatDialogFragment> mMvpDelegate;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getMvpDelegate().onCreate(savedInstanceState);
}

public void onResume() {
super.onResume();

mIsStateSaved = false;

getMvpDelegate().onAttach();
}

public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

mIsStateSaved = true;

getMvpDelegate().onSaveInstanceState(outState);
getMvpDelegate().onDetach();
}

@Override
public void onStop() {
super.onStop();

getMvpDelegate().onDetach();
}

@Override
public void onDestroyView() {
super.onDestroyView();

getMvpDelegate().onDetach();
getMvpDelegate().onDestroyView();
}

@Override
public void onDestroy() {
super.onDestroy();

if (mIsStateSaved) {
mIsStateSaved = false;
return;
}

boolean anyParentIsRemoving = false;
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}

if (isRemoving() || anyParentIsRemoving || getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
}
}

/**
* @return The {@link MvpDelegate} being used by this Fragment.
*/
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
}

return mMvpDelegate;
}
private boolean mIsStateSaved;
private MvpDelegate<? extends MvpAppCompatDialogFragment> mMvpDelegate;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getMvpDelegate().onCreate(savedInstanceState);
}

public void onResume() {
super.onResume();

mIsStateSaved = false;

getMvpDelegate().onAttach();
}

public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

mIsStateSaved = true;

getMvpDelegate().onSaveInstanceState(outState);
getMvpDelegate().onDetach();
}

@Override
public void onStop() {
super.onStop();

getMvpDelegate().onDetach();
}

@Override
public void onDestroyView() {
super.onDestroyView();

getMvpDelegate().onDetach();
getMvpDelegate().onDestroyView();
}

@Override
public void onDestroy() {
super.onDestroy();

//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}

// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}

// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}

if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}

/**
* @return The {@link MvpDelegate} being used by this Fragment.
*/
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
}

return mMvpDelegate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,28 @@ public void onDestroyView() {
public void onDestroy() {
super.onDestroy();

//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}

// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}

// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}

if (isRemoving() || anyParentIsRemoving || getActivity().isFinishing()) {
if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ public static String fillGenerics(Map<String, String> types, List<? extends Type
result += "<" + s + ">";
}
} else if (param instanceof TypeVariable) {
result += types.get(param.toString());
String type = types.get(param.toString());
if (type == null) {
type = param.toString();
}
result += type;
} else {
result += param;
}
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.4.5'
compile 'com.arello-mobile:moxy-app-compat:1.4.5'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.5'
compile 'com.arello-mobile:moxy:1.4.6'
compile 'com.arello-mobile:moxy-app-compat:1.4.6'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.6'
}
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.4.5'
compile 'com.arello-mobile:moxy-app-compat:1.4.5'
kapt 'com.arello-mobile:moxy-compiler:1.4.5'
compile 'com.arello-mobile:moxy:1.4.6'
compile 'com.arello-mobile:moxy-app-compat:1.4.6'
kapt 'com.arello-mobile:moxy-compiler:1.4.6'

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

0 comments on commit 42f8518

Please sign in to comment.