cancel tile loading when tile was removed from cache
This commit is contained in:
parent
3543b71671
commit
cad5c1ed7b
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.layers.tile;
|
package org.oscim.layers.tile;
|
||||||
|
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Bitmap;
|
import org.oscim.backend.canvas.Bitmap;
|
||||||
import org.oscim.core.MapElement;
|
import org.oscim.core.MapElement;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
@ -123,6 +125,9 @@ public class BitmapTileLayer extends TileLayer<TileLoader> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTileImage(Bitmap bitmap) {
|
public void setTileImage(Bitmap bitmap) {
|
||||||
|
if (isCanceled() || mTile.state(MapTile.STATE_CANCEL))
|
||||||
|
throw new CancellationException();
|
||||||
|
|
||||||
BitmapLayer l = new BitmapLayer(false);
|
BitmapLayer l = new BitmapLayer(false);
|
||||||
l.setBitmap(bitmap, Tile.SIZE, Tile.SIZE);
|
l.setBitmap(bitmap, Tile.SIZE, Tile.SIZE);
|
||||||
mTile.layers = new ElementLayers();
|
mTile.layers = new ElementLayers();
|
||||||
|
@ -136,9 +136,9 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
// query database, which calls 'process' callback
|
// query database, which calls 'process' callback
|
||||||
result = mTileDataSource.executeQuery(mTile, this);
|
result = mTileDataSource.executeQuery(mTile, this);
|
||||||
} catch (CancellationException e) {
|
} catch (CancellationException e) {
|
||||||
log.debug("canceled {}", mTile);
|
log.debug("{} was canceled", mTile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug("{}", e);
|
log.debug("{} {}", mTile, e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
mTile = null;
|
mTile = null;
|
||||||
clearState();
|
clearState();
|
||||||
@ -209,10 +209,9 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(MapElement element) {
|
public void process(MapElement element) {
|
||||||
|
|
||||||
clearState();
|
clearState();
|
||||||
|
|
||||||
if (isCanceled())
|
if (isCanceled() || mTile.state(MapTile.STATE_CANCEL))
|
||||||
throw new CancellationException();
|
throw new CancellationException();
|
||||||
|
|
||||||
mElement = element;
|
mElement = element;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user