Skip to content

Commit cda3782

Browse files
committed
Merge branch 'release/1.4.4'
2 parents b284f02 + d3590c2 commit cda3782

File tree

18 files changed

+337
-64
lines changed

18 files changed

+337
-64
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,36 @@ Base modules integration:
7676
```groovy
7777
dependencies {
7878
...
79-
compile 'com.arello-mobile:moxy:1.4.3'
80-
provided 'com.arello-mobile:moxy-compiler:1.4.3'
79+
compile 'com.arello-mobile:moxy:1.4.4'
80+
provided 'com.arello-mobile:moxy-compiler:1.4.4'
8181
}
8282
```
8383
If you want to see generated code, use `apt` instead of `provided` dependency type:
8484
```groovy
8585
dependencies {
8686
...
87-
apt 'com.arello-mobile:moxy-compiler:1.4.3'
87+
apt 'com.arello-mobile:moxy-compiler:1.4.4'
8888
}
8989
```
9090
Note: if you use gradle plugin verion 2.2.2 and above, so you can use `annotationProcessor` instead of `apt`:
9191
```groovy
9292
dependencies {
9393
...
94-
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.3'
94+
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.4'
9595
}
9696
```
9797
For additional base view classes `MvpActivity` and `MvpFragment` add this:
9898
```groovy
9999
dependencies {
100100
...
101-
compile 'com.arello-mobile:moxy-android:1.4.3'
101+
compile 'com.arello-mobile:moxy-android:1.4.4'
102102
}
103103
```
104104
If you are planing to use AppCompat, then you can use `MvpAppCompatActivity` and `MvpAppCompatFragment`. Then add this:
105105
```groovy
106106
dependencies {
107107
...
108-
compile 'com.arello-mobile:moxy-app-compat:1.4.3'
108+
compile 'com.arello-mobile:moxy-app-compat:1.4.4'
109109
compile 'com.android.support:appcompat-v7:$support_version'
110110
}
111111
```
@@ -114,7 +114,7 @@ If you are using kotlin, use `kapt` instead of `provided`/`apt` dependency type
114114
```groovy
115115
dependencies {
116116
...
117-
kapt 'com.arello-mobile:moxy-compiler:1.4.3'
117+
kapt 'com.arello-mobile:moxy-compiler:1.4.4'
118118
}
119119
kapt {
120120
generateStubs = true

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ allprojects {
1919
}
2020

2121
ext {
22-
targetVersionCode = 36
23-
targetVersionName = "1.4.3"
22+
targetVersionCode = 37
23+
targetVersionName = "1.4.4"
2424
}
2525

2626
task clean(type: Delete) {

moxy-android/build.gradle

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,11 @@ def getBasePom(String libName) {
111111
}
112112

113113
return basePom.withXml {
114-
asNode().dependencies.'*'.findAll() {
115-
it.version.text() == 'unspecified' && project.configurations.compile.allDependencies.find { dep ->
116-
dep.name == it.artifactId.text()
117-
}
118-
}.each() {
119-
it.scope*.value = 'compile'
120-
it.groupId*.value = 'com.arello-mobile'
121-
it.artifactId*.value = libName
122-
it.version*.value = '${project.version}'
114+
asNode().dependencies.'*'.findAll {
115+
it.artifactId.text().contains('moxy')
116+
}.each {
117+
it.groupId*.value = targetGroupId
118+
it.version*.value = targetVersionName
123119
}
124120
}
125121

moxy-app-compat/build.gradle

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,13 @@ def getBasePom(String libName) {
111111
}
112112

113113
return basePom.withXml {
114-
asNode().dependencies.'*'.findAll() {
115-
it.version.text() == 'unspecified' && project.configurations.compile.allDependencies.find { dep ->
116-
dep.name == it.artifactId.text()
117-
}
118-
}.each() {
119-
it.scope*.value = 'compile'
120-
it.groupId*.value = 'com.arello-mobile'
121-
it.artifactId*.value = libName
122-
it.version*.value = '${project.version}'
114+
asNode().dependencies.'*'.findAll {
115+
it.artifactId.text().contains('moxy')
116+
}.each {
117+
it.groupId*.value = targetGroupId
118+
it.version*.value = targetVersionName
123119
}
124120
}
125-
126-
127121
}
128122

129123
task copyJars << {

moxy-compiler/build.gradle

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,13 @@ def getBasePom(String libName) {
103103
}
104104

105105
return basePom.withXml {
106-
107-
asNode().dependencies.'*'.findAll() {
108-
it.version.text() == 'unspecified' && project.configurations.compile.allDependencies.find { dep ->
109-
dep.name == it.artifactId.text()
110-
}
111-
}.each() {
112-
it.scope*.value = 'compile'
113-
it.groupId*.value = 'com.arello-mobile'
114-
it.artifactId*.value = libName
115-
it.version*.value = '${project.version}'
106+
asNode().dependencies.'*'.findAll {
107+
it.artifactId.text().contains('moxy')
108+
}.each {
109+
it.groupId*.value = targetGroupId
110+
it.version*.value = targetVersionName
116111
}
117112
}
118-
119-
120113
}
121114

122115
task copyJars << {

moxy/build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,11 @@ def getBasePom() {
113113
}
114114

115115
return basePom.withXml {
116-
asNode().dependencies.'*'.findAll() {
117-
it.version.text() == '4.0.+' && project.configurations.compile.allDependencies.find { dep ->
118-
dep.name == it.artifactId.text()
119-
}
120-
}.each() {
121-
it.version*.value = '[4.0,)'
116+
asNode().dependencies.'*'.findAll {
117+
it.artifactId.text().contains('moxy')
118+
}.each {
119+
it.groupId*.value = targetGroupId
120+
it.version*.value = targetVersionName
122121
}
123122
}
124123
}

moxy/src/main/java/com/arellomobile/mvp/MvpProcessor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ public class MvpProcessor {
2121
public static final String VIEW_STATE_PROVIDER_SUFFIX = "$$ViewStateProvider";
2222

2323
/**
24-
* 1) Generates tag for identification MvpPresenter
25-
* <p>
26-
* 2) Checks if presenter with tag is already exist in {@link com.arellomobile.mvp.PresenterStore}, and returns it.
27-
* <p>
28-
* 3)If {@link com.arellomobile.mvp.PresenterStore} doesn't contain MvpPresenter with current tag, {@link PresenterField} will create it
24+
* <p>1) Generates tag for identification MvpPresenter</p>
25+
* <p>2) Checks if presenter with tag is already exist in {@link com.arellomobile.mvp.PresenterStore}, and returns it</p>
26+
* <p>3) If {@link com.arellomobile.mvp.PresenterStore} doesn't contain MvpPresenter with current tag, {@link PresenterField} will create it</p>
2927
*
3028
* @param <Delegated> type of delegated
3129
* @param target object that want injection
@@ -37,9 +35,12 @@ private <Delegated> MvpPresenter<? super Delegated> getMvpPresenter(Delegated ta
3735
PresenterStore presenterStore = MvpFacade.getInstance().getPresenterStore();
3836

3937
PresenterType type = presenterField.getPresenterType();
40-
//noinspection unchecked
41-
String tag = type == PresenterType.LOCAL ? delegateTag + "$" : "";
42-
tag += presenterField.getTag(target);
38+
String tag;
39+
if (type == PresenterType.LOCAL) {
40+
tag = delegateTag + "$" + presenterField.getTag(target);
41+
} else {
42+
tag = presenterField.getTag(target);
43+
}
4344

4445
//noinspection unchecked
4546
MvpPresenter<? super Delegated> presenter = presenterStore.get(type, tag, presenterClass);
@@ -64,9 +65,8 @@ private <Delegated> MvpPresenter<? super Delegated> getMvpPresenter(Delegated ta
6465

6566

6667
/**
67-
* Gets presenters {@link java.util.List} annotated with {@link com.arellomobile.mvp.presenter.InjectPresenter} for view.
68-
* <p>
69-
* See full info about getting presenter instance in {@link #getMvpPresenter}
68+
* <p>Gets presenters {@link java.util.List} annotated with {@link com.arellomobile.mvp.presenter.InjectPresenter} for view.</p>
69+
* <p>See full info about getting presenter instance in {@link #getMvpPresenter}</p>
7070
*
7171
* @param delegated class contains presenter
7272
* @param delegateTag unique tag generated by {@link MvpDelegate#generateTag()}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.arellomobile.mvp.provide_methods_test;
2+
3+
import android.os.Bundle;
4+
5+
import com.arellomobile.mvp.MvpDelegate;
6+
import com.arellomobile.mvp.provide_methods_test.resources.LocalProvidedView;
7+
import com.arellomobile.mvp.provide_methods_test.resources.TwoLocalProvidedView;
8+
import com.arellomobile.mvp.provide_methods_test.resources.TwoWeakWithSamePresenterIdView;
9+
import com.arellomobile.mvp.provide_methods_test.resources.WeakProvidedView;
10+
11+
import org.junit.Assert;
12+
import org.junit.Test;
13+
import org.junit.runner.RunWith;
14+
import org.robolectric.RobolectricTestRunner;
15+
import org.robolectric.annotation.Config;
16+
17+
/**
18+
* Date: 30.12.2016
19+
* Time: 11:18
20+
*
21+
* @author Yuri Shmakov
22+
*/
23+
@RunWith(RobolectricTestRunner.class)
24+
@Config(manifest = Config.NONE)
25+
public class ProvideMethodsTest {
26+
27+
@Test
28+
public void testLocalIsProvided() {
29+
LocalProvidedView view = new LocalProvidedView();
30+
31+
view.delegate = new MvpDelegate<>(view);
32+
view.delegate.onCreate(new Bundle());
33+
34+
Assert.assertNotNull(view.oneLocalPresenter);
35+
Assert.assertSame(view.oneLocalPresenter, view.oneLocalProvidedPresenter);
36+
}
37+
38+
@Test
39+
public void testTwoLocalUseDifferentProvided() {
40+
TwoLocalProvidedView view = new TwoLocalProvidedView();
41+
42+
view.delegate = new MvpDelegate<>(view);
43+
view.delegate.onCreate(new Bundle());
44+
45+
Assert.assertNotSame(view.oneLocalPresenter, view.secondLocalPresenter);
46+
}
47+
48+
@Test
49+
public void testWeakPresenterWithHardcodedTag() {
50+
WeakProvidedView view = new WeakProvidedView();
51+
52+
view.delegate = new MvpDelegate<>(view);
53+
view.delegate.onCreate(new Bundle());
54+
55+
Assert.assertNotNull(view.weakPresenter);
56+
Assert.assertSame(view.weakPresenter, view.weakProvidedPresenter);
57+
}
58+
59+
@Test
60+
public void testTwoWeakPresenterWithSamePresenterIdTest() {
61+
TwoWeakWithSamePresenterIdView view = new TwoWeakWithSamePresenterIdView();
62+
63+
view.delegate = new MvpDelegate<>(view);
64+
view.delegate.onCreate(new Bundle());
65+
66+
Assert.assertNotNull(view.oneWeakPresenter);
67+
Assert.assertNotNull(view.secondWeakPresenter);
68+
69+
Assert.assertSame(view.oneWeakPresenter, view.secondWeakPresenter);
70+
}
71+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.arellomobile.mvp.provide_methods_test.resources;
2+
3+
import com.arellomobile.mvp.MvpDelegate;
4+
import com.arellomobile.mvp.presenter.InjectPresenter;
5+
import com.arellomobile.mvp.presenter.ProvidePresenter;
6+
7+
/**
8+
* Date: 30.12.2016
9+
* Time: 12:05
10+
*
11+
* @author Yuri Shmakov
12+
*/
13+
14+
public class LocalProvidedView implements TestView {
15+
@InjectPresenter
16+
public TestPresenter oneLocalPresenter;
17+
public TestPresenter oneLocalProvidedPresenter;
18+
19+
public MvpDelegate<LocalProvidedView> delegate;
20+
21+
@ProvidePresenter
22+
TestPresenter provideLocalPresenter() {
23+
oneLocalProvidedPresenter = new TestPresenter();
24+
return oneLocalProvidedPresenter;
25+
}
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.arellomobile.mvp.provide_methods_test.resources;
2+
3+
import com.arellomobile.mvp.MvpDelegate;
4+
import com.arellomobile.mvp.presenter.InjectPresenter;
5+
import com.arellomobile.mvp.presenter.ProvidePresenter;
6+
7+
/**
8+
* Date: 30.12.2016
9+
* Time: 10:12
10+
*
11+
* @author Yuri Shmakov
12+
*/
13+
14+
public class SuperView implements TestView {
15+
@InjectPresenter
16+
public TestPresenter oneLocalPresenter;
17+
public TestPresenter oneLocalProvidedPresenter;
18+
19+
@InjectPresenter
20+
public TestPresenter secondLocalPresenter;
21+
22+
@InjectPresenter(presenterId = "one_global")
23+
public TestPresenter oneGlobalPresenter;
24+
25+
@InjectPresenter(presenterId = "second_global")
26+
public TestPresenter secondGlobalPresenter;
27+
28+
public MvpDelegate<SuperView> delegate;
29+
30+
@ProvidePresenter
31+
public TestPresenter provideLocalPresenter() {
32+
oneLocalProvidedPresenter = new TestPresenter();
33+
return oneLocalProvidedPresenter;
34+
}
35+
}

0 commit comments

Comments
 (0)