On Sunday, 28 October 2012 07:22:21 UTC, Martin wrote:
Could you give me some hints as to how i'd enable a tile cache on external memory?
If it's straightforward to implement i'd like to do so.
In MapsforgeOSMDroidTileProvider.TileLoader.loadTile we have
@Override
public Drawable loadTile(final MapTileRequestState aState) throws CantContinueException
{
Drawable tile = drawMapsforgeTile(aState);
if(tile == null)
tile = downloadTile(aState);
return tile;
}
So, had off to Mapsforge to render the tile. If Mapsforge failed - no data, out of bounds, etc - we go to the fallback tilesource and download a tile.
You could extend this to something like
@Override
public Drawable loadTile(final MapTileRequestState aState) throws CantContinueException
{
Drawable tile = checkCache(aState);
if(tile != null)
return tile;
tile = drawMapsforgeTile(aState);
if(tile == null)
tile = downloadTile(aState);
if(tile != null)
cacheTile(aState, tile);
return tile;
}
The OSMDroid FileWriter class can handle most of the mechanics of managing the cache, so you just need a bit of glue between the two.
Jez