Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

GTUG Android iglaset Presentation 1 Oct


Published on

Android iglaset slides from Stockolm GTUG presentation, October 1st

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

GTUG Android iglaset Presentation 1 Oct

  1. 1. Johan Nilsson @johanni
  2. 3. STHLM Traveling
  3. 4. <ul><li>&quot;Att surfa till SLs hemsida funkar bättre&quot; </li></ul>&quot;Helt värdelös.&quot; &quot;Saknar bara realtid. Grym annars&quot; &quot;Bra app men behövs bokmärken&quot; &quot;Eftersom programmet inte uppfyller mina basbehov så blir det en etta&quot; &quot;At last. SL mobile site is crummy on Android and this fills a nice gap. I am hoping for the ability to bookmark locations soon&quot;
  4. 5. Help the developer
  5. 6. Search in one of Swedens largest liquor databases with comments and ratings.
  6. 7. <ul><ul><li>Demo </li></ul></ul><ul><ul><li>Passing data between activities </li></ul></ul><ul><ul><li>Custom list adapters </li></ul></ul><ul><ul><li>Handling screen rotation </li></ul></ul><ul><ul><li>Some links </li></ul></ul>
  7. 8. Demo  
  8. 9. Passing data between activities <ul><li>Non-Persistent Objects </li></ul><ul><ul><li>The class </li></ul></ul><ul><ul><li>A public static field/method </li></ul></ul><ul><ul><li>A HashMap of WeakReferences to Objects </li></ul></ul><ul><ul><li>A Singleton class </li></ul></ul><ul><li>  </li></ul><ul><li>Persistent Objects </li></ul><ul><li>  </li></ul><ul><ul><li>Application Preferences </li></ul></ul><ul><ul><li>Files </li></ul></ul><ul><ul><li>contentProviders </li></ul></ul><ul><ul><li>SQLite DB </li></ul></ul><ul><li>  </li></ul>
  9. 10. Using public static can get kinda messy, not that easy to call RouteDetailActivity from another activity <ul><li>/** </li></ul><ul><li>* Holds the current selected route, this is referenced by </li></ul><ul><li>* RouteDetailActivity. </li></ul><ul><li>*/ </li></ul><ul><li>public static Route route; </li></ul>
  10. 11. Primitive Data Types <ul><li>intent.putExtra(&quot;com.markupartist.iglaset.drinkId&quot;, drinkId); </li></ul>
  11. 12. Using Parcelable, we can send more complex objects <ul><li>   </li></ul>intent.putExtra(&quot;com.markupartist.iglaset.drink&quot;, drink);  
  12. 13. List Adapters  
  13. 14. SectionedListAdapter Idea by Jeff Sharkey Refactored version at
  14. 15. SectionedListAdapter
  15. 16. MultipleListAdapter mMultipleAdapter = new MultipleListAdapter(); mMultipleAdapter.addAdapter(ADAPTER_FIRST, mFirstAdater); mMultipleAdapter.addAdapter(ADAPTER_SECOND, mSecondAdapter); mMultipleAdapter.addAdapter(ADAPTER_THIRD, mThirdAdapter);
  16. 17. MultipleListAdapter
  17. 18. Paginating Adapter
  18. 19. Screen rotation When switching from portrait to landscape mode or vice-versa, the activity's onDestroy() and onCreate() will be called Rotate the emulator by pressing Ctrl + F12
  19. 20. onRetainNonConfigurationInstance @Override public Object onRetainNonConfigurationInstance() {     return mDrinks; }   @Override public void onCreate(Bundle savedInstanceState) {      final ArrayList<Drink> data = (ArrayList<Drink>)                                            getLastNonConfigurationInstance(); } <ul><ul><li>If it is expensive to serialize </li></ul></ul><ul><ul><li>If you can not serialize, network connections </li></ul></ul>
  20. 21. onSaveInstanceState @Override protected void onSaveInstanceState(Bundle bundle) {     bundle.putParcelableArrayList(&quot;drinks&quot;, mDrinks); } @Override public void onCreate(Bundle savedInstanceState) {     ArrayList<Drink> data = null;     if (savedInstanceState != null) {         data = savedInstanceState.getParcelableArrayList(&quot;drinks&quot;);     } } <ul><ul><li>If you need to save several objects </li></ul></ul><ul><li>  </li></ul><ul><li>Might also be called in other cases (when the activity is closed because of low memory) </li></ul>
  21. 22. Some links <ul><ul><li>ImageLoader </li></ul></ul><ul><ul><li>Shelves </li></ul></ul><ul><ul><li>CommonsWare   </li></ul></ul><ul><ul><li>Color debugging </li></ul></ul><ul><ul><li>Swedroid   </li></ul></ul>
  22. 23. Thank you [email_address] @johanni See you at the Android Hackathon at bwin 28/11