When the class contains an instance of {@link EventBus} which is annotated with {@link EventBusGreenRobot}, we
* it will automatically be initialized with the default event bus: {@link EventBus#getDefault()}
*
@@ -96,7 +102,8 @@ public JBlock getInvocationBlock(EComponentHolder holder) {
}
@Override
- public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentHolder holder, Element element, Element param) {
+ public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentHolder holder, Element
+ element, Element param) {
// the InjectHelper will call this function
// * targetBlock is a block in the init-method (which is returned by @getInvocationBlock)
// * fieldRef is the field reference (this.bus) that is annotated with this EventBusGreenRobot annotation
@@ -104,10 +111,10 @@ public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, ECompon
initEventBusMember(targetBlock, fieldRef, param);
- if (holder instanceof HasLifecycleMethods) {
+ if (holder instanceof HasSimpleLifecycleMethods) {
if (hasSubscribeAnnotation(element)) {
// we need to register/unregister the event-bus
- handleEventBusRegistration(fieldRef, (HasLifecycleMethods) holder);
+ handleEventBusRegistration(fieldRef, (HasSimpleLifecycleMethods) holder);
}
}
}
@@ -119,10 +126,10 @@ public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, ECompon
* and is of type {@link org.greenrobot.eventbus.EventBus} with the
* default event-bus: {@link EventBus#getDefault()}
*
-
- * @param targetBlock the code block where the initialization code is added to
- * @param fieldRef the reference to the event-bus member variable.
- * @param param the annotated element
+ *
+ * @param targetBlock the code block where the initialization code is added to
+ * @param fieldRef the reference to the event-bus member variable.
+ * @param param the annotated element
*/
private void initEventBusMember(JBlock targetBlock, IJAssignmentTarget fieldRef, Element param) {
TypeMirror fieldType = param.asType();
@@ -144,7 +151,7 @@ private void initEventBusMember(JBlock targetBlock, IJAssignmentTarget fieldRef,
* then we must register/unregister the class with the EventBus
*
*
- * @param element the element to check for the @{@link Subscribe} annotation
+ * @param element the element to check for the @{@link Subscribe} annotation
* @return if we must register/unregister the EventBus
*/
private boolean hasSubscribeAnnotation(Element element) {
@@ -166,21 +173,25 @@ private boolean hasSubscribeAnnotation(Element element) {
/**
* adds register/unregister calls for the EventBus to the onStart/onStop methods
*
- * @param fieldRef is the field reference ({@code this.bus}) that is annotated the {@link EventBusGreenRobot} annotation
- * @param holderWithLifecycleMethods the component holder which implements {@link HasLifecycleMethods}
+ * @param fieldRef is the field reference ({@code this.bus}) that is annotated the
+ * {@link EventBusGreenRobot} annotation
+ * @param holderWithLifecycleMethods the component holder which implements {@link HasSimpleLifecycleMethods}
*/
private void handleEventBusRegistration(IJAssignmentTarget fieldRef
- , HasLifecycleMethods holderWithLifecycleMethods) {
+ , HasSimpleLifecycleMethods holderWithLifecycleMethods) {
JBlock onStartBlock;
JBlock onStopBlock;
- if (holderWithLifecycleMethods instanceof EServiceHolder) {
- onStartBlock = holderWithLifecycleMethods.getOnCreateAfterSuperBlock();
- onStopBlock = holderWithLifecycleMethods.getOnDestroyBeforeSuperBlock();
- } else {
- onStartBlock = holderWithLifecycleMethods.getOnStartAfterSuperBlock();
- onStopBlock = holderWithLifecycleMethods.getOnStopBeforeSuperBlock();
- }
+ onStartBlock = holderWithLifecycleMethods.getStartLifecycleAfterSuperBlock();
+ onStopBlock = holderWithLifecycleMethods.getEndLifecycleBeforeSuperBlock();
+
+// if (holderWithLifecycleMethods instanceof EServiceHolder) {
+// onStartBlock = holderWithLifecycleMethods.getOnCreateAfterSuperBlock();
+// onStopBlock = holderWithLifecycleMethods.getOnDestroyBeforeSuperBlock();
+// } else {
+// onStartBlock = holderWithLifecycleMethods.getOnStartAfterSuperBlock();
+// onStopBlock = holderWithLifecycleMethods.getOnStopBeforeSuperBlock();
+// }
onStartBlock.invoke(fieldRef, "register").arg(JExpr._this());
onStopBlock.invoke(fieldRef, "unregister").arg(JExpr._this());
}
diff --git a/pom.xml b/pom.xml
index cd984c8..6f24263 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
com.tmtrongreen-annotations-parent
- 1.0.2-SNAPSHOT
+ 1.0.2GreenRobot AndroidAnnotations parentAn AndroidAnnotations plugin to support GreenRobot
@@ -51,7 +51,7 @@
-->
1.7
- 4.1.0
+ 4.4.0
@@ -188,7 +188,7 @@
com.helgerjcodemodel
- 2.8.5
+ 3.0.1junit
@@ -263,7 +263,7 @@
4.4.1
- 17
+ 25true