Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ public ProcessResult process(AnnotationElements validatedModel) throws Exception
for (DecoratingElementProcessor processor : enclosedProcessors) {
Class<? extends Annotation> target = processor.getTarget();

/*
* For ancestors, the processor manipulates the annotated elements,
* but uses the holder for the root element
*/
Set<AnnotatedAndRootElements> ancestorAnnotatedElements = validatedModel.getAncestorAnnotatedElements(target.getName());
for (AnnotatedAndRootElements elements : ancestorAnnotatedElements) {
EBeanHolder holder = eBeansHolder.getEBeanHolder(elements.rootTypeElement);
/*
* Annotations coming from ancestors may be applied to root
* elements that are not validated, and therefore not available.
*/
if (holder != null) {
processor.process(elements.annotatedElement, codeModel, holder);
}
}

Set<? extends Element> rootAnnotatedElements = validatedModel.getRootAnnotatedElements(target.getName());

for (Element annotatedElement : rootAnnotatedElements) {
Expand All @@ -109,21 +125,6 @@ public ProcessResult process(AnnotationElements validatedModel) throws Exception
}
}

/*
* For ancestors, the processor manipulates the annotated elements,
* but uses the holder for the root element
*/
Set<AnnotatedAndRootElements> ancestorAnnotatedElements = validatedModel.getAncestorAnnotatedElements(target.getName());
for (AnnotatedAndRootElements elements : ancestorAnnotatedElements) {
EBeanHolder holder = eBeansHolder.getEBeanHolder(elements.rootTypeElement);
/*
* Annotations coming from ancestors may be applied to root
* elements that are not validated, and therefore not available.
*/
if (holder != null) {
processor.process(elements.annotatedElement, codeModel, holder);
}
}
}

return new ProcessResult(//
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.androidannotations.test15.inheritance;

import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;

import org.androidannotations.test15.AndroidAnnotationsTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

import android.app.Activity;
import android.content.Context;

@RunWith(AndroidAnnotationsTestRunner.class)
public class InheritanceTest {

@Test
public void after_inject_mother_calls_first() {
Child child = Child_.getInstance_(mock(Context.class));
assertThat(child.motherInitWasCalled).isTrue();
}

@Test
public void after_views_mother_calls_first() {
Child_ child = Child_.getInstance_(mock(Activity.class));
child.afterSetContentView_();
assertThat(child.motherInitViewsWasCalled).isTrue();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.androidannotations.test15.inheritance;

import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EBean;

@EBean
public class Child extends Mother {

public boolean motherInitWasCalled;
public boolean motherInitViewsWasCalled;

@AfterInject
void initChild() {
motherInitWasCalled = motherInitCalled;
}

@AfterViews
void initViewsChild() {
motherInitViewsWasCalled = motherInitViewsCalled;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.androidannotations.test15.inheritance;

import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EBean;

@EBean
public abstract class Mother {

protected boolean motherInitCalled = false;
protected boolean motherInitViewsCalled = false;

@AfterInject
void initMother() {
motherInitCalled = true;
}

@AfterViews
void initViewsMother() {
motherInitViewsCalled = true;
}

}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.