Monday, June 22, 2015

RoboGuice - Android development made simple and fun



"Simple and Fun!" Now, they make quite a promise!

read up:

https://github.com/roboguice/roboguice/blob/master/README.md

https://github.com/roboguice/roboguice/wiki

Maven repo:


org.roboguice
roboguice
3.0.1


OK, so most of all RoboGuice is about DEPENDENCY INJECTION



Examples:


@InjectView(R.id.label)
TextView label;

@InjectResource(R.string.app_name) // strings, drawables
String applicationName;

@Inject // system service
LayoutInflater layoutInflater;

@Inject
LocationManager locationManager;

@Inject // POJO
Book book;


Creating Activities



public class FightForcesOfEvilActivity extends RoboActivity {

@InjectView(R.id.expletive) 
TextView expletiveText;

Creating Android Modules


public class MyModule extends AbstractModule {
@Override
protected void configure() { }



AsynchTask 


public static class AsyncPunch extends RoboAsyncTask {

// Astroboy is a @Singleton public class Astroboy {
@Inject Astroboy astroboy;

// new instance of java.util.Random, since we haven't specified any binding instructions
@Inject Random random;


If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins