Skip to content

Instantly share code, notes, and snippets.

View abombss's full-sized avatar

Adam Tybor abombss

  • Accenture
  • Chicago, IL
View GitHub Profile
@abombss
abombss / Usage.java
Created February 25, 2011 19:16
A roboguice provider for creating a User-Agent string on android
public class MyModule extends AbstractModule {
@Override
void configure() {
bind(String.class).annotatedWith(UserAgent.class).to(UserAgentProvider.class);
}
}
public class MyComponent {
String userAgent;
@abombss
abombss / WakefulIntentService.java
Created February 21, 2011 18:02
A compatible wakeful intent service
/***
Copyright (c) 2009 CommonsWare, LLC
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.
@abombss
abombss / RobolectricGuicyTestRunner.java
Created February 9, 2011 05:44
Robolectric test runner with modifications for RoboGuice 1.2-SNAPSHOT
public class RobolectricGuicyTestRunner extends RobolectricTestRunner {
public RobolectricGuicyTestRunner(Class testClass) throws InitializationError {
super(testClass, new File("./application").exists() ? new File("./application") : new File("./"));
}
@Override
protected Application createApplication() {
Application app = super.createApplication();
Injector injector = RoboGuice.getInjector(Stage.PRODUCTION, app,new RoboModule(app), new RobolectricModule());
return app;
@abombss
abombss / ContextRunner.java
Created February 5, 2011 07:39
Poor Man's Mspec in Java
public class ContextRunner extends Runner {
static class SpecificationMethod {
Class<?> TestContainerType;
Description TestContainerDescription;
ContextSpecification ContextSpecification;
Description ContextSpecificationDescription;
Field ContextSpecificationField;
Method SpecificationMethod;
Description SpecificationDescription;
}
package roboguice.astroboy;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import roboguice.inject.InjectView;
import java.util.List;