moagrius/MapView — pull request #46 by aadnk (2013-04-30 17:20:02+00:00)
Title: Added support for customzing the data source of the downsample bitmap

I don't know if you were planing on adding this yourself, but I figured I might as well take a shot.

The simplest and probably most consistent metod is to reuse MapTileDecoder for this purpose, using a "setDownsampeDecoder" method in MapView. It's a bit wierd for a tile decoder to be used in this manner, but it doesn't have any specific knowledge about tiles or zoom levels. Perhaps the interface really should have been called BitmapLoader?

In fact, it might have been better if the MapTileDecoder interface had been written like so:
```java
public interface MapTileDecoder {
public Bitmap decode(ZoomLevel level, int row, int column,
Context context);
}
```
And then the default tile decoder would be a AssetTileDecoder that delegates to a AssetLoader with a signature similar to today's MapTileDecoder:
```java
public class AssetTileDecoder implements MapTileDecoder {
public AssetTileDecoder(AssetLoader loader) ...

// Every %col% and %row% in the given path is processed as now
public registerZoomLevel(ZoomLevel level, String path) ...

public Bitmap decode(ZoomLevel level, int row, int column, Context context) {
String path = formatMap(getFormatFromLevel(level), row, column);
return loader.decode(path, context);
}
}

public interface AssetLoader {
public Bitmap decode(String asset, Context context);
}
````
This rewritten MapTileDecoder would have been useful for me when I implemented a Tile Decoder that reads tiles directly from a large PNG file on disk (using BitmapRegionDecoder), but it's still possible currently - I just had to parse the string to get the zoom level, row and column index.