Skip to content

Commit 37cca64

Browse files
author
roman_tcaregorodtcev
committed
Merge branch 'master' of https://github.com/Omega-R/OmegaMoxy into feature/bottom_dialog
2 parents c4b2134 + a010850 commit 37cca64

File tree

99 files changed

+339
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+339
-197
lines changed

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Moxy
2-
[![Maven Central](https://img.shields.io/maven-central/v/com.arello-mobile/moxy.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.arello-mobile%22%20AND%20(a%3A%22moxy%22%20OR%20a%3A%22moxy-compiler%22%20OR%20a%3A%22moxy-android%22%20OR%20a%3A%22moxy-app-compat%22)) [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)
2+
[![](https://jitpack.io/v/Omega-R/OmegaMoxy.svg)](https://jitpack.io/#Omega-R/OmegaMoxy)
3+
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)
34

45
Moxy is a library that helps to use MVP pattern when you do the Android Application. _Without problems of lifecycle and boilerplate code!_
56

@@ -72,27 +73,46 @@ Templates located in [/moxy-templates](https://github.com/Arello-Mobile/Moxy/tre
7273
[FAQ](https://github.com/Arello-Mobile/Moxy/wiki/FAQ)
7374

7475
## Integration
76+
77+
Add the JitPack repository to your build file:
78+
```groovy
79+
allprojects {
80+
repositories {
81+
...
82+
maven { url 'https://jitpack.io' }
83+
}
84+
}
85+
```
86+
7587
Base modules integration:
7688
```groovy
7789
dependencies {
7890
...
79-
compile 'com.arello-mobile:moxy:1.5.6'
80-
annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.6'
91+
implementation 'com.github.Omega-R.OmegaMoxy:moxy:1.5.7'
92+
annotationProcessor 'com.github.Omega-R.OmegaMoxy:moxy-compiler:1.5.7'
8193
}
8294
```
8395
For additional base view classes `MvpActivity` and `MvpFragment` add this:
8496
```groovy
8597
dependencies {
8698
...
87-
compile 'com.arello-mobile:moxy-android:1.5.6'
99+
implementation 'com.github.Omega-R.OmegaMoxy:moxy-android:1.5.7'
100+
}
101+
```
102+
103+
If you are planning to use AndroidX, then you can use `MvpAppCompatActivity` and `MvpAppCompatFragment`. Then add this:
104+
```groovy
105+
dependencies {
106+
...
107+
implementation 'com.github.Omega-R.OmegaMoxy:moxy-androidx:1.5.7'
88108
}
89109
```
90110
If you are planning to use AppCompat, then you can use `MvpAppCompatActivity` and `MvpAppCompatFragment`. Then add this:
91111
```groovy
92112
dependencies {
93113
...
94-
compile 'com.arello-mobile:moxy-app-compat:1.5.6'
95-
compile 'com.android.support:appcompat-v7:$support_version'
114+
implementation 'com.github.Omega-R.OmegaMoxy:moxy-app-compat:1.5.7'
115+
implementation 'com.android.support:appcompat-v7:$support_version'
96116
}
97117
```
98118
### Kotlin
@@ -102,7 +122,7 @@ apply plugin: 'kotlin-kapt'
102122
103123
dependencies {
104124
...
105-
kapt 'com.arello-mobile:moxy-compiler:1.5.6'
125+
kapt 'com.github.Omega-R.OmegaMoxy:moxy-compiler:1.5.7'
106126
}
107127
```
108128

build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ buildscript {
77
google()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.2.1'
10+
classpath 'com.android.tools.build:gradle:3.3.2'
11+
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1112
}
1213
}
1314

@@ -16,12 +17,14 @@ allprojects {
1617
jcenter()
1718
mavenCentral()
1819
google()
20+
maven { url 'https://jitpack.io' }
1921
}
2022
}
2123

2224
ext {
2325
targetVersionCode = 46
2426
targetVersionName = "1.5.6"
27+
kotlin_version = '1.3.21'
2528

2629
deps = [
2730
android : 'com.google.android:android:1.6_r2',
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Nov 24 23:06:24 NOVT 2018
1+
#Thu Mar 21 17:43:47 MSK 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

moxy-androidx-sapmle/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.10'
32
repositories {
43
google()
54
jcenter()
@@ -19,7 +18,7 @@ android {
1918
compileSdkVersion 28
2019

2120
defaultConfig {
22-
applicationId "com.arellomobile.mvp.sample.androidx"
21+
applicationId "com.omegar.mvp.sample.androidx"
2322
minSdkVersion 16
2423
targetSdkVersion 28
2524
versionCode 1
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.omegar.mvp;
2+
3+
import android.os.Build;
4+
import android.os.Bundle;
5+
6+
import androidx.appcompat.app.AppCompatDialogFragment;
7+
import androidx.fragment.app.Fragment;
8+
9+
public class MvpAppCompatDialogFragment extends AppCompatDialogFragment {
10+
11+
private boolean mIsStateSaved;
12+
private MvpDelegate<? extends MvpAppCompatDialogFragment> mMvpDelegate;
13+
14+
public void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
17+
getMvpDelegate().onCreate(savedInstanceState);
18+
}
19+
20+
public void onResume() {
21+
super.onResume();
22+
23+
mIsStateSaved = false;
24+
25+
getMvpDelegate().onAttach();
26+
}
27+
28+
public void onSaveInstanceState(Bundle outState) {
29+
super.onSaveInstanceState(outState);
30+
31+
mIsStateSaved = true;
32+
33+
getMvpDelegate().onSaveInstanceState(outState);
34+
getMvpDelegate().onDetach();
35+
}
36+
37+
@Override
38+
public void onStop() {
39+
super.onStop();
40+
41+
getMvpDelegate().onDetach();
42+
}
43+
44+
@Override
45+
public void onDestroyView() {
46+
super.onDestroyView();
47+
48+
getMvpDelegate().onDetach();
49+
getMvpDelegate().onDestroyView();
50+
}
51+
52+
@Override
53+
public void onDestroy() {
54+
super.onDestroy();
55+
56+
//We leave the screen and respectively all fragments will be destroyed
57+
if (getActivity().isFinishing()) {
58+
getMvpDelegate().onDestroy();
59+
return;
60+
}
61+
62+
// When we rotate device isRemoving() return true for fragment placed in backstack
63+
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
64+
if (mIsStateSaved) {
65+
mIsStateSaved = false;
66+
return;
67+
}
68+
69+
// See https://github.com/Arello-Mobile/Moxy/issues/24
70+
boolean anyParentIsRemoving = false;
71+
72+
if (Build.VERSION.SDK_INT >= 17) {
73+
Fragment parent = getParentFragment();
74+
while (!anyParentIsRemoving && parent != null) {
75+
anyParentIsRemoving = parent.isRemoving();
76+
parent = parent.getParentFragment();
77+
}
78+
}
79+
80+
if (isRemoving() || anyParentIsRemoving) {
81+
getMvpDelegate().onDestroy();
82+
}
83+
}
84+
85+
/**
86+
* @return The {@link MvpDelegate} being used by this Fragment.
87+
*/
88+
public MvpDelegate getMvpDelegate() {
89+
if (mMvpDelegate == null) {
90+
mMvpDelegate = new MvpDelegate<>(this);
91+
}
92+
93+
return mMvpDelegate;
94+
}
95+
}

moxy-androidx/stub-androidx/src/main/java/androidx/appcompat/app/AppCompatActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
import android.os.Bundle;
44

5+
import androidx.fragment.app.FragmentActivity;
6+
57
/**
68
* Date: 25-July-18
79
* Time: 2:51
810
*
911
* @author Vova Stelmashchuk
1012
*/
1113

12-
public class AppCompatActivity {
14+
public class AppCompatActivity extends FragmentActivity {
1315

1416
protected void onCreate(Bundle savedInstanceState) {
1517
throw new RuntimeException("Stub!");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package androidx.appcompat.app;
2+
3+
import androidx.fragment.app.DialogFragment;
4+
5+
/**
6+
* Date: 22-March-19
7+
* Time: 09:18
8+
*
9+
* @author R12rus
10+
*/
11+
public class AppCompatDialogFragment extends DialogFragment {
12+
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package androidx.fragment.app;
2+
3+
/**
4+
* Date: 22-March-19
5+
* Time: 08:58
6+
*
7+
* @author R12rus
8+
*/
9+
public class DialogFragment extends Fragment {
10+
11+
}

moxy-compiler/src/main/java/com/omegar/mvp/compiler/MvpCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
@SuppressWarnings("unused")
5050
@AutoService(Processor.class)
5151
public class MvpCompiler extends AbstractProcessor {
52-
public static final String MOXY_REFLECTOR_DEFAULT_PACKAGE = "com.arellomobile.mvp";
52+
public static final String MOXY_REFLECTOR_DEFAULT_PACKAGE = "com.omegar.mvp";
5353

5454
private static final String OPTION_MOXY_REFLECTOR_PACKAGE = "moxyReflectorPackage";
5555

moxy-compiler/src/test/resources/multimodules/app/MoxyReflector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.arellomobile.mvp;
1+
package com.omegar.mvp;
22

33
import com.omegar.mvp.ViewStateProvider;
44

0 commit comments

Comments
 (0)