GTUG Android iglaset Presentation 1 Oct
-
Upload
johan-nilsson -
Category
Technology
-
view
1.016 -
download
2
description
Transcript of GTUG Android iglaset Presentation 1 Oct
![Page 2: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/2.jpg)
![Page 3: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/3.jpg)
STHLM Traveling
http://markupartist.com/sthlmtraveling/
![Page 4: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/4.jpg)
"Att surfa till SLs hemsida funkar bättre"
"Helt värdelös."
"Saknar bara realtid. Grym annars"
"Bra app men behövs bokmärken"
"Eftersom programmet inte uppfyller mina basbehov så blir det en etta"
"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"
![Page 5: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/5.jpg)
Help the developer
http://www.cyrket.com/package/com.xtralogic.android.logcollector
![Page 6: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/6.jpg)
Search in one of Swedens largest liquor databases iglaset.se with comments and ratings.
![Page 7: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/7.jpg)
• Demo • Passing data between activities• Custom list adapters• Handling screen rotation• Some links
![Page 8: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/8.jpg)
Demo
![Page 9: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/9.jpg)
Passing data between activitiesNon-Persistent Objects
• The android.app.Application class• A public static field/method• A HashMap of WeakReferences to Objects• A Singleton class
Persistent Objects • Application Preferences• Files• contentProviders• SQLite DB
http://developer.android.com/intl/zh-CN/guide/appendix/faq/framework.html#3
![Page 10: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/10.jpg)
Using public static can get kinda messy, not that easy to call RouteDetailActivity from another activity
/*** Holds the current selected route, this is referenced by * RouteDetailActivity.*/public static Route route;
![Page 11: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/11.jpg)
Primitive Data Types
intent.putExtra("com.markupartist.iglaset.drinkId", drinkId);
![Page 12: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/12.jpg)
Using Parcelable, we can send more complex objects
http://github.com/johannilsson/iglaset/blob/master/src/com/markupartist/iglaset/provider/Drink.java#L9
intent.putExtra("com.markupartist.iglaset.drink", drink);
![Page 13: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/13.jpg)
List Adapters
![Page 14: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/14.jpg)
SectionedListAdapter
Idea by Jeff Sharkey http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/
Refactored version at
http://github.com/commonsguy/cw-advandroid/blob/master/ListView/Sections/src/com/commonsware/android/listview/SectionedAdapter.java
![Page 15: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/15.jpg)
SectionedListAdapter
![Page 16: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/16.jpg)
MultipleListAdapter
http://github.com/johannilsson/sthlmtraveling/blob/master/src/com/markupartist/sthlmtraveling/MultipleListAdapter.java
mMultipleAdapter = new MultipleListAdapter();mMultipleAdapter.addAdapter(ADAPTER_FIRST, mFirstAdater);mMultipleAdapter.addAdapter(ADAPTER_SECOND, mSecondAdapter);mMultipleAdapter.addAdapter(ADAPTER_THIRD, mThirdAdapter);
![Page 17: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/17.jpg)
MultipleListAdapter
![Page 18: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/18.jpg)
Paginating Adapter
http://github.com/johannilsson/iglaset/blob/master/src/com/markupartist/iglaset/activity/SearchResultActivity.java#L161
![Page 19: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/19.jpg)
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
![Page 20: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/20.jpg)
onRetainNonConfigurationInstance
@Overridepublic Object onRetainNonConfigurationInstance() { return mDrinks;} @Overridepublic void onCreate(Bundle savedInstanceState) { final ArrayList<Drink> data = (ArrayList<Drink>) getLastNonConfigurationInstance();}
• If it is expensive to serialize• If you can not serialize, network
connections
![Page 21: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/21.jpg)
onSaveInstanceState
@Overrideprotected void onSaveInstanceState(Bundle bundle) { bundle.putParcelableArrayList("drinks", mDrinks);}@Overridepublic void onCreate(Bundle savedInstanceState) { ArrayList<Drink> data = null; if (savedInstanceState != null) { data = savedInstanceState.getParcelableArrayList("drinks"); }}
• If you need to save several objects Might also be called in other cases (when the activity is closed because of low memory)
![Page 22: GTUG Android iglaset Presentation 1 Oct](https://reader031.fdocuments.net/reader031/viewer/2022020122/55549b8eb4c90502618b4701/html5/thumbnails/22.jpg)
Some links
• ImageLoaderhttp://wu-media.com/2009/06/android-imageloader-load-images-sequencially-in-the-background/
• Shelveshttp://code.google.com/p/shelves/
• CommonsWarehttp://commonsware.com/AdvAndroid/index.html
• Color debugginghttp://jsharkey.org/blog/2009/04/22/modifying-the-android-logcat-stream-for-full-color-debugging/
• Swedroidhttp://swedroid.se/