moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

Redrawing tiles on touch events #40

Closed ghost closed 11 years ago

ghost commented 11 years ago

I noticed that the tiles are not redrawn when dragging or zooming the TileView. Redraw happens only after some time when the touch events stop. Is it possible to enable this, so when I'm dragging the view around or zooming the tiles get updated automatically?

moagrius commented 11 years ago

You can request a render during a drag event, but it'll be performance hit. Both concepts are discussed in #25. The render request is already throttled by 250 milliseconds - you can tweak that if you wish, but again be careful of the work being required of the UI thread.

ghost commented 11 years ago

I'm aware of the performance. I'd like to request render only if the drag distance is over certain limit, e.g. 100dp. However calling requestRender removes the RENDER_FLAG from a handler's message queue and adds a new one after 250ms. Since dragging the view continuously calls onDrag, the requestRender is effectively cancelling the previous requests and happens only 250ms afer thelast onDrag update (e.g. when I stop dragging the view around). Thus I'd have to add another method, e.g. requestRenderNow, that'd do it instantly. I can see there are some more performance issues raising from this approach so I'll reconsider what can be achieved here. Thanks very much for your help.

moagrius commented 11 years ago

FWIW, adding a downsample (the third argument of some addDetailLevel signatures) is the compromise for not rendering during drag/pinch. It's intended to show a low-memory version of the tiled image, scaled. Post back if that's not clear.

Also, I wouldn't necessarily be adverse to adding a "requestRenderNow" (or "requestImmediateRender") method.