Issue
I'm implementing a lazy drawing of overlays based on the user's current viewing rectangle. The viewing rectangle gets initialized based on the dimensions of the mapview as follows:
Rect viewRectangle = new Rect(0, 0, mapView.getWidth(), mapView.getHeight());
Through debugging, the width and height of the mapview remain constant (except when there's an orientation change) except for the initial creation of the mapview where the dimensions (width and height) are zero.
Unfortunately, despite my attempts at holding off initialization until all of the other UI components have been created, I can't seem to find the proper place for the creation of the viewing rectangle. I do not want to place the initialization within the drawing of my overlays because it seems theoretically inefficient (with the allocation overhead and potentially triggering garbage collection) to create those temporary objects for every lazy-drawing call (triggered by zooming, panning, and RESTful data refreshes).
Is there a listener that gets triggered when the dimensions of the mapview are changed from their zero state? I've tried a multitude of different searches to find an answer and searched through android documentation, to no avail.
Any information is appreciated. Thanks in advance.
Solution
I ended up doing this in the ondraw for the overlay.
I also checked out different methods, but never found a good solution.
Best to add a boolean check to only execute the code once. Do keep track of orientation changes...
Answered By - Ophidian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.