Tiles outside the image are created
See original GitHub issueI’ve noticed that sometimes a row or column is set on a tile that is outside of the image’s bounds. This originates from TileView.computeAndRenderTilesInViewport()
: the grid is too large. This affects the Tile.mDestinationRect
. Later in Tile.decode()
, this same row and column is used to render a tile with mStreamProvider.getStream()
. Is there a reason why these non-existing tiles are rendered?
The problem that I’m experiencing is that in my project the tiles are loaded with http requests, and our client’s server returns white tiles for invalid coordinates. True, this is just a bad design and the server should return an error or empty stream, but maybe other people have issues with this as well.
Thank you for maintaining this library the way you do and always being quick to answer, I appreciate it.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
I think I got it but I’m not sure if it will cover all cases. It seemed to fix it for me in a layout where the image is centered in the TileView and where the scaling starts at a ‘fitCenter’ state:
tileView.setMinimumScaleMode(ScalingScrollView.MinimumScaleMode.CONTAIN) tileView.setScaleLimits(0f, 2f)
When changing the
TileView.updateViewport()
frommViewport.right = mViewport.left + getMeasuredWidth(); mViewport.bottom = mViewport.top + getMeasuredHeight();
to
mViewport.right = mViewport.left + Math.min(getMeasuredWidth(), getScaledWidth()); mViewport.bottom = mViewport.top + Math.min(getMeasuredHeight(), getScaledHeight());
just the right amount of rows and columns are created.
I do not know what else will be affected by this however.
This is awesome! Thanks so much for digging in. I may need to make some minor tweaks but this looks very promising - I’ll try to get his verified (and committed, hopefully) as soon as I get some time (I’ll shoot for Mon-Tues of next week - gone all weekend).
Thanks again! Nice open source-ery 😉