diff --git a/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java
index 7aa056ee12..64a8d36754 100644
--- a/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java
+++ b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java
@@ -1,46 +1,46 @@
-/**
- * Copyright (C) 2010-2014 eBusiness Information, Excilys Group
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed To in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.androidannotations.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Use it on {@link EActivity} annotated classes to set a custom title layout.
- *
- * The annotation value is mandatory and should be one of R.layout.* fields.
- *
- *
- *
- * Example :
- *
- *
- * @CustomTitle(R.layout.activityTitleLayout)
- * @EActivity(R.layout.main)
- * public class MyActivity extends Activity {
- *
- * }
- *
- *
- *
- */
-@Retention(RetentionPolicy.CLASS)
-@Target(ElementType.TYPE)
-public @interface CustomTitle {
- int value();
-}
+/**
+ * Copyright (C) 2010-2014 eBusiness Information, Excilys Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed To in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.androidannotations.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Use it on {@link EActivity} annotated classes to set a custom title layout.
+ *
+ * The annotation value is mandatory and should be one of R.layout.* fields.
+ *
+ *
+ *
+ * Example :
+ *
+ *
+ * @CustomTitle(R.layout.activityTitleLayout)
+ * @EActivity(R.layout.main)
+ * public class MyActivity extends Activity {
+ *
+ * }
+ *
+ *
+ *
+ */
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.TYPE)
+public @interface CustomTitle {
+ int value();
+}
diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/handler/RoboGuiceHandler.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/handler/RoboGuiceHandler.java
index 9f03183978..9b0678e45d 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/handler/RoboGuiceHandler.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/handler/RoboGuiceHandler.java
@@ -39,6 +39,7 @@
import com.sun.codemodel.JBlock;
import com.sun.codemodel.JClass;
+import com.sun.codemodel.JExpr;
import com.sun.codemodel.JExpression;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JInvocation;
@@ -49,7 +50,7 @@
public class RoboGuiceHandler extends BaseAnnotationHandler {
- private APTCodeModelHelper codeModelHelper = new APTCodeModelHelper();
+ private APTCodeModelHelper codeModelHelper = new APTCodeModelHelper();
public RoboGuiceHandler(ProcessingEnvironment processingEnvironment) {
super(RoboGuice.class, processingEnvironment);
@@ -66,25 +67,25 @@ public void validate(Element element, AnnotationElements validatedElements, IsVa
public void process(Element element, EActivityHolder holder) {
RoboGuiceHolder roboGuiceHolder = holder.getRoboGuiceHolder();
- holder.getGeneratedClass()._implements(classes().INJECTOR_PROVIDER);
+ holder.getGeneratedClass()._implements(classes().ROBO_CONTEXT);
- JFieldVar scope = roboGuiceHolder.getScopeField();
+ JFieldVar scopedObjects = roboGuiceHolder.getScopedObjectsField();
JFieldVar eventManager = roboGuiceHolder.getEventManagerField();
- JMethod getInjector = roboGuiceHolder.getGetInjector();
+ roboGuiceHolder.getContentViewListenerField();
listenerFields(element, holder);
- beforeCreateMethod(holder, scope, eventManager, getInjector);
- afterSetContentView(holder, scope, eventManager);
- onRestartMethod(roboGuiceHolder, scope, eventManager);
- onStartMethod(roboGuiceHolder, scope, eventManager);
- onResumeMethod(roboGuiceHolder, scope, eventManager);
+ beforeCreateMethod(holder, scopedObjects, eventManager);
+ onRestartMethod(roboGuiceHolder, eventManager);
+ onStartMethod(roboGuiceHolder, eventManager);
+ onResumeMethod(roboGuiceHolder, eventManager);
onPauseMethod(roboGuiceHolder, eventManager);
- onNewIntentMethod(roboGuiceHolder, scope, eventManager);
- onStopMethod(roboGuiceHolder, scope, eventManager);
- onDestroyMethod(roboGuiceHolder, scope, eventManager);
+ onNewIntentMethod(roboGuiceHolder, eventManager);
+ onStopMethod(roboGuiceHolder, eventManager);
+ onDestroyMethod(roboGuiceHolder, eventManager);
onConfigurationChangedMethod(roboGuiceHolder, eventManager);
onContentChangedMethod(roboGuiceHolder, eventManager);
- onActivityResultMethod(roboGuiceHolder, scope, eventManager);
+ onActivityResultMethod(roboGuiceHolder, eventManager);
+ getScopedObjectMap(holder, scopedObjects);
}
private void listenerFields(Element element, EActivityHolder holder) {
@@ -130,39 +131,29 @@ private List extractListenerClasses(Element activityElement) {
return new ArrayList(0);
}
- private void beforeCreateMethod(EActivityHolder holder, JFieldVar scope, JFieldVar eventManager, JMethod getInjector) {
+ private void beforeCreateMethod(EActivityHolder holder, JFieldVar scopedObjects, JFieldVar eventManager) {
JBlock body = holder.getInitBody();
- JVar injector = body.decl(classes().INJECTOR, "injector_", invoke(getInjector));
- body.assign(scope, invoke(injector, "getInstance").arg(classes().CONTEXT_SCOPE.dotclass()));
- body.invoke(scope, "enter").arg(_this());
- body.invoke(injector, "injectMembers").arg(_this());
+ JClass keyWildCard = classes().KEY.narrow(codeModel().wildcard());
+ JClass scopedHashMap = classes().HASH_MAP.narrow(keyWildCard, classes().OBJECT);
+ body.assign(scopedObjects, JExpr._new(scopedHashMap));
+
+ JVar injector = body.decl(classes().ROBO_INJECTOR, "injector_", classes().ROBO_GUICE.staticInvoke("getInjector").arg(_this()));
body.assign(eventManager, invoke(injector, "getInstance").arg(classes().EVENT_MANAGER.dotclass()));
+ body.add(injector.invoke("injectMembersWithoutViews").arg(_this()));
fireEvent(eventManager, body, classes().ON_CREATE_EVENT, holder.getInitSavedInstanceParam());
}
- private void afterSetContentView(EActivityHolder holder, JFieldVar scope, JFieldVar eventManager) {
- JBlock onViewChanged = holder.getOnViewChangedBody();
- onViewChanged.invoke(scope, "injectViews");
- fireEvent(eventManager, onViewChanged, classes().ON_CONTENT_VIEW_AVAILABLE_EVENT);
- }
-
- private void onRestartMethod(RoboGuiceHolder holder, JFieldVar scope, JFieldVar eventManager) {
- JBlock onRestartBeforeSuperBlock = holder.getOnRestartBeforeSuperBlock();
- onRestartBeforeSuperBlock.invoke(scope, "enter").arg(_this());
+ private void onRestartMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
JBlock onRestartAfterSuperBlock = holder.getOnRestartAfterSuperBlock();
fireEvent(eventManager, onRestartAfterSuperBlock, classes().ON_RESTART_EVENT);
}
- private void onStartMethod(RoboGuiceHolder holder, JFieldVar scope, JFieldVar eventManager) {
- JBlock onStartBeforeSuperBlock = holder.getOnStartBeforeSuperBlock();
- onStartBeforeSuperBlock.invoke(scope, "enter").arg(_this());
+ private void onStartMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
JBlock onStartAfterSuperBlock = holder.getOnStartAfterSuperBlock();
fireEvent(eventManager, onStartAfterSuperBlock, classes().ON_START_EVENT);
}
- private void onResumeMethod(RoboGuiceHolder holder, JFieldVar scope, JFieldVar eventManager) {
- JBlock onResumeBeforeSuperBlock = holder.getOnResumeBeforeSuperBlock();
- onResumeBeforeSuperBlock.invoke(scope, "enter").arg(_this());
+ private void onResumeMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
JBlock onResumeAfterSuperBlock = holder.getOnResumeAfterSuperBlock();
fireEvent(eventManager, onResumeAfterSuperBlock, classes().ON_RESUME_EVENT);
}
@@ -172,42 +163,37 @@ private void onPauseMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
fireEvent(eventManager, onPauseAfterSuperBlock, classes().ON_PAUSE_EVENT);
}
- private void onNewIntentMethod(RoboGuiceHolder holder, JFieldVar scope, JFieldVar eventManager) {
+ private void onNewIntentMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
JBlock onNewIntentAfterSuperBlock = holder.getOnNewIntentAfterSuperBlock();
- onNewIntentAfterSuperBlock.invoke(scope, "enter").arg(_this());
fireEvent(eventManager, onNewIntentAfterSuperBlock, classes().ON_NEW_INTENT_EVENT);
}
- private void onStopMethod(RoboGuiceHolder holder, JFieldVar scope, JFieldVar eventManager) {
+ private void onStopMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
JBlock onStopBlock = new JBlock(false, false);
- onStopBlock.invoke(scope, "enter").arg(_this());
JTryBlock tryBlock = onStopBlock._try();
fireEvent(eventManager, tryBlock.body(), classes().ON_STOP_EVENT);
JBlock finallyBody = tryBlock._finally();
- finallyBody.invoke(scope, "exit").arg(_this());
finallyBody.invoke(_super(), "onStop");
- JMethod onStop = holder.getOnStop();
- codeModelHelper.replaceSuperCall(onStop, onStopBlock);
+ JMethod onStop = holder.getOnStop();
+ codeModelHelper.replaceSuperCall(onStop, onStopBlock);
}
- private void onDestroyMethod(RoboGuiceHolder holder, JFieldVar scope, JFieldVar eventManager) {
- JBlock onDestroyBlock = new JBlock(false, false);
- onDestroyBlock.invoke(scope, "enter").arg(_this());
+ private void onDestroyMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
+ JBlock onDestroyBlock = new JBlock(false, false);
JTryBlock tryBlock = onDestroyBlock._try();
fireEvent(eventManager, tryBlock.body(), classes().ON_DESTROY_EVENT);
JBlock finallyBody = tryBlock._finally();
- finallyBody.invoke(eventManager, "clear").arg(_this());
- finallyBody.invoke(scope, "exit").arg(_this());
- finallyBody.invoke(scope, "dispose").arg(_this());
- finallyBody.invoke(_super(), "onDestroy");
+ JTryBlock tryInFinally = finallyBody._try();
+ tryInFinally.body().add(classes().ROBO_GUICE.staticInvoke("destroyInjector").arg(_this()));
+ tryInFinally._finally().invoke(_super(), "onDestroy");
- JMethod onDestroy = holder.getOnDestroy();
- codeModelHelper.replaceSuperCall(onDestroy, onDestroyBlock);
+ JMethod onDestroy = holder.getOnDestroy();
+ codeModelHelper.replaceSuperCall(onDestroy, onDestroyBlock);
}
private void onConfigurationChangedMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
@@ -219,22 +205,17 @@ private void onConfigurationChangedMethod(RoboGuiceHolder holder, JFieldVar even
private void onContentChangedMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
JBlock onContentChangedAfterSuperBlock = holder.getOnContentChangedAfterSuperBlock();
+ onContentChangedAfterSuperBlock.add(classes().ROBO_GUICE.staticInvoke("getInjector").arg(_this()).invoke("injectViewMembers").arg(_this()));
fireEvent(eventManager, onContentChangedAfterSuperBlock, classes().ON_CONTENT_CHANGED_EVENT);
}
- private void onActivityResultMethod(RoboGuiceHolder holder, JFieldVar scope, JFieldVar eventManager) {
+ private void onActivityResultMethod(RoboGuiceHolder holder, JFieldVar eventManager) {
JBlock onActivityResultAfterSuperBlock = holder.getOnActivityResultAfterSuperBlock();
JVar requestCode = holder.getRequestCode();
JVar resultCode = holder.getResultCode();
JVar data = holder.getData();
- onActivityResultAfterSuperBlock.invoke(scope, "enter").arg(_this());
-
- JTryBlock tryBlock = onActivityResultAfterSuperBlock._try();
- fireEvent(eventManager, tryBlock.body(), classes().ON_ACTIVITY_RESULT_EVENT, requestCode, resultCode, data);
-
- JBlock finallyBody = tryBlock._finally();
- finallyBody.invoke(scope, "exit").arg(_this());
+ fireEvent(eventManager, onActivityResultAfterSuperBlock, classes().ON_ACTIVITY_RESULT_EVENT, requestCode, resultCode, data);
}
private void fireEvent(JFieldVar eventManager, JBlock body, JClass eventClass, JExpression... eventArguments) {
@@ -244,4 +225,10 @@ private void fireEvent(JFieldVar eventManager, JBlock body, JClass eventClass, J
}
body.invoke(eventManager, "fire").arg(newEvent);
}
+
+ private void getScopedObjectMap(EActivityHolder holder, JFieldVar scopedObjectMap) {
+ JMethod getScopedObjectMapMethod = holder.getGeneratedClass().method(JMod.PUBLIC, scopedObjectMap.type(), "getScopedObjectMap");
+ getScopedObjectMapMethod.annotate(Override.class);
+ getScopedObjectMapMethod.body()._return(scopedObjectMap);
+ }
}
diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/CanonicalNameConstants.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/CanonicalNameConstants.java
index 11210acb24..f162cd18ff 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/CanonicalNameConstants.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/CanonicalNameConstants.java
@@ -141,8 +141,10 @@ public final class CanonicalNameConstants {
/*
* RoboGuice
*/
- public static final String INJECTOR_PROVIDER = "roboguice.inject.InjectorProvider";
- public static final String INJECTOR = "com.google.inject.Injector";
+ public static final String ROBO_CONTEXT = "roboguice.util.RoboContext";
+ public static final String ROBO_INJECTOR = "roboguice.inject.RoboInjector";
+ public static final String KEY = "com.google.inject.Key";
+ public static final String CONTENT_VIEW_LISTENER = "roboguice.inject.ContentViewListener";
public static final String ON_RESTART_EVENT = "roboguice.activity.event.OnRestartEvent";
public static final String ON_START_EVENT = "roboguice.activity.event.OnStartEvent";
public static final String ON_RESUME_EVENT = "roboguice.activity.event.OnResumeEvent";
@@ -150,6 +152,7 @@ public final class CanonicalNameConstants {
public static final String ON_NEW_INTENT_EVENT = "roboguice.activity.event.OnNewIntentEvent";
public static final String EVENT_MANAGER = "roboguice.event.EventManager";
public static final String CONTEXT_SCOPE = "roboguice.inject.ContextScope";
+ public static final String ROBO_GUICE = "roboguice.RoboGuice";
public static final String INJECT = "com.google.inject.Inject";
public static final String ON_STOP_EVENT = "roboguice.activity.event.OnStopEvent";
public static final String ON_DESTROY_EVENT = "roboguice.activity.event.OnDestroyEvent";
diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/ValidatorHelper.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/ValidatorHelper.java
index a37a54e64f..33918d71e9 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/ValidatorHelper.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/ValidatorHelper.java
@@ -15,9 +15,66 @@
*/
package org.androidannotations.helper;
-import org.androidannotations.annotations.*;
-import org.androidannotations.annotations.rest.*;
-import org.androidannotations.annotations.sharedpreferences.*;
+import static java.util.Arrays.asList;
+import static org.androidannotations.helper.AndroidConstants.LOG_DEBUG;
+import static org.androidannotations.helper.AndroidConstants.LOG_ERROR;
+import static org.androidannotations.helper.AndroidConstants.LOG_INFO;
+import static org.androidannotations.helper.AndroidConstants.LOG_VERBOSE;
+import static org.androidannotations.helper.AndroidConstants.LOG_WARN;
+import static org.androidannotations.helper.CanonicalNameConstants.CLIENT_HTTP_REQUEST_FACTORY;
+import static org.androidannotations.helper.CanonicalNameConstants.CLIENT_HTTP_REQUEST_INTERCEPTOR;
+import static org.androidannotations.helper.CanonicalNameConstants.HTTP_MESSAGE_CONVERTER;
+import static org.androidannotations.helper.CanonicalNameConstants.INTERNET_PERMISSION;
+import static org.androidannotations.helper.ModelConstants.GENERATION_SUFFIX;
+import static org.androidannotations.helper.ModelConstants.VALID_ENHANCED_COMPONENT_ANNOTATIONS;
+import static org.androidannotations.helper.ModelConstants.VALID_ENHANCED_VIEW_SUPPORT_ANNOTATIONS;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.ArrayType;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.ErrorType;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.Elements;
+
+import org.androidannotations.annotations.EActivity;
+import org.androidannotations.annotations.EBean;
+import org.androidannotations.annotations.EFragment;
+import org.androidannotations.annotations.EIntentService;
+import org.androidannotations.annotations.EService;
+import org.androidannotations.annotations.Receiver;
+import org.androidannotations.annotations.Trace;
+import org.androidannotations.annotations.ViewById;
+import org.androidannotations.annotations.rest.Delete;
+import org.androidannotations.annotations.rest.Get;
+import org.androidannotations.annotations.rest.Head;
+import org.androidannotations.annotations.rest.Options;
+import org.androidannotations.annotations.rest.Post;
+import org.androidannotations.annotations.rest.Put;
+import org.androidannotations.annotations.rest.Rest;
+import org.androidannotations.annotations.sharedpreferences.DefaultBoolean;
+import org.androidannotations.annotations.sharedpreferences.DefaultFloat;
+import org.androidannotations.annotations.sharedpreferences.DefaultInt;
+import org.androidannotations.annotations.sharedpreferences.DefaultLong;
+import org.androidannotations.annotations.sharedpreferences.DefaultString;
+import org.androidannotations.annotations.sharedpreferences.SharedPref;
import org.androidannotations.api.rest.RestClientErrorHandling;
import org.androidannotations.api.rest.RestClientHeaders;
import org.androidannotations.api.rest.RestClientRootUrl;
@@ -27,18 +84,6 @@
import org.androidannotations.model.AnnotationElements;
import org.androidannotations.process.IsValid;
-import javax.lang.model.element.*;
-import javax.lang.model.type.*;
-import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.Elements;
-import java.lang.annotation.Annotation;
-import java.util.*;
-
-import static java.util.Arrays.asList;
-import static org.androidannotations.helper.AndroidConstants.*;
-import static org.androidannotations.helper.CanonicalNameConstants.*;
-import static org.androidannotations.helper.ModelConstants.*;
-
public class ValidatorHelper {
private static final List VALID_REST_INTERFACES = asList(RestClientHeaders.class.getName(), RestClientErrorHandling.class.getName(), RestClientRootUrl.class.getName(), RestClientSupport.class.getName());
@@ -613,24 +658,19 @@ public void allowedType(Element element, IsValid valid, TypeMirror fieldTypeMirr
public void hasRoboGuiceJars(Element element, IsValid valid) {
Elements elementUtils = annotationHelper.getElementUtils();
- if (elementUtils.getTypeElement(CanonicalNameConstants.INJECTOR_PROVIDER) == null) {
- valid.invalidate();
- annotationHelper.printAnnotationError(element, "Could not find the RoboGuice framework in the classpath, the following class is missing: " + CanonicalNameConstants.INJECTOR_PROVIDER);
- }
-
- if (elementUtils.getTypeElement(RoboGuiceConstants.ROBOGUICE_APPLICATION_CLASS) == null) {
+ if (elementUtils.getTypeElement(CanonicalNameConstants.ROBO_CONTEXT) == null) {
valid.invalidate();
- annotationHelper.printAnnotationError(element, "Could not find the RoboApplication class in the classpath, are you using RoboGuice 1.1.1 ?");
+ annotationHelper.printAnnotationError(element, "Could not find the RoboGuice framework in the classpath, the following class is missing: " + CanonicalNameConstants.ROBO_CONTEXT);
}
try {
- if (elementUtils.getTypeElement(CanonicalNameConstants.INJECTOR) == null) {
+ if (elementUtils.getTypeElement(CanonicalNameConstants.ROBO_INJECTOR) == null) {
valid.invalidate();
- annotationHelper.printAnnotationError(element, "Could not find the Guice framework in the classpath, the following class is missing: " + CanonicalNameConstants.INJECTOR);
+ annotationHelper.printAnnotationError(element, "Could not find the Guice framework in the classpath, the following class is missing: " + CanonicalNameConstants.ROBO_INJECTOR);
}
} catch (RuntimeException e) {
valid.invalidate();
- annotationHelper.printAnnotationError(element, "Could not find the Guice framework in the classpath, the following class is missing: " + CanonicalNameConstants.INJECTOR);
+ annotationHelper.printAnnotationError(element, "Could not find the Guice framework in the classpath, the following class is missing: " + CanonicalNameConstants.ROBO_INJECTOR);
}
}
diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/EActivityHolder.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/EActivityHolder.java
index 17dc658864..a6e749d7e0 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/EActivityHolder.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/EActivityHolder.java
@@ -19,6 +19,7 @@
import org.androidannotations.api.SdkVersionHelper;
import org.androidannotations.helper.*;
import org.androidannotations.process.ProcessHolder;
+import static org.androidannotations.helper.ModelConstants.GENERATION_SUFFIX;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
@@ -420,20 +421,21 @@ public RoboGuiceHolder getRoboGuiceHolder() {
return roboGuiceHolder;
}
- protected void setScopeField() {
- getRoboGuiceHolder().scope = getGeneratedClass().field(JMod.PRIVATE, classes().CONTEXT_SCOPE, "scope_");
+ protected void setScopedObjectsField() {
+ JClass keyWildCard = classes().KEY.narrow(codeModel().wildcard());
+ JClass scopedHashMap = classes().HASH_MAP.narrow(keyWildCard, classes().OBJECT);
+
+ getRoboGuiceHolder().scopedObjects = getGeneratedClass().field(JMod.PROTECTED, scopedHashMap, "scopedObjects" + GENERATION_SUFFIX);
+ getRoboGuiceHolder().scopedObjects.assign(JExpr._new(scopedHashMap));
}
protected void setEventManagerField() {
- getRoboGuiceHolder().eventManager = generatedClass.field(JMod.PRIVATE, classes().EVENT_MANAGER, "eventManager_");
+ getRoboGuiceHolder().eventManager = generatedClass.field(JMod.PROTECTED, classes().EVENT_MANAGER, "eventManager" + GENERATION_SUFFIX);
}
- public void setGetInjector() {
- JMethod method = generatedClass.method(JMod.PUBLIC, classes().INJECTOR, "getInjector");
- method.annotate(Override.class);
- JExpression castApplication = cast(classes().INJECTOR_PROVIDER, invoke("getApplication"));
- method.body()._return(castApplication.invoke("getInjector"));
- getRoboGuiceHolder().getInjector = method;
+ protected void setContentViewListenerField() {
+ getRoboGuiceHolder().contentViewListenerField = generatedClass.field(JMod.NONE, classes().CONTENT_VIEW_LISTENER, "ignored" + GENERATION_SUFFIX);
+ getRoboGuiceHolder().contentViewListenerField.annotate(classes().INJECT);
}
@Override
@@ -665,6 +667,7 @@ public JBlock getOnDestroyAfterSuperBlock() {
return onDestroyAfterSuperBlock;
}
+ @Override
public JBlock getOnResumeAfterSuperBlock() {
if (onResumeAfterSuperBlock == null) {
setOnResume();
@@ -724,5 +727,4 @@ public JFieldVar getIntentFilterField(String[] actions) {
return receiverRegistrationHolder.getIntentFilterField(actions);
}
-
}
diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/RoboGuiceHolder.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/RoboGuiceHolder.java
index b036979bb7..f6912e111b 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/RoboGuiceHolder.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/holder/RoboGuiceHolder.java
@@ -23,9 +23,9 @@
public class RoboGuiceHolder {
private EActivityHolder holder;
- protected JFieldVar scope;
+ protected JFieldVar scopedObjects;
protected JFieldVar eventManager;
- protected JMethod getInjector;
+ public JFieldVar contentViewListenerField;
protected JBlock onRestartBeforeSuperBlock;
protected JBlock onRestartAfterSuperBlock;
protected JBlock onStartBeforeSuperBlock;
@@ -50,18 +50,18 @@ public JFieldVar getEventManagerField() {
return eventManager;
}
- public JFieldVar getScopeField() {
- if (scope == null) {
- holder.setScopeField();
+ public JFieldVar getScopedObjectsField() {
+ if (scopedObjects == null) {
+ holder.setScopedObjectsField();
}
- return scope;
+ return scopedObjects;
}
- public JMethod getGetInjector() {
- if (getInjector == null) {
- holder.setGetInjector();
+ public JFieldVar getContentViewListenerField() {
+ if (contentViewListenerField == null) {
+ holder.setContentViewListenerField();
}
- return getInjector;
+ return contentViewListenerField;
}
public JBlock getOnRestartBeforeSuperBlock() {
diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/process/ProcessHolder.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/process/ProcessHolder.java
index 871b7e6f53..f27e3f0268 100644
--- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/process/ProcessHolder.java
+++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/process/ProcessHolder.java
@@ -129,22 +129,23 @@ public class Classes {
/*
* RoboGuice
*/
- public final JClass INJECTOR_PROVIDER = refClass(CanonicalNameConstants.INJECTOR_PROVIDER);
- public final JClass INJECTOR = refClass(CanonicalNameConstants.INJECTOR);
+ public final JClass ROBO_CONTEXT = refClass(CanonicalNameConstants.ROBO_CONTEXT);
+ public final JClass ROBO_INJECTOR = refClass(CanonicalNameConstants.ROBO_INJECTOR);
+ public final JClass CONTENT_VIEW_LISTENER = refClass(CanonicalNameConstants.CONTENT_VIEW_LISTENER);
+ public final JClass KEY = refClass(CanonicalNameConstants.KEY);
public final JClass ON_RESTART_EVENT = refClass(CanonicalNameConstants.ON_RESTART_EVENT);
public final JClass ON_START_EVENT = refClass(CanonicalNameConstants.ON_START_EVENT);
public final JClass ON_RESUME_EVENT = refClass(CanonicalNameConstants.ON_RESUME_EVENT);
public final JClass ON_PAUSE_EVENT = refClass(CanonicalNameConstants.ON_PAUSE_EVENT);
public final JClass ON_NEW_INTENT_EVENT = refClass(CanonicalNameConstants.ON_NEW_INTENT_EVENT);
public final JClass EVENT_MANAGER = refClass(CanonicalNameConstants.EVENT_MANAGER);
- public final JClass CONTEXT_SCOPE = refClass(CanonicalNameConstants.CONTEXT_SCOPE);
+ public final JClass ROBO_GUICE = refClass(CanonicalNameConstants.ROBO_GUICE);
public final JClass INJECT = refClass(CanonicalNameConstants.INJECT);
public final JClass ON_STOP_EVENT = refClass(CanonicalNameConstants.ON_STOP_EVENT);
public final JClass ON_DESTROY_EVENT = refClass(CanonicalNameConstants.ON_DESTROY_EVENT);
public final JClass ON_CONFIGURATION_CHANGED_EVENT = refClass(CanonicalNameConstants.ON_CONFIGURATION_CHANGED_EVENT);
public final JClass ON_CONTENT_CHANGED_EVENT = refClass(CanonicalNameConstants.ON_CONTENT_CHANGED_EVENT);
public final JClass ON_ACTIVITY_RESULT_EVENT = refClass(CanonicalNameConstants.ON_ACTIVITY_RESULT_EVENT);
- public final JClass ON_CONTENT_VIEW_AVAILABLE_EVENT = refClass(CanonicalNameConstants.ON_CONTENT_VIEW_AVAILABLE_EVENT);
public final JClass ON_CREATE_EVENT = refClass(CanonicalNameConstants.ON_CREATE_EVENT);
/*
diff --git a/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/CustomTitleActivity.java b/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/CustomTitleActivity.java
index 4a70dd5bff..45b8788776 100644
--- a/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/CustomTitleActivity.java
+++ b/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/CustomTitleActivity.java
@@ -1,26 +1,26 @@
-/**
- * Copyright (C) 2010-2014 eBusiness Information, Excilys Group
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed To in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.androidannotations.test15;
-
-import org.androidannotations.annotations.CustomTitle;
-import org.androidannotations.annotations.EActivity;
-
-import android.app.Activity;
-
-@EActivity
-@CustomTitle(R.layout.component)
-public class CustomTitleActivity extends Activity {
-}
+/**
+ * Copyright (C) 2010-2014 eBusiness Information, Excilys Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed To in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.androidannotations.test15;
+
+import org.androidannotations.annotations.CustomTitle;
+import org.androidannotations.annotations.EActivity;
+
+import android.app.Activity;
+
+@EActivity
+@CustomTitle(R.layout.component)
+public class CustomTitleActivity extends Activity {
+}
diff --git a/examples/gradle/gradlew.bat b/examples/gradle/gradlew.bat
index aec99730b4..8a0b282aa6 100644
--- a/examples/gradle/gradlew.bat
+++ b/examples/gradle/gradlew.bat
@@ -1,90 +1,90 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega