I've made several improvements/bug fixes to the R-Line application. Here's some noteworthy changes:
I've changed my ItemizedOverlay for the moving buses to return false for draw(). I previously had it return true to force the maps API to redraw the overlays. The API docs tout this as a way to "animate" the layer. Unfortunately, this creates continuous drawing and high cpu usage. Instead, I created another listener to my data service to call the postInvalidate() on the MapView. This forces the map to redraw the overlays whenever new data is downloaded.
Also, within my ItemizedOverlay, I added some synchronizing to the data collection storing the buses. Inside draw(), we can't see it, but it's iterating over the collection. It's possible to call createItem(int i) on an item that no longer exists. This created a rare force close when panning/zooming the map and an overlay item disappeared. Using a Collections.synchronizedList() call to create a synchronized List was not enough. Instead I added some synchronizations to draw() and the method where I update the collection.
Monday, February 15, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment