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;
|
||||
|
||||
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();
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user