public abstract class MapTileProviderBase extends Object implements IMapTileProviderCallback
MapTileIndex
for an overview of how tiles are served by this provider.Modifier and Type | Field and Description |
---|---|
static int |
MAPTILE_FAIL_ID |
static int |
MAPTILE_SUCCESS_ID |
protected MapTileCache |
mTileCache |
protected Drawable |
mTileNotFoundImage |
protected boolean |
mUseDataConnection |
Constructor and Description |
---|
MapTileProviderBase(ITileSource pTileSource) |
MapTileProviderBase(ITileSource pTileSource,
Handler pDownloadFinishedListener) |
Modifier and Type | Method and Description |
---|---|
void |
clearTileCache()
purges the cache of all tiles (default is the in memory cache)
|
MapTileCache |
createTileCache()
Creates a
MapTileCache to be used to cache tiles in memory. |
void |
detach()
classes that extend MapTileProviderBase must call this method to prevent memory leaks.
|
void |
ensureCapacity(int pCapacity) |
void |
expireInMemoryCache(long pMapTileIndex)
Expire a tile that is in the memory cache
Typical use is for mapsforge, where the contents of the tile can evolve,
depending on the neighboring tiles that have been displayed so far.
|
abstract Drawable |
getMapTile(long pMapTileIndex)
Attempts to get a Drawable that represents a
MapTileIndex . |
abstract int |
getMaximumZoomLevel()
Gets the maximum zoom level this tile provider can provide
|
abstract int |
getMinimumZoomLevel()
Gets the minimum zoom level this tile provider can provide
|
abstract long |
getQueueSize() |
MapTileCache |
getTileCache() |
Collection<Handler> |
getTileRequestCompleteHandlers() |
ITileSource |
getTileSource()
Gets the tile source for this tile provider.
|
abstract IFilesystemCache |
getTileWriter() |
void |
mapTileRequestCompleted(MapTileRequestState pState,
Drawable pDrawable)
Called by implementation class methods indicating that they have completed the request as
best it can.
|
void |
mapTileRequestExpiredTile(MapTileRequestState pState,
Drawable pDrawable)
Called by implementation class methods indicating that they have produced an expired result
that can be used but better results may be delivered later.
|
void |
mapTileRequestFailed(MapTileRequestState pState)
Called by implementation class methods indicating that they have failed to retrieve the
requested map tile.
|
void |
mapTileRequestFailedExceedsMaxQueueSize(MapTileRequestState pState)
Called by implementation class methods indicating that they have failed to retrieve the
requested map tile, because the max queue size has been reached
|
protected void |
putExpiredTileIntoCache(MapTileRequestState pState,
Drawable pDrawable)
Deprecated.
Use
putTileIntoCache(long, Drawable, int) } instead |
protected void |
putTileIntoCache(long pMapTileIndex,
Drawable pDrawable,
int pState) |
void |
rescaleCache(Projection pProjection,
double pNewZoomLevel,
double pOldZoomLevel,
Rect pViewPort)
Recreate the cache using scaled versions of the tiles currently in it
|
static void |
setApproximationBackgroundColor(int pColor)
Sets the default color for approximated tiles.
|
void |
setTileLoadFailureImage(Drawable drawable)
Sets the "sorry we can't load a tile for this location" image.
|
void |
setTileRequestCompleteHandler(Handler handler)
Deprecated.
Use
getTileRequestCompleteHandlers() instead |
void |
setTileSource(ITileSource pTileSource)
Sets the tile source for this tile provider.
|
void |
setUseDataConnection(boolean pMode)
Set whether to use the network connection if it's available.
|
boolean |
useDataConnection()
Whether to use the network connection if it's available.
|
public static final int MAPTILE_SUCCESS_ID
public static final int MAPTILE_FAIL_ID
protected final MapTileCache mTileCache
protected boolean mUseDataConnection
protected Drawable mTileNotFoundImage
public MapTileProviderBase(ITileSource pTileSource)
public MapTileProviderBase(ITileSource pTileSource, Handler pDownloadFinishedListener)
public abstract Drawable getMapTile(long pMapTileIndex)
MapTileIndex
. If the tile is not immediately
available this will return null and attempt to get the tile from known tile sources for
subsequent future requests. Note that this may return a ReusableBitmapDrawable
in
which case you should follow proper handling procedures for using that Drawable or it may
reused while you are working with it.ReusableBitmapDrawable
public void detach()
public static void setApproximationBackgroundColor(int pColor)
pColor
- the default color that will be shown for approximated tilespublic abstract int getMinimumZoomLevel()
public abstract int getMaximumZoomLevel()
public void setTileSource(ITileSource pTileSource)
pTileSource
- the tile sourcepublic ITileSource getTileSource()
public MapTileCache createTileCache()
MapTileCache
to be used to cache tiles in memory.public void setTileLoadFailureImage(Drawable drawable)
TilesOverlay.setLoadingLineColor(int)
and
TilesOverlay.setLoadingBackgroundColor(int)
drawable
- public void mapTileRequestCompleted(MapTileRequestState pState, Drawable pDrawable)
mapTileRequestCompleted
in interface IMapTileProviderCallback
pState
- the map tile request state objectpDrawable
- the Drawable of the map tilepublic void mapTileRequestFailed(MapTileRequestState pState)
mapTileRequestFailed
in interface IMapTileProviderCallback
pState
- the map tile request state objectpublic void mapTileRequestFailedExceedsMaxQueueSize(MapTileRequestState pState)
mapTileRequestFailedExceedsMaxQueueSize
in interface IMapTileProviderCallback
pState
- the map tile request state objectpublic void mapTileRequestExpiredTile(MapTileRequestState pState, Drawable pDrawable)
mapTileRequestExpiredTile
in interface IMapTileProviderCallback
pState
- the map tile request state objectpDrawable
- the Drawable of the map tileprotected void putTileIntoCache(long pMapTileIndex, Drawable pDrawable, int pState)
@Deprecated protected void putExpiredTileIntoCache(MapTileRequestState pState, Drawable pDrawable)
putTileIntoCache(long, Drawable, int)
} instead@Deprecated public void setTileRequestCompleteHandler(Handler handler)
getTileRequestCompleteHandlers()
insteadpublic Collection<Handler> getTileRequestCompleteHandlers()
public void ensureCapacity(int pCapacity)
public MapTileCache getTileCache()
public void clearTileCache()
public boolean useDataConnection()
useDataConnection
in interface IMapTileProviderCallback
public void setUseDataConnection(boolean pMode)
pMode
- if true use the network connection if it's available. if false don't use the
network connection even if it's available.public void rescaleCache(Projection pProjection, double pNewZoomLevel, double pOldZoomLevel, Rect pViewPort)
pNewZoomLevel
- the zoom level that we need nowpOldZoomLevel
- the previous zoom level that we should get the tiles to rescalepViewPort
- the view port we need tiles forpublic abstract IFilesystemCache getTileWriter()
public abstract long getQueueSize()
public void expireInMemoryCache(long pMapTileIndex)