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.

Building TimePiece

1,660 views

Published on

Code and patterns from building TimePiece: an Android World Clock application released under the Open Source MIT license. The talk was given at the Philly Android Alliance User Group meeting on 8/24

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

Building TimePiece

  1. 1. Building TimePiece<br />Arpit Mathur<br />http://twitter.com/arpit<br />
  2. 2. What is TimePiece<br />World Time lookup without API calls<br />Visually interesting (fun with animation)<br />Open Source (under the MIT license)<br />
  3. 3. Technical breakdown<br />Local SQLite database with City / Java TimeZone Id mappings<br />JODA DateTime library<br />Search<br />Custom List Renderers<br />The usual app stuff:<br />User Preferences<br />Menus<br />Intro screens<br />Context menus<br />
  4. 4. Implementing ContentProviders with local SQLite databases<br />
  5. 5. Steps<br />Add SQLite to your assets folder<br />Copy the database to your app’s data folder<br />Open the database (extend SQLiteOpenHelper)<br />Create a ContentProvider from this Database<br />
  6. 6. Code:<br />DataBaseHelper<br />TimeZoneLookupService<br />CitySearchSuggestionProvider<br />
  7. 7. Create a searchable config xml file<br />Create an Activity to handle the search<br />Add the Search config and activity to the activity that you want to trigger search on<br />Implementing Search<br />
  8. 8. Search config (in res/xml)<br />
  9. 9. Search Activity<br />
  10. 10. Integrate with Main Activity<br />
  11. 11. Mind the stacks!<br />Activity LaunchModesdeclared in Activity:<br />multiple<br />singleTop<br />singleTask<br />singleInstance<br />
  12. 12. Replacing the Activity with Suggestions<br />res/searchable.xml<br />CitySearchSuggestionProvider<br />
  13. 13. Return format<br />
  14. 14. Building Custom Lists<br />Create a List View or a ListActivity<br />Create an Adapter for populating the List<br />Populate the List Adapter<br />Refresh the Adapter every 60 seconds<br />
  15. 15. Code<br />MyLocationsActivity<br />MyLocationsDataAdapter<br />
  16. 16. A little deeper into Animation<br />
  17. 17. Loading Animation XMLs<br />
  18. 18. Creating animation objects at runtime<br />
  19. 19. Creating custom animations<br />Extend Animation<br />Override applyTransform<br />
  20. 20.
  21. 21. Remember: <br />Animations only effect the rendering buffers so objects don’t actually change in position itself<br />If you don’t set setFillAfter, the animated object will return to its location/transformation as before animation started <br />Leverage LayoutAnimations as well as regular animations<br />
  22. 22. Releasing to the Market<br />Use Android Asset Studio to create your icons<br />Broken Market search: Joining words is probably a bad idea<br />When adding images to your app’s description, make sure the first one is most representative (for third party market indexers like Chomp)<br />
  23. 23. Links<br />TimePiece:<br />https://market.android.com/details?id=com.arpitonline.worldclock<br />Packing local SQLite databases:<br />http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/<br />Android Asset Studio:<br />http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html<br />

×