The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

mejohnsn (22) [Avatar] Offline
#1
Well, to be fully honest, I don't remember whether I downloaded the source code for WindWaves from a location for Unlocking Android or for Android in Action, but the code seems awfully similar: I haven't seen a difference in the code provided in the text of Chapter 11 itself yet. But the problem is that after doing the build on that code, I get something that runs, it shows the OverlayItems for the buoys, it shows the Toast announcing getting buoy data, but I get no response to taps or touch events. I verified this by putting Log.d() statements in both the onTap() method and the onTouchEvent() method in BuoyItemizedOverlay.

The only changes I made to the code downloaded are: 1) comments 2) call to boundCenterBottom() in ItemizedOverlay's constructor 3) changed minTime=60000mS in MapViewActivity's onStart(). And it failed before adding boundCenterBottom(), too. In fact, it failed before I had made any changes other than comments.

Now no matter what the proper resolution to this is, it raises a question that would be good to discuss in the text: what causes the Overlay to get/lose focus?

Another good thing to discuss a little more: when must populate() be called? Is it after each Overlay added, or after each OverlayItem? The HelloGoogleMaps tutorial is annoyingly vague on this point, appearing to mean the one at one time, and the other at another; I could get it to work (using APIlevel 8 and google_apis-3) only after modifying the code to call populate() after each OverlayItem added.

I suppose it might help to add: the fetcher really does return data from NDBC, I get the following (among many others!) in the logcat output:

I/WindWaves( 406smilie: NDBCFetcher query - http://www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=37.88N&lon=122.26W&radius=100
D/WindWaves( 406smilie: MapViewActivity fetcher start
D/WindWaves( 406smilie: NDBCHandler NDBCHandler instantiated
D/WindWaves( 406smilie: MapViewActivity fetcher finish - duration = 2635mS
D/WindWaves( 406smilie: MapViewActivity buoyDataList size = 27

After that I see many lines like:
D/WindWaves( 406smilie: got to BOI createItem

(BOI is abbrev for BuoyOverlayItem) and then silence. So I assume the PC is somewhere in Android System, waiting for the appropriate event to bounce the PC back into MapActivity or BuoyOverlayItem; but this never happens.

BTW: this might be a hint: NDBC returns 27 items, but I only see 8 Buoy markers on the screen. What does WindWaves do with markers that go off the map?
mejohnsn (22) [Avatar] Offline
#2
Re: Ch 11 Source Code -- WindWaves never gets to onTap() method
I just figured out the answer to my own question: somehow, probably while editing out the book's map key and replacing with my own, the key attribute 'android:clickable="true"' was omitted from mapview_activity.xml. Once I restored this, it worked.