Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Bootstrap

Daf1617c9a4ff129239e922e8c56af1b?s=47 Donn Felker
November 15, 2013

Android Bootstrap

Bootstrap your next Android Application with Android Bootstrap or use it as a reference to learn new technology.

Daf1617c9a4ff129239e922e8c56af1b?s=128

Donn Felker

November 15, 2013
Tweet

Transcript

  1. Android Development with android bootstrap bootstrapping

  2. DONN FELKER donn@donnfelker.com @donnfelker gplus.to/donnfelker

  3. Groupon MyFitnessPal GetHuman Fitness+3 Travel WODs QONQR ... and over

    50 more Android apps
  4. loose agenda what is android bootstrap? why was it built?

    lots of demos libraries & examples questions
  5. What is Android Bootstrap?

  6. 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.
  7. 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
  8. Why was Android Bootstrap built?

  9. new client! new project!

  10. reuse old code

  11. None
  12. this week!

  13. it worked. but it was demoralizing.

  14. Boilerplate. Bootstrap. MVP. I needed to

  15. Goal Build More With Less

  16. None
  17. Pay with Square GitHub Gaug.es

  18. How do we get there?

  19. tons of integration work tons of open source

  20. open source used dagger app compat navigation drawer otto http-request

    gson view pager indicator robotium gradle fragments parse.com
  21. android bootstrap demo

  22. download the app from search for “android bootstrap”

  23. App Architecture

  24. Parse.com datastore & REST endpoint (MongoDB in the cloud) app

    requests data parse REST API returns JSON data
  25. None
  26. None
  27. Views Activities Service Layer Event Bus Repository Layer POJOS JSON

    parse Dependency Injection API consumption through HTTP Otto Dagger & Butterknife GSON Fragments (http-request)
  28. UI & UX Used in Android Bootstrap Navigation Drawer Action

    Bar View Page Indicator
  29. Picasso ListView Images are loaded via Picasso from Gravatar square.github.io/picasso/

  30. Fragments & Responsive Aware Layout Handset Tablet

  31. 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.
  32. Background Service Architecture Android Activity Event Bus Background Service Android

    Notifications
  33. ANDROID BOOTSTRAP HAS A LOT GOING ON

  34. GOOD

  35. Overview of Libraries

  36. square.github.io/dagger/

  37. ActionBar with AppCompat actionbarsherlock.com

  38. Pay with Square GitHub Gaug.es

  39. screenshot: actionbarsherlock.com

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

    parent
  41. must extend ActionBarActivity actionbarsherlock.com gotchas No PreferenceActivity Support

  42. AppCompat demo

  43. Navigation Drawer

  44. None
  45. DrawerLayout & Fragments/Views

  46. navigation drawer demo

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

    support.
  48. Publish an event bus.post(new AnswerAvailableEvent(42)); @Subscribe public void answerAvailable(AnswerAvailableEvent event)

    { // TODO: React to the event somehow! } Subscribing to the event
  49. Use Cases Activity / Fragment Communication Service / Fragment /

    Activity Communication Basic Message Passing between objects in scope Excellent Message Bus
  50. 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
  51. 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
  52. Otto demo

  53. square.github.io/otto/

  54. http-request kevinsawicki.github.com/http-request/ A simple convenience library for using a HttpURLConnection

    to make requests and access the response.
  55. kevinsawicki.github.com/http-request/

  56. kevinsawicki.github.com/http-request/

  57. None
  58. kevinsawicki.github.com/http-request/

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

  60. 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/
  61. woohoo! no more manual json parsing code.google.com/p/google-gson/

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

  63. None
  64. None
  65. REST API

  66. api consumption demo

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

  68. Why is it so fast? - Compile Time Validation -

    Compile Time Code Generation
  69. http://square.github.io/dagger/

  70. 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
  71. Dependencies in the UserListFragment

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

  73. None
  74. dagger demo http://square.github.io/dagger/

  75. view pager indicator viewpagerindicator.com

  76. viewpagerindicator.com

  77. viewpagerindicator.com

  78. viewpagerindicator.com

  79. gradle

  80. None
  81. build process easier to manage

  82. gradle files demo

  83. 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
  84. “its like selenium, but for android” code.google.com/p/robotium

  85. public class EditorTest extends ActivityInstrumentationTestCase2<EditorActivity> { 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
  86. code.google.com/p/robotium

  87. androidbootstrap.com

  88. Generate Your Next Project Gradle - Android Studio - AppCompat

    - NavigationDrawer Maven - IntelliJ - ActionBarSherlock - SlidingMenu androidbootstrap.com alpha.androidbootstrap.com USE THIS ONE
  89. None
  90. 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
  91. uses template for your next project use as a reference

    a how to tutorial project MVP bootstrap androidbootstrap.com
  92. Thank You. DONN FELKER donn@donnfelker.com @donnfelker gplus.to/donnfelker