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