Slide 1

Slide 1 text

Android Development with android bootstrap bootstrapping

Slide 2

Slide 2 text

DONN FELKER [email protected] @donnfelker gplus.to/donnfelker

Slide 3

Slide 3 text

Groupon MyFitnessPal GetHuman Fitness+3 Travel WODs QONQR ... and over 50 more Android apps

Slide 4

Slide 4 text

loose agenda what is android bootstrap? why was it built? lots of demos libraries & examples questions

Slide 5

Slide 5 text

What is Android Bootstrap?

Slide 6

Slide 6 text

A collection of libraries and frameworks integrated together in a easy to use application that can serve as a boilerplate or reference for existing or future Android apps.

Slide 7

Slide 7 text

http api consumption dependency injection pojos instead of raw json message bus fragments navigation drawer action bar testing responsive layout backwards compatibility boilerplate for new projects

Slide 8

Slide 8 text

Why was Android Bootstrap built?

Slide 9

Slide 9 text

new client! new project!

Slide 10

Slide 10 text

reuse old code

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

this week!

Slide 13

Slide 13 text

it worked. but it was demoralizing.

Slide 14

Slide 14 text

Boilerplate. Bootstrap. MVP. I needed to

Slide 15

Slide 15 text

Goal Build More With Less

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Pay with Square GitHub Gaug.es

Slide 18

Slide 18 text

How do we get there?

Slide 19

Slide 19 text

tons of integration work tons of open source

Slide 20

Slide 20 text

open source used dagger app compat navigation drawer otto http-request gson view pager indicator robotium gradle fragments parse.com

Slide 21

Slide 21 text

android bootstrap demo

Slide 22

Slide 22 text

download the app from search for “android bootstrap”

Slide 23

Slide 23 text

App Architecture

Slide 24

Slide 24 text

Parse.com datastore & REST endpoint (MongoDB in the cloud) app requests data parse REST API returns JSON data

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Views Activities Service Layer Event Bus Repository Layer POJOS JSON parse Dependency Injection API consumption through HTTP Otto Dagger & Butterknife GSON Fragments (http-request)

Slide 28

Slide 28 text

UI & UX Used in Android Bootstrap Navigation Drawer Action Bar View Page Indicator

Slide 29

Slide 29 text

Picasso ListView Images are loaded via Picasso from Gravatar square.github.io/picasso/

Slide 30

Slide 30 text

Fragments & Responsive Aware Layout Handset Tablet

Slide 31

Slide 31 text

Background Service Timer Activity is updated from background service. Timer will continue to run in background. Use notification to go back to the activity. Timer is updated and looks like its running at all times.

Slide 32

Slide 32 text

Background Service Architecture Android Activity Event Bus Background Service Android Notifications

Slide 33

Slide 33 text

ANDROID BOOTSTRAP HAS A LOT GOING ON

Slide 34

Slide 34 text

GOOD

Slide 35

Slide 35 text

Overview of Libraries

Slide 36

Slide 36 text

square.github.io/dagger/

Slide 37

Slide 37 text

ActionBar with AppCompat actionbarsherlock.com

Slide 38

Slide 38 text

Pay with Square GitHub Gaug.es

Slide 39

Slide 39 text

screenshot: actionbarsherlock.com

Slide 40

Slide 40 text

usage getSupportActionBar() MenuItemCompat supports theming must use AppCompat themes as parent

Slide 41

Slide 41 text

must extend ActionBarActivity actionbarsherlock.com gotchas No PreferenceActivity Support

Slide 42

Slide 42 text

AppCompat demo

Slide 43

Slide 43 text

Navigation Drawer

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

DrawerLayout & Fragments/Views

Slide 46

Slide 46 text

navigation drawer demo

Slide 47

Slide 47 text

Otto An enhanced Guava-based event bus with emphasis on Android support.

Slide 48

Slide 48 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

Slide 49

Slide 49 text

Use Cases Activity / Fragment Communication Service / Fragment / Activity Communication Basic Message Passing between objects in scope Excellent Message Bus

Slide 50

Slide 50 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

Slide 51

Slide 51 text

usage include library via libs, maven or gradle // Register in onResume() bus.register(this); // Unregister in onPause() bus.unregister(this); // in onPause @Provides bus.post(event); @Subscribe

Slide 52

Slide 52 text

Otto demo

Slide 53

Slide 53 text

square.github.io/otto/

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

kevinsawicki.github.com/http-request/

Slide 56

Slide 56 text

kevinsawicki.github.com/http-request/

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

kevinsawicki.github.com/http-request/

Slide 59

Slide 59 text

gson a library for working with json code.google.com/p/google-gson/

Slide 60

Slide 60 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/

Slide 61

Slide 61 text

woohoo! no more manual json parsing code.google.com/p/google-gson/

Slide 62

Slide 62 text

code.google.com/p/google-gson/

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

REST API

Slide 66

Slide 66 text

api consumption demo

Slide 67

Slide 67 text

a fast dependency injector for Android and Java http://square.github.io/dagger/

Slide 68

Slide 68 text

Why is it so fast? - Compile Time Validation - Compile Time Code Generation

Slide 69

Slide 69 text

http://square.github.io/dagger/

Slide 70

Slide 70 text

User Interface Service Layer Repository Layer what if I a particular dependency down here that depends on context? service layer: goo.gl/7NQVZ repository/persistence layer: goo.gl/j5u74 http://square.github.io/dagger/ Traditional IoC/DI Diagram

Slide 71

Slide 71 text

Dependencies in the UserListFragment

Slide 72

Slide 72 text

http://square.github.io/dagger/

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

dagger demo http://square.github.io/dagger/

Slide 75

Slide 75 text

view pager indicator viewpagerindicator.com

Slide 76

Slide 76 text

viewpagerindicator.com

Slide 77

Slide 77 text

viewpagerindicator.com

Slide 78

Slide 78 text

viewpagerindicator.com

Slide 79

Slide 79 text

gradle

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

build process easier to manage

Slide 82

Slide 82 text

gradle files demo

Slide 83

Slide 83 text

resources Gradle Plugin User Guide http://tools.android.com/tech-docs/new-build-system/user-guide youtube.com/watch?v=LCJAgPkpmR0 IO 2013 -Android Gradle Plugin Intro Docs

Slide 84

Slide 84 text

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

Slide 85

Slide 85 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

Slide 86

Slide 86 text

code.google.com/p/robotium

Slide 87

Slide 87 text

androidbootstrap.com

Slide 88

Slide 88 text

Generate Your Next Project Gradle - Android Studio - AppCompat - NavigationDrawer Maven - IntelliJ - ActionBarSherlock - SlidingMenu androidbootstrap.com alpha.androidbootstrap.com USE THIS ONE

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

androidbootstrap.com includes dagger otto action bar sherlock or app compat http-request gson view pager indicator robotium maven or gradle fragments api consumption image downloading image caching cache mechanism pojo support and much more... ahhhhhh yeah

Slide 91

Slide 91 text

uses template for your next project use as a reference a how to tutorial project MVP bootstrap androidbootstrap.com

Slide 92

Slide 92 text

Thank You. DONN FELKER [email protected] @donnfelker gplus.to/donnfelker