Skip to content
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
Integrate with RoboGuice 3
This drops RoboGuice 2 support.
  • Loading branch information
WonderCsabo committed Dec 28, 2014
commit c9fe8e2b739308cc725d0ea389b8c0978db967cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ private void onActivityResultMethod(RoboGuiceHolder holder, JFieldVar eventManag
}

private void fireEvent(JFieldVar eventManager, JBlock body, JClass eventClass, JExpression... eventArguments) {
JInvocation newEvent = _new(eventClass);
JClass actualEventClass = eventClass;
if (eventClass.fullName().startsWith("roboguice.context.event")) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to call eventClass.isParameterized() here, but for some reason it always returns false. 😕

actualEventClass = eventClass.narrow(classes().ACTIVITY);
}

JInvocation newEvent = _new(actualEventClass);
newEvent.arg(_this());
for (JExpression eventArgument : eventArguments) {
newEvent.arg(eventArgument);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ public final class CanonicalNameConstants {
* RoboGuice
*/
public static final String ROBO_APPLICATION = "roboguice.application.RoboApplication";
public static final String ON_START_EVENT_OLD = "roboguice.activity.event.OnStartEvent";
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_START_EVENT = "roboguice.context.event.OnStartEvent";
public static final String ON_RESUME_EVENT = "roboguice.activity.event.OnResumeEvent";
public static final String ON_PAUSE_EVENT = "roboguice.activity.event.OnPauseEvent";
public static final String ON_NEW_INTENT_EVENT = "roboguice.activity.event.OnNewIntentEvent";
Expand All @@ -157,12 +158,12 @@ public final class CanonicalNameConstants {
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";
public static final String ON_CONFIGURATION_CHANGED_EVENT = "roboguice.activity.event.OnConfigurationChangedEvent";
public static final String ON_DESTROY_EVENT = "roboguice.context.event.OnDestroyEvent";
public static final String ON_CONFIGURATION_CHANGED_EVENT = "roboguice.context.event.OnConfigurationChangedEvent";
public static final String ON_CONTENT_CHANGED_EVENT = "roboguice.activity.event.OnContentChangedEvent";
public static final String ON_ACTIVITY_RESULT_EVENT = "roboguice.activity.event.OnActivityResultEvent";
public static final String ON_CONTENT_VIEW_AVAILABLE_EVENT = "roboguice.activity.event.OnContentViewAvailableEvent";
public static final String ON_CREATE_EVENT = "roboguice.activity.event.OnCreateEvent";
public static final String ON_CREATE_EVENT = "roboguice.context.event.OnCreateEvent";

/*
* ORMLite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,12 @@ public void hasRoboGuiceJars(Element element, IsValid valid) {

if (elementUtils.getTypeElement(CanonicalNameConstants.ROBO_APPLICATION) != null) {
valid.invalidate();
annotationHelper.printAnnotationError(element, "It seems you are using an old version of RoboGuice. Be sure to use version 2.0!");
annotationHelper.printAnnotationError(element, "It seems you are using an old version of RoboGuice. Be sure to use version 3.0!");
}

if (elementUtils.getTypeElement(CanonicalNameConstants.ON_START_EVENT_OLD) != null) {
valid.invalidate();
annotationHelper.printAnnotationError(element, "It seems you are using an old version of RoboGuice. Be sure to use version 3.0!");
}
}

Expand Down
2 changes: 1 addition & 1 deletion AndroidAnnotations/functional-test-1-5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

import java.util.Date;

import roboguice.util.Ln;
import android.util.Log;

import com.google.inject.AbstractModule;
import com.google.inject.Scopes;

Expand All @@ -29,14 +26,5 @@ public class RobolectricSampleTestModule extends AbstractModule {
protected void configure() {
bind(Date.class).toProvider(FakeDateProvider.class);
bind(Counter.class).in(Scopes.SINGLETON);
bind(Ln.BaseConfig.class).toInstance(new RobolectricLoggerConfig());
}

static class RobolectricLoggerConfig extends Ln.BaseConfig {
public RobolectricLoggerConfig() {
packageName = "robo";
minimumLogLevel = Log.VERBOSE;
scope = "ROBO";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

// CHECKSTYLE:OFF
public class TestSampleRoboApplication_ extends Application implements TestLifecycleApplication {
// CHECKSTYLE:ON
@Override
public void onCreate() {
super.onCreate();

RoboGuice.setBaseApplicationInjector(this, RoboGuice.DEFAULT_STAGE, RoboGuice.newDefaultRoboModule(this), new RobolectricSampleModule());
RoboGuice.overrideApplicationInjector(this, RoboGuice.newDefaultRoboModule(this), new RobolectricSampleModule());
}

@Override
Expand All @@ -26,7 +25,7 @@ public void beforeTest(Method method) {
public void prepareTest(Object test) {
TestSampleRoboApplication_ application = (TestSampleRoboApplication_) Robolectric.application;

RoboGuice.setBaseApplicationInjector(application, RoboGuice.DEFAULT_STAGE, RoboGuice.newDefaultRoboModule(application), new RobolectricSampleTestModule());
RoboGuice.overrideApplicationInjector(application, RoboGuice.newDefaultRoboModule(application), new RobolectricSampleTestModule());

RoboGuice.getInjector(application).injectMembers(test);
}
Expand Down