From cad5c1ed7bf0e9c7780c5d8f184971023941f85a Mon Sep 17 00:00:00 2001 From: Hannes Janetzek <hannes.janetzek@gmail.com> Date: Tue, 28 Jan 2014 00:32:40 +0100 Subject: [PATCH] cancel tile loading when tile was removed from cache --- vtm/src/org/oscim/layers/tile/BitmapTileLayer.java | 5 +++++ vtm/src/org/oscim/layers/tile/vector/VectorTileLoader.java | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/vtm/src/org/oscim/layers/tile/BitmapTileLayer.java b/vtm/src/org/oscim/layers/tile/BitmapTileLayer.java index 4300b1fc..f0786f3d 100644 --- a/vtm/src/org/oscim/layers/tile/BitmapTileLayer.java +++ b/vtm/src/org/oscim/layers/tile/BitmapTileLayer.java @@ -16,6 +16,8 @@ */ package org.oscim.layers.tile; +import java.util.concurrent.CancellationException; + import org.oscim.backend.canvas.Bitmap; import org.oscim.core.MapElement; import org.oscim.core.MapPosition; @@ -123,6 +125,9 @@ public class BitmapTileLayer extends TileLayer<TileLoader> { @Override public void setTileImage(Bitmap bitmap) { + if (isCanceled() || mTile.state(MapTile.STATE_CANCEL)) + throw new CancellationException(); + BitmapLayer l = new BitmapLayer(false); l.setBitmap(bitmap, Tile.SIZE, Tile.SIZE); mTile.layers = new ElementLayers(); diff --git a/vtm/src/org/oscim/layers/tile/vector/VectorTileLoader.java b/vtm/src/org/oscim/layers/tile/vector/VectorTileLoader.java index 082a67cf..3aadc0b4 100644 --- a/vtm/src/org/oscim/layers/tile/vector/VectorTileLoader.java +++ b/vtm/src/org/oscim/layers/tile/vector/VectorTileLoader.java @@ -136,9 +136,9 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac // query database, which calls 'process' callback result = mTileDataSource.executeQuery(mTile, this); } catch (CancellationException e) { - log.debug("canceled {}", mTile); + log.debug("{} was canceled", mTile); } catch (Exception e) { - log.debug("{}", e); + log.debug("{} {}", mTile, e.getMessage()); } finally { mTile = null; clearState(); @@ -209,10 +209,9 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac @Override public void process(MapElement element) { - clearState(); - if (isCanceled()) + if (isCanceled() || mTile.state(MapTile.STATE_CANCEL)) throw new CancellationException(); mElement = element;