Skip to content

Commit

Permalink
Merge branch 'release/1.4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
senneco committed Dec 29, 2016
2 parents a7ffd49 + 852f30d commit b284f02
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 17 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.2'
provided 'com.arello-mobile:moxy-compiler:1.4.2'
compile 'com.arello-mobile:moxy:1.4.3'
provided 'com.arello-mobile:moxy-compiler:1.4.3'
}
```
If you want to see generated code, use `apt` instead of `provided` dependency type:
```groovy
dependencies {
...
apt 'com.arello-mobile:moxy-compiler:1.4.2'
apt 'com.arello-mobile:moxy-compiler:1.4.3'
}
```
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.2'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.3'
}
```
For additional base view classes `MvpActivity` and `MvpFragment` add this:
```groovy
dependencies {
...
compile 'com.arello-mobile:moxy-android:1.4.2'
compile 'com.arello-mobile:moxy-android:1.4.3'
}
```
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.2'
compile 'com.arello-mobile:moxy-app-compat:1.4.3'
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.2'
kapt 'com.arello-mobile:moxy-compiler:1.4.3'
}
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 = 35
targetVersionName = "1.4.2"
targetVersionCode = 36
targetVersionName = "1.4.3"
}

task clean(type: Delete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public SourceVersion getSupportedSourceVersion() {

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (annotations.isEmpty()) {
return false;
}

try {
return throwableProcess(roundEnv);
} catch (RuntimeException e) {
Expand All @@ -88,7 +92,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
getMessager().printMessage(Diagnostic.Kind.ERROR, "Moxy compilation failed; see the compiler error output for details (" + e + ")");
}

return false;
return true;
}

private boolean throwableProcess(RoundEnvironment roundEnv) {
Expand Down
8 changes: 7 additions & 1 deletion moxy/src/main/java/com/arellomobile/mvp/MvpProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ private <Delegated> MvpPresenter<? super Delegated> getMvpPresenter(Delegated ta
<Delegated> List<MvpPresenter<? super Delegated>> getMvpPresenters(Delegated delegated, String delegateTag) {
@SuppressWarnings("unchecked")
Class<? super Delegated> aClass = (Class<Delegated>) delegated.getClass();
List<Object> presenterBinders = MoxyReflector.getPresenterBinders(aClass);
List<Object> presenterBinders = null;

while (aClass != Object.class && presenterBinders == null) {
presenterBinders = MoxyReflector.getPresenterBinders(aClass);

aClass = aClass.getSuperclass();
}

if (presenterBinders == null || presenterBinders.isEmpty()) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.arellomobile.mvp.inheritance_test;

import android.os.Bundle;

import com.arellomobile.mvp.MvpDelegate;
import com.arellomobile.mvp.inheritance_test.resources.ChildViewWithoutInject;
import com.arellomobile.mvp.inheritance_test.resources.SuperViewWithInject;
import com.arellomobile.mvp.inheritance_test.resources.ViewWithoutInject;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

/**
* Date: 30.12.2016
* Time: 00:29
*
* @author Yuri Shmakov
*/
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class InheritanceTest {

@Test
public void testWithoutInject() {
ViewWithoutInject view = new ViewWithoutInject();

view.delegate = new MvpDelegate<>(view);

view.delegate.onCreate(new Bundle());
}

@Test
public void testInjectInInherited() {
SuperViewWithInject view = new SuperViewWithInject();

view.delegate = new MvpDelegate<>(view);

view.delegate.onCreate(new Bundle());

Assert.assertNotNull(view.presenter);
}

@Test
public void testInjectOnlyInSuper() {
ChildViewWithoutInject view = new ChildViewWithoutInject();

view.delegate = new MvpDelegate<>(view);

view.delegate.onCreate();

Assert.assertNotNull(view.presenter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.arellomobile.mvp.inheritance_test.resources;

/**
* Date: 30.12.2016
* Time: 00:13
*
* @author Yuri Shmakov
*/
public class ChildViewWithoutInject extends SuperViewWithInject implements TestView {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.arellomobile.mvp.inheritance_test.resources;

import com.arellomobile.mvp.presenter.InjectPresenter;

/**
* Date: 30.12.2016
* Time: 00:11
*
* @author Yuri Shmakov
*/
public class SuperViewWithInject extends ViewWithoutInject implements TestView {
@InjectPresenter
public TestPresenter presenter;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.arellomobile.mvp.inheritance_test.resources;

import com.arellomobile.mvp.MvpPresenter;

/**
* Date: 29.12.2016
* Time: 14:32
*
* @author Yuri Shmakov
*/
@SuppressWarnings("WeakerAccess")
public class TestPresenter extends MvpPresenter<TestView> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.arellomobile.mvp.inheritance_test.resources;

import com.arellomobile.mvp.MvpView;

/**
* Date: 29.12.2016
* Time: 14:31
*
* @author Yuri Shmakov
*/
public interface TestView extends MvpView {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.arellomobile.mvp.inheritance_test.resources;

import com.arellomobile.mvp.MvpDelegate;

/**
* Date: 30.12.2016
* Time: 00:09
*
* @author Yuri Shmakov
*/
public class ViewWithoutInject {
public MvpDelegate<? extends ViewWithoutInject> delegate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.arellomobile.mvp.memory_leak_test;

import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;

import android.os.Bundle;

import com.arellomobile.mvp.MvpDelegate;
import com.arellomobile.mvp.memory_leak_test.resources.TestViewImplementation;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;


import static org.junit.Assert.assertTrue;

/**
* Date: 29.12.2016
* Time: 14:29
*
* @author Yuri Shmakov
*/
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class MemoryLeakTest {
@Test
public void test() {
TestViewImplementation viewImplementation = new TestViewImplementation();

viewImplementation.delegate = new MvpDelegate<>(viewImplementation);

viewImplementation.delegate.onCreate(new Bundle());

viewImplementation.delegate.onDestroy();

WeakReference viewImplementationReference = new WeakReference(viewImplementation);
WeakReference presenterReference = new WeakReference(viewImplementation.presenter);

/**
* Remove local reference to this object. Test will been failed if reference to the implemented view or
* to presenter was being saved in Moxy
*/
//noinspection UnusedAssignment
viewImplementation = null;

long delay = 0;

while (delay < TimeUnit.SECONDS.toMillis(2)) {
System.gc();

if (viewImplementationReference.get() == null && presenterReference.get() == null) {
return;
}

try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
delay += 100;
}

assertTrue(false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.arellomobile.mvp.memory_leak_test.resources;

import com.arellomobile.mvp.MvpPresenter;

/**
* Date: 29.12.2016
* Time: 14:32
*
* @author Yuri Shmakov
*/
public class TestPresenter extends MvpPresenter<TestView> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.arellomobile.mvp.memory_leak_test.resources;

import com.arellomobile.mvp.MvpView;

/**
* Date: 29.12.2016
* Time: 14:31
*
* @author Yuri Shmakov
*/
public interface TestView extends MvpView {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.arellomobile.mvp.memory_leak_test.resources;

import com.arellomobile.mvp.MvpDelegate;
import com.arellomobile.mvp.presenter.InjectPresenter;

/**
* Date: 29.12.2016
* Time: 14:33
*
* @author Yuri Shmakov
*/

public class TestViewImplementation implements TestView {
@InjectPresenter
public TestPresenter presenter;

public MvpDelegate<TestViewImplementation> delegate;
}
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.2'
compile 'com.arello-mobile:moxy-app-compat:1.4.2'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.2'
compile 'com.arello-mobile:moxy:1.4.3'
compile 'com.arello-mobile:moxy-app-compat:1.4.3'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.3'
}
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.2'
compile 'com.arello-mobile:moxy-app-compat:1.4.2'
kapt 'com.arello-mobile:moxy-compiler:1.4.2'
compile 'com.arello-mobile:moxy:1.4.3'
compile 'com.arello-mobile:moxy-app-compat:1.4.3'
kapt 'com.arello-mobile:moxy-compiler:1.4.3'

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

0 comments on commit b284f02

Please sign in to comment.