Building TimePiece
-
Upload
arpit-mathur -
Category
Technology
-
view
1.473 -
download
0
description
Transcript of Building TimePiece
![Page 2: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/2.jpg)
What is TimePiece
• World Time lookup without API calls
• Visually interesting (fun with animation)
• Open Source (under the MIT license)
![Page 3: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/3.jpg)
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
![Page 4: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/4.jpg)
Implementing ContentProviders with local SQLite databases
![Page 5: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/5.jpg)
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
![Page 6: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/6.jpg)
Code:
• DataBaseHelper• TimeZoneLookupService• CitySearchSuggestionProvider
![Page 7: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/7.jpg)
• 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
![Page 8: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/8.jpg)
Search config (in res/xml)
![Page 9: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/9.jpg)
Search Activity
![Page 10: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/10.jpg)
Integrate with Main Activity
![Page 11: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/11.jpg)
Mind the stacks!
• Activity LaunchModes declared in Activity:–multiple– singleTop– singleTask– singleInstance
![Page 12: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/12.jpg)
Replacing the Activity with Suggestions
CitySearchSuggestionProvider
res/searchable.xml
![Page 13: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/13.jpg)
Return format
![Page 14: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/14.jpg)
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
![Page 15: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/15.jpg)
Code
• MyLocationsActivity• MyLocationsDataAdapter
![Page 16: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/16.jpg)
A little deeper into Animation
![Page 17: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/17.jpg)
Loading Animation XMLs
![Page 18: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/18.jpg)
Creating animation objects at runtime
![Page 19: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/19.jpg)
Creating custom animations
• Extend Animation• Override applyTransform
![Page 20: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/20.jpg)
![Page 21: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/21.jpg)
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
![Page 22: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/22.jpg)
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)
![Page 23: Building TimePiece](https://reader035.fdocuments.us/reader035/viewer/2022062405/554f8343b4c905435d8b4ac8/html5/thumbnails/23.jpg)
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