Skip to content

Commit

Permalink
Merge branch 'release/1.4.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
senneco committed Mar 9, 2017
2 parents 090bdcd + 23133fa commit cbf6b91
Show file tree
Hide file tree
Showing 25 changed files with 423 additions and 65 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
101 changes: 101 additions & 0 deletions moxy-android/src/main/java/com/arellomobile/mvp/MvpDialogFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.arellomobile.mvp;

import android.app.DialogFragment;
import android.app.Fragment;
import android.os.Build;
import android.os.Bundle;

/**
* Date: 17-Dec-16
* Time: 21:58
*
* @author Konstantin Tckhovrebov
*/
@SuppressWarnings("ConstantConditions")
public class MvpDialogFragment extends DialogFragment {

private boolean mIsStateSaved;
private MvpDelegate<? extends MvpDialogFragment> 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;

if (Build.VERSION.SDK_INT >= 17) {
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;
}
}
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
@@ -0,0 +1,11 @@
package android.app;

/**
* Date: 17-Dec-16
* Time: 21:58
*
* @author Konstantin Tckhovrebov
*/
public class DialogFragment extends Fragment {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.arellomobile.mvp;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatDialogFragment;

/**
* Date: 17-Dec-16
* Time: 21:55
*
* @author Konstantin Tckhovrebov
*/
@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();

//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
@@ -0,0 +1,11 @@
package android.support.v4.app;

/**
* Date: 17-Dec-16
* Time: 21:58
*
* @author Konstantin Tckhovrebov
*/
public class DialogFragment extends Fragment {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package android.support.v7.app;

import android.support.v4.app.DialogFragment;

/**
* Date: 17-Dec-16
* Time: 21:58
*
* @author Konstantin Tckhovrebov
*/
public class AppCompatDialogFragment extends DialogFragment {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.arellomobile.mvp.GenerateViewState;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class MvpCompiler extends AbstractProcessor {
private static Messager sMessager;
private static Types sTypeUtils;
private static Elements sElementUtils;
private static Map<String, String> sOptions;

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
Expand All @@ -52,6 +54,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
sMessager = processingEnv.getMessager();
sTypeUtils = processingEnv.getTypeUtils();
sElementUtils = processingEnv.getElementUtils();
sOptions = processingEnv.getOptions();
}

public static Messager getMessager() {
Expand Down
Loading

0 comments on commit cbf6b91

Please sign in to comment.