Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Commit 9b10834

Browse files
committed
Integrate with RoboGuice 3
This drops RoboGuice 2 support.
1 parent f3f76b9 commit 9b10834

6 files changed

Lines changed: 36 additions & 38 deletions

File tree

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/handler/RoboGuiceHandler.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,13 @@ private void onActivityResultMethod(RoboGuiceHolder holder, JFieldVar eventManag
231231
}
232232

233233
private void fireEvent(JFieldVar eventManager, JBlock body, JClass eventClass, JExpression... eventArguments) {
234-
JInvocation newEvent = _new(eventClass);
234+
JClass actualEventClass = eventClass;
235+
if (eventClass.fullName().startsWith("roboguice.context.event")) {
236+
actualEventClass = eventClass.narrow(classes().ACTIVITY);
237+
}
238+
239+
JInvocation newEvent = _new(actualEventClass);
240+
newEvent.arg(_this());
235241
for (JExpression eventArgument : eventArguments) {
236242
newEvent.arg(eventArgument);
237243
}

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/CanonicalNameConstants.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ public final class CanonicalNameConstants {
142142
* RoboGuice
143143
*/
144144
public static final String ROBO_APPLICATION = "roboguice.application.RoboApplication";
145+
public static final String ON_START_EVENT_OLD = "roboguice.activity.event.OnStartEvent";
145146
public static final String ROBO_CONTEXT = "roboguice.util.RoboContext";
146147
public static final String ROBO_INJECTOR = "roboguice.inject.RoboInjector";
147148
public static final String KEY = "com.google.inject.Key";
148149
public static final String CONTENT_VIEW_LISTENER = "roboguice.inject.ContentViewListener";
149150
public static final String ON_RESTART_EVENT = "roboguice.activity.event.OnRestartEvent";
150-
public static final String ON_START_EVENT = "roboguice.activity.event.OnStartEvent";
151+
public static final String ON_START_EVENT = "roboguice.context.event.OnStartEvent";
151152
public static final String ON_RESUME_EVENT = "roboguice.activity.event.OnResumeEvent";
152153
public static final String ON_PAUSE_EVENT = "roboguice.activity.event.OnPauseEvent";
153154
public static final String ON_NEW_INTENT_EVENT = "roboguice.activity.event.OnNewIntentEvent";
@@ -157,12 +158,12 @@ public final class CanonicalNameConstants {
157158
public static final String ROBO_GUICE = "roboguice.RoboGuice";
158159
public static final String INJECT = "com.google.inject.Inject";
159160
public static final String ON_STOP_EVENT = "roboguice.activity.event.OnStopEvent";
160-
public static final String ON_DESTROY_EVENT = "roboguice.activity.event.OnDestroyEvent";
161-
public static final String ON_CONFIGURATION_CHANGED_EVENT = "roboguice.activity.event.OnConfigurationChangedEvent";
161+
public static final String ON_DESTROY_EVENT = "roboguice.context.event.OnDestroyEvent";
162+
public static final String ON_CONFIGURATION_CHANGED_EVENT = "roboguice.context.event.OnConfigurationChangedEvent";
162163
public static final String ON_CONTENT_CHANGED_EVENT = "roboguice.activity.event.OnContentChangedEvent";
163164
public static final String ON_ACTIVITY_RESULT_EVENT = "roboguice.activity.event.OnActivityResultEvent";
164165
public static final String ON_CONTENT_VIEW_AVAILABLE_EVENT = "roboguice.activity.event.OnContentViewAvailableEvent";
165-
public static final String ON_CREATE_EVENT = "roboguice.activity.event.OnCreateEvent";
166+
public static final String ON_CREATE_EVENT = "roboguice.context.event.OnCreateEvent";
166167

167168
/*
168169
* ORMLite

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/ValidatorHelper.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,12 @@ public void hasRoboGuiceJars(Element element, IsValid valid) {
715715

716716
if (elementUtils.getTypeElement(CanonicalNameConstants.ROBO_APPLICATION) != null) {
717717
valid.invalidate();
718-
annotationHelper.printAnnotationError(element, "It seems you are using an old version of RoboGuice. Be sure to use version 2.0!");
718+
annotationHelper.printAnnotationError(element, "It seems you are using an old version of RoboGuice. Be sure to use version 3.0!");
719+
}
720+
721+
if (elementUtils.getTypeElement(CanonicalNameConstants.ON_START_EVENT_OLD) != null) {
722+
valid.invalidate();
723+
annotationHelper.printAnnotationError(element, "It seems you are using an old version of RoboGuice. Be sure to use version 3.0!");
719724
}
720725
}
721726

‎AndroidAnnotations/functional-test-1-5/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>org.roboguice</groupId>
4444
<artifactId>roboguice</artifactId>
45-
<version>2.0</version>
45+
<version>3.0</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>com.j256.ormlite</groupId>

‎AndroidAnnotations/functional-test-1-5/src/test/java/org/androidannotations/test15/roboguice/RobolectricSampleTestModule.java‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
import java.util.Date;
1919

20-
import roboguice.util.Ln;
21-
import android.util.Log;
22-
2320
import com.google.inject.AbstractModule;
2421
import com.google.inject.Scopes;
2522

@@ -29,14 +26,5 @@ public class RobolectricSampleTestModule extends AbstractModule {
2926
protected void configure() {
3027
bind(Date.class).toProvider(FakeDateProvider.class);
3128
bind(Counter.class).in(Scopes.SINGLETON);
32-
bind(Ln.BaseConfig.class).toInstance(new RobolectricLoggerConfig());
33-
}
34-
35-
static class RobolectricLoggerConfig extends Ln.BaseConfig {
36-
public RobolectricLoggerConfig() {
37-
packageName = "robo";
38-
minimumLogLevel = Log.VERBOSE;
39-
scope = "ROBO";
40-
}
4129
}
4230
}

‎AndroidAnnotations/functional-test-1-5/src/test/java/org/androidannotations/test15/roboguice/TestSampleRoboApplication_.java‎

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,27 @@
99
import android.app.Application;
1010

1111
public class TestSampleRoboApplication_ extends Application implements TestLifecycleApplication {
12-
@Override
13-
public void onCreate() {
14-
super.onCreate();
12+
@Override
13+
public void onCreate() {
14+
super.onCreate();
1515

16-
RoboGuice.setBaseApplicationInjector(this, RoboGuice.DEFAULT_STAGE,
17-
RoboGuice.newDefaultRoboModule(this), new RobolectricSampleModule());
18-
}
16+
RoboGuice.overrideApplicationInjector(this, RoboGuice.newDefaultRoboModule(this), new RobolectricSampleModule());
17+
}
1918

20-
@Override
21-
public void beforeTest(Method method) {
22-
}
19+
@Override
20+
public void beforeTest(Method method) {
21+
}
2322

24-
@Override
25-
public void prepareTest(Object test) {
26-
TestSampleRoboApplication_ application = (TestSampleRoboApplication_) Robolectric.application;
23+
@Override
24+
public void prepareTest(Object test) {
25+
TestSampleRoboApplication_ application = (TestSampleRoboApplication_) Robolectric.application;
2726

28-
RoboGuice.setBaseApplicationInjector(application, RoboGuice.DEFAULT_STAGE,
29-
RoboGuice.newDefaultRoboModule(application), new RobolectricSampleTestModule());
27+
RoboGuice.overrideApplicationInjector(application, RoboGuice.newDefaultRoboModule(application), new RobolectricSampleTestModule());
3028

31-
RoboGuice.getInjector(application).injectMembers(test);
32-
}
29+
RoboGuice.getInjector(application).injectMembers(test);
30+
}
3331

34-
@Override
35-
public void afterTest(Method method) {
36-
}
32+
@Override
33+
public void afterTest(Method method) {
34+
}
3735
}

0 commit comments

Comments
 (0)