Slide 1

Slide 1 text

More With Less with android bootstrap building Saturday, April 20, 13

Slide 2

Slide 2 text

@donnfelker Saturday, April 20, 13

Slide 3

Slide 3 text

Saturday, April 20, 13

Slide 4

Slide 4 text

Building More With Less Saturday, April 20, 13

Slide 5

Slide 5 text

agenda open source libraries examples bootstrap Saturday, April 20, 13

Slide 6

Slide 6 text

Saturday, April 20, 13

Slide 7

Slide 7 text

Pay with Square GitHub Gaug.es Saturday, April 20, 13

Slide 8

Slide 8 text

tons of integration work tons of open source Saturday, April 20, 13

Slide 9

Slide 9 text

open source dagger action bar sherlock otto http-request gson view pager indicator robotium maven android maven plugin fragments Saturday, April 20, 13

Slide 10

Slide 10 text

a fast dependency injector for Android and Java http://square.github.io/dagger/ Saturday, April 20, 13

Slide 11

Slide 11 text

Why is it so fast? - Compile Time Validation - Compile Time Code Generation Saturday, April 20, 13

Slide 12

Slide 12 text

public class UserActivity extends BootstrapActivity { @Inject protected AvatarLoader avatarLoader; protected User user; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.user_view); if(getIntent() != null && getIntent().getExtras() != null) { user = (User) getIntent().getExtras().getSerializable(USER); } getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); avatarLoader.bind(avatar, user); name.setText(String.format("%s %s", user.getFirstName(), user.getLastName())); } } http://square.github.io/dagger/ Saturday, April 20, 13

Slide 13

Slide 13 text

User Interface Service Layer Persistence Layer what if I a particular dependency down here that depends on context? service layer: goo.gl/7NQVZ persistence layer: goo.gl/j5u74 http://square.github.io/dagger/ Saturday, April 20, 13

Slide 14

Slide 14 text

