make TileLayer abstract and create TileLoaders in subclass
This commit is contained in:
parent
78f05992f4
commit
34065efb93
@ -44,11 +44,12 @@ public class MapTileLayer extends TileLayer<MapTileLoader> {
|
|||||||
private final static String TAG = MapTileLayer.class.getName();
|
private final static String TAG = MapTileLayer.class.getName();
|
||||||
|
|
||||||
public MapTileLayer(MapView mapView) {
|
public MapTileLayer(MapView mapView) {
|
||||||
super(mapView, new TileLoader.Factory<MapTileLoader>(){
|
super(mapView);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapTileLoader create(JobQueue q, TileManager tm) {
|
protected MapTileLoader createLoader(JobQueue q, TileManager tm) {
|
||||||
return new MapTileLoader(q, tm);
|
return new MapTileLoader(q, tm);
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MapOptions mMapOptions;
|
private MapOptions mMapOptions;
|
||||||
|
|||||||
@ -30,12 +30,12 @@ public class TestTileLayer extends TileLayer<TestTileLoader> {
|
|||||||
final static String TAG = TestTileLayer.class.getName();
|
final static String TAG = TestTileLayer.class.getName();
|
||||||
|
|
||||||
public TestTileLayer(MapView mapView) {
|
public TestTileLayer(MapView mapView) {
|
||||||
// create an TileLayer instance using TestTileLoader as TileLoader
|
super(mapView);
|
||||||
super(mapView, new TileLoader.Factory<TestTileLoader>(){
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestTileLoader create(JobQueue q, TileManager tm) {
|
protected TestTileLoader createLoader(JobQueue q, TileManager tm) {
|
||||||
return new TestTileLoader(q, tm);
|
return new TestTileLoader(q, tm);
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TestTileLoader extends TileLoader {
|
static class TestTileLoader extends TileLoader {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import org.oscim.core.MapPosition;
|
|||||||
import org.oscim.layers.Layer;
|
import org.oscim.layers.Layer;
|
||||||
import org.oscim.view.MapView;
|
import org.oscim.view.MapView;
|
||||||
|
|
||||||
public class TileLayer<T extends TileLoader> extends Layer {
|
public abstract class TileLayer<T extends TileLoader> extends Layer {
|
||||||
//private final static String TAG = TileLayer.class.getName();
|
//private final static String TAG = TileLayer.class.getName();
|
||||||
|
|
||||||
private boolean mClearMap = true;
|
private boolean mClearMap = true;
|
||||||
@ -32,7 +32,7 @@ public class TileLayer<T extends TileLoader> extends Layer {
|
|||||||
protected final int mNumTileLoader = 4;
|
protected final int mNumTileLoader = 4;
|
||||||
protected final ArrayList<T> mTileLoader;
|
protected final ArrayList<T> mTileLoader;
|
||||||
|
|
||||||
public TileLayer(MapView mapView, TileLoader.Factory<T> factory) {
|
public TileLayer(MapView mapView) {
|
||||||
super(mapView);
|
super(mapView);
|
||||||
|
|
||||||
// TileManager responsible for adding visible tiles
|
// TileManager responsible for adding visible tiles
|
||||||
@ -44,7 +44,7 @@ public class TileLayer<T extends TileLoader> extends Layer {
|
|||||||
// Instantiate TileLoader threads
|
// Instantiate TileLoader threads
|
||||||
mTileLoader = new ArrayList<T>();
|
mTileLoader = new ArrayList<T>();
|
||||||
for (int i = 0; i < mNumTileLoader; i++) {
|
for (int i = 0; i < mNumTileLoader; i++) {
|
||||||
T tileGenerator = factory.create(mJobQueue, mTileManager);
|
T tileGenerator = createLoader(mJobQueue, mTileManager);
|
||||||
mTileLoader.add(tileGenerator);
|
mTileLoader.add(tileGenerator);
|
||||||
tileGenerator.start();
|
tileGenerator.start();
|
||||||
}
|
}
|
||||||
@ -54,6 +54,8 @@ public class TileLayer<T extends TileLoader> extends Layer {
|
|||||||
mLayer = new TileRenderLayer(mapView, mTileManager);
|
mLayer = new TileRenderLayer(mapView, mTileManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract protected T createLoader(JobQueue q, TileManager tm);
|
||||||
|
|
||||||
public TileRenderLayer getTileLayer() {
|
public TileRenderLayer getTileLayer() {
|
||||||
return (TileRenderLayer) mLayer;
|
return (TileRenderLayer) mLayer;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user