public class UserRepository { @Inject PublicKeyProvider publicKeyProvider; public void saveProfile(UserProfile profile) { // user publicKey to do some encryption // Now, save the encrypted profile to db/api/etc } } http://square.github.io/dagger/ Saturday, April 20, 13

Slide 15

Slide 15 text

public class UserRepository { @Inject PublicKeyProvider publicKeyProvider; @Inject AuthService authService; public void saveProfile(UserProfile profile) { // Get auth token from auth service then save // user publicKey to do some encryption // Now, save the encrypted profile to api } } http://square.github.io/dagger/ Saturday, April 20, 13

Slide 16

Slide 16 text

must extend wait .. no .. no need to extend anything! WOO WOO! http://square.github.io/dagger/ Saturday, April 20, 13

Slide 17

Slide 17 text

square.github.io/dagger/ Saturday, April 20, 13

Slide 18

Slide 18 text

action bar sherlock action bar support for pre 3.x actionbarsherlock.com Saturday, April 20, 13

Slide 19

Slide 19 text

Pay with Square GitHub Gaug.es actionbarsherlock.com Saturday, April 20, 13

Slide 20

Slide 20 text

actionbarsherlock.com Saturday, April 20, 13

Slide 21

Slide 21 text

usage getSupportActionBar() native calls supports theming must use Sherlock themes as parent actionbarsherlock.com Saturday, April 20, 13

Slide 22

Slide 22 text

must extend SherlockActivity SherlockListActivity SherlockFragmentActivity SherlockListFragmentActivity ... actionbarsherlock.com Saturday, April 20, 13

Slide 23

Slide 23 text

actionbarsherlock.com Saturday, April 20, 13

Slide 24

Slide 24 text

Otto An enhanced Guava-based event bus with emphasis on Android support. Saturday, April 20, 13

Slide 25

Slide 25 text

Publish an event bus.post(new AnswerAvailableEvent(42)); @Subscribe public void answerAvailable(AnswerAvailableEvent event) { // TODO: React to the event somehow! } Subscribing to the event Saturday, April 20, 13

Slide 26

Slide 26 text

Use Cases Activity / Fragment Communication Service / Fragment / Activity Communication Basic Message Passing between objects in scope Saturday, April 20, 13

Slide 27

Slide 27 text

Publish an event FROM A FRAGMENT bus.post(new AnswerAvailableEvent(42)); @Subscribe public void answerAvailable(AnswerAvailableEvent event) { // TODO: React to the event somehow! } Subscribing to the event FROM A ACTIVITY Saturday, April 20, 13

Slide 28

Slide 28 text

usage include library via lib or maven // Register in onResume() bus.register(this); // Unregister in onPause() bus.unregister(this); // in onPause @Provides bus.post(event); @Subscribe Saturday, April 20, 13

Slide 29

Slide 29 text

square.github.io/otto/ Saturday, April 20, 13

Slide 30

Slide 30 text

http-request kevinsawicki.github.com/http-request/ A simple convenience library for using a HttpURLConnection to make requests and access the response. Saturday, April 20, 13

Slide 31

Slide 31 text

kevinsawicki.github.com/http-request/ Saturday, April 20, 13

Slide 32

Slide 32 text

kevinsawicki.github.com/http-request/ Saturday, April 20, 13

Slide 33

Slide 33 text

Saturday, April 20, 13

Slide 34

Slide 34 text

kevinsawicki.github.com/http-request/ Saturday, April 20, 13

Slide 35

Slide 35 text

gson a library for working with json code.google.com/p/google-gson/ Saturday, April 20, 13

Slide 36

Slide 36 text

class  BagOfPrimitives  {    private  int  value1  =  1;    private  String  value2  =  "abc";    private  transient  int  value3  =  3;    BagOfPrimitives()  {        //  no-­‐args  constructor    } } BagOfPrimitives  obj  =  new  BagOfPrimitives(); Gson  gson  =  new  Gson(); String  json  =  gson.toJson(obj);   a pojo serialization BagOfPrimitives  obj2  =  gson.fromJson(json,  BagOfPrimitives.class); deserialization code.google.com/p/google-gson/ Saturday, April 20, 13

Slide 37

Slide 37 text

woohoo! no more manual json parsing code.google.com/p/google-gson/ Saturday, April 20, 13

Slide 38

Slide 38 text

code.google.com/p/google-gson/ Saturday, April 20, 13

Slide 39

Slide 39 text

view pager indicator viewpagerindicator.com Saturday, April 20, 13

Slide 40

Slide 40 text

viewpagerindicator.com Saturday, April 20, 13

Slide 41

Slide 41 text

viewpagerindicator.com Saturday, April 20, 13

Slide 42

Slide 42 text

viewpagerindicator.com Saturday, April 20, 13

Slide 43

Slide 43 text

android-maven-plugin an easy to use maven plugin for android code.google.com/p/maven-android-plugin/ Saturday, April 20, 13

Slide 44

Slide 44 text

       4.0.0        android-­‐bootstrap        apk        Android  Bootstrap  app        https://github.com/donnfelker/android-­‐bootstrap                        1.0                com.donnfelker.android.bootstrap                android-­‐bootstrap-­‐parent                                4.1.0                                                        com.google.android                        android                        provided                        ${android.version}                                                        com.google.code.gson                        gson                        2.1                                                        com.github.rtyley                        roboguice-­‐sherlock                        1.4                          ...   Saturday, April 20, 13

Slide 45

Slide 45 text

build process easier to manage code.google.com/p/maven-android-plugin/ Saturday, April 20, 13

Slide 46

Slide 46 text

resources google group ch14 of sonatype book goo.gl/3Waf5 (sample next) code.google.com/p/maven-android-plugin/ Saturday, April 20, 13

Slide 47

Slide 47 text

Saturday, April 20, 13

Slide 48

Slide 48 text

code.google.com/p/maven-android-plugin/ Saturday, April 20, 13

Slide 49

Slide 49 text

fragments android support library Saturday, April 20, 13

Slide 50

Slide 50 text

download from android sdk Saturday, April 20, 13

Slide 51

Slide 51 text

“its like selenium, but for android” code.google.com/p/robotium Saturday, April 20, 13

Slide 52

Slide 52 text

public class EditorTest extends ActivityInstrumentationTestCase2 { private Solo solo; public EditorTest() { super("com.test.editor", EditorActivity.class); } public void setUp() throws Exception { solo = new Solo(getInstrumentation(), getActivity()); } public void testPreferenceIsSaved() throws Exception { solo.sendKey(Solo.MENU); solo.clickOnText("More"); solo.clickOnText("Preferences"); solo.clickOnText("Edit File Extensions"); Assert.assertTrue(solo.searchText("rtf")); solo.clickOnText("txt"); solo.clearEditText(2); solo.enterText(2, "robotium"); solo.clickOnButton("Save"); solo.goBack(); solo.clickOnText("Edit File Extensions"); Assert.assertTrue(solo.searchText("application/robotium")); } @Override public void tearDown() throws Exception { solo.finishOpenedActivities(); } } code.google.com/p/robotium Saturday, April 20, 13

Slide 53

Slide 53 text

code.google.com/p/robotium Saturday, April 20, 13

Slide 54

Slide 54 text

androidbootstrap.com Saturday, April 20, 13

Slide 55

Slide 55 text

Saturday, April 20, 13

Slide 56

Slide 56 text

influences are from github and gaug.es GitHub Gaug.es androidbootstrap.com Saturday, April 20, 13

Slide 57

Slide 57 text

androidbootstrap.com includes dagger otto action bar sherlock http-request gson view pager indicator robotium maven android maven plugin fragments api consumption image downloading image caching cache mechanism pojo support and more... ahhhhhh yeah Saturday, April 20, 13

Slide 58

Slide 58 text

uses template for your next project use as a reference a how to tutorial project MVP bootstrap androidbootstrap.com Saturday, April 20, 13

Slide 59

Slide 59 text

q & a androidbootstrap.com Saturday, April 20, 13

Slide 60

Slide 60 text

Thank You. questions? tweet @donnfelker Saturday, April 20, 13