本文整理汇总了Java中org.osmdroid.tileprovider.MapTileRequestState类的典型用法代码示例。如果您正苦于以下问题:Java MapTileRequestState类的具体用法?Java MapTileRequestState怎么用?Java MapTileRequestState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapTileRequestState类属于org.osmdroid.tileprovider包,在下文中一共展示了MapTileRequestState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadMapTileAsync
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
public void loadMapTileAsync(final MapTileRequestState pState) {
// Make sure we're not detached
if (mExecutor.isShutdown())
return;
synchronized (mQueueLockObject) {
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"MapTileModuleProviderBase.loadMaptileAsync() on provider: "
+ getName() + " for tile: " + pState.getMapTile());
if (mPending.containsKey(pState.getMapTile()))
Log.d(IMapView.LOGTAG,"MapTileModuleProviderBase.loadMaptileAsync() tile already exists in request queue for modular provider. Moving to front of queue.");
else
Log.d(IMapView.LOGTAG,"MapTileModuleProviderBase.loadMaptileAsync() adding tile to request queue for modular provider.");
}
// this will put the tile in the queue, or move it to the front of
// the queue if it's already present
mPending.put(pState.getMapTile(), pState);
}
try {
mExecutor.execute(getTileLoader());
} catch (final RejectedExecutionException e) {
Log.w(IMapView.LOGTAG,"RejectedExecutionException", e);
}
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:26,代码来源:MapTileModuleProviderBase.java
示例2: mapTileRequestExpiredTile
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
@Override
public void mapTileRequestExpiredTile(MapTileRequestState aState, Drawable aDrawable) {
// Call through to the super first so aState.getCurrentProvider() still contains the proper
// provider.
super.mapTileRequestExpiredTile(aState, aDrawable);
// Continue through the provider chain
final MapTileModuleProviderBase nextProvider = findNextAppropriateProvider(aState);
if (nextProvider != null) {
nextProvider.loadMapTileAsync(aState);
} else {
//synchronized (mWorking) {
mWorking.remove(aState.getMapTile());
//}
}
}
开发者ID:gabuzomeu,项目名称:osmLib,代码行数:17,代码来源:MapTileProviderArrayTTbox.java
示例3: findNextAppropriateProvider
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
/**
* We want to not use a provider that doesn't exist anymore in the chain, and we want to not use
* a provider that requires a data connection when one is not available.
*/
protected MapTileModuleProviderBase findNextAppropriateProvider(final MapTileRequestState aState) {
MapTileModuleProviderBase provider = null;
boolean providerDoesntExist = false, providerCantGetDataConnection = false, providerCantServiceZoomlevel = false;
// The logic of the while statement is
// "Keep looping until you get null, or a provider that still exists
// and has a data connection if it needs one and can service the zoom level,"
do {
provider = aState.getNextProvider();
// Perform some checks to see if we can use this provider
// If any of these are true, then that disqualifies the provider for this tile request.
if (provider != null) {
providerDoesntExist = !this.getProviderExists(provider);
providerCantGetDataConnection = !useDataConnection()
&& provider.getUsesDataConnection();
int zoomLevel = aState.getMapTile().getZoomLevel();
providerCantServiceZoomlevel = zoomLevel > provider.getMaximumZoomLevel()
|| zoomLevel < provider.getMinimumZoomLevel();
}
} while ((provider != null)
&& (providerDoesntExist || providerCantGetDataConnection || providerCantServiceZoomlevel));
return provider;
}
开发者ID:gabuzomeu,项目名称:osmLib,代码行数:27,代码来源:MapTileProviderArrayTTbox.java
示例4: drawMapsforgeTile
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
private Drawable drawMapsforgeTile(final MapTileRequestState aState) {
if (tileSource_ == null) return null;
try {
final MapTile tile = aState.getMapTile();
return tileSource_.getDrawable(tile.getX(), tile.getY(), tile.getZoomLevel());
} catch (Exception e) {
return null;
}
}
开发者ID:yuviii,项目名称:OfflineMap,代码行数:10,代码来源:MapsforgeOSMDroidTileProviderBase.java
示例5: loadTile
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
@Override
protected Drawable loadTile(MapTileRequestState req) throws CantContinueException {
InputStream inputStream;
try {
final String filePath = tileSource.getTileRelativeFilenameString(req.getMapTile());
inputStream = assetManager.open(filePath);
return new ExpirableBitmapDrawable(BitmapFactory.decodeStream(inputStream));
} catch (final IOException e) {
return null;
}
}
开发者ID:tarent,项目名称:invio,代码行数:13,代码来源:AssetTileProvider.java
示例6: loadTile
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
@Override
public Drawable loadTile(final MapTileRequestState aState) throws CantContinueException
{
Drawable tile = drawMapsforgeTile(aState);
if(tile == null)
tile = downloadTile(aState);
return tile;
}
开发者ID:MobileAppCodes,项目名称:CycleStreets-Android-app-,代码行数:9,代码来源:MapsforgeOSMDroidTileProvider.java
示例7: drawMapsforgeTile
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
private Drawable drawMapsforgeTile(final MapTileRequestState aState)
{
if(tileSource_ == null)
return null;
try {
final MapTile tile = aState.getMapTile();
return tileSource_.getDrawable(tile.getX(), tile.getY(), tile.getZoomLevel());
}
catch(Exception e) {
return null;
}
}
开发者ID:MobileAppCodes,项目名称:CycleStreets-Android-app-,代码行数:14,代码来源:MapsforgeOSMDroidTileProvider.java
示例8: MapTileModuleProviderBase
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
public MapTileModuleProviderBase(int pThreadPoolSize, final int pPendingQueueSize) {
if (pPendingQueueSize < pThreadPoolSize) {
Log.w(IMapView.LOGTAG,"The pending queue size is smaller than the thread pool size. Automatically reducing the thread pool size.");
pThreadPoolSize = pPendingQueueSize;
}
mExecutor = Executors.newFixedThreadPool(pThreadPoolSize,
new ConfigurablePriorityThreadFactory(Thread.NORM_PRIORITY, getThreadGroupName()));
mWorking = new HashMap<MapTile, MapTileRequestState>();
mPending = new LinkedHashMap<MapTile, MapTileRequestState>(pPendingQueueSize + 2, 0.1f,
true) {
private static final long serialVersionUID = 6455337315681858866L;
@Override
protected boolean removeEldestEntry(
final Map.Entry<MapTile, MapTileRequestState> pEldest) {
if (size() > pPendingQueueSize) {
MapTile result = null;
// get the oldest tile that isn't in the mWorking queue
Iterator<MapTile> iterator = mPending.keySet().iterator();
while (result == null && iterator.hasNext()) {
final MapTile tile = iterator.next();
if (!mWorking.containsKey(tile)) {
result = tile;
}
}
if (result != null) {
MapTileRequestState state = mPending.get(result);
removeTileFromQueues(result);
state.getCallback().mapTileRequestFailedExceedsMaxQueueSize(state);
}
}
return false;
}
};
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:41,代码来源:MapTileModuleProviderBase.java
示例9: nextTile
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
protected MapTileRequestState nextTile() {
synchronized (mQueueLockObject) {
MapTile result = null;
// get the most recently accessed tile
// - the last item in the iterator that's not already being
// processed
Iterator<MapTile> iterator = mPending.keySet().iterator();
// TODO this iterates the whole list, make this faster...
while (iterator.hasNext()) {
final MapTile tile = iterator.next();
if (!mWorking.containsKey(tile)) {
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"TileLoader.nextTile() on provider: " + getName()
+ " found tile in working queue: " + tile);
}
result = tile;
}
}
if (result != null) {
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"TileLoader.nextTile() on provider: " + getName()
+ " adding tile to working queue: " + result);
}
mWorking.put(result, mPending.get(result));
}
return (result != null ? mPending.get(result) : null);
}
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:34,代码来源:MapTileModuleProviderBase.java
示例10: tileLoaded
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
/**
* A tile has loaded.
*/
protected void tileLoaded(final MapTileRequestState pState, final Drawable pDrawable) {
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"TileLoader.tileLoaded() on provider: " + getName() + " with tile: "
+ pState.getMapTile());
}
removeTileFromQueues(pState.getMapTile());
ExpirableBitmapDrawable.setState(pDrawable, ExpirableBitmapDrawable.UP_TO_DATE);
pState.getCallback().mapTileRequestCompleted(pState, pDrawable);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:13,代码来源:MapTileModuleProviderBase.java
示例11: tileLoadedExpired
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
/**
* A tile has loaded but it's expired.
* Return it <b>and</b> send request to next provider.
*/
protected void tileLoadedExpired(final MapTileRequestState pState, final Drawable pDrawable) {
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"TileLoader.tileLoadedExpired() on provider: " + getName()
+ " with tile: " + pState.getMapTile());
}
removeTileFromQueues(pState.getMapTile());
ExpirableBitmapDrawable.setState(pDrawable, ExpirableBitmapDrawable.EXPIRED);
pState.getCallback().mapTileRequestExpiredTile(pState, pDrawable);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:14,代码来源:MapTileModuleProviderBase.java
示例12: tileLoadedScaled
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
protected void tileLoadedScaled(final MapTileRequestState pState, final Drawable pDrawable) {
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"TileLoader.tileLoadedScaled() on provider: " + getName()
+ " with tile: " + pState.getMapTile());
}
removeTileFromQueues(pState.getMapTile());
ExpirableBitmapDrawable.setState(pDrawable, ExpirableBitmapDrawable.SCALED);
pState.getCallback().mapTileRequestExpiredTile(pState, pDrawable);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:10,代码来源:MapTileModuleProviderBase.java
示例13: tileLoadedFailed
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
protected void tileLoadedFailed(final MapTileRequestState pState) {
if (Configuration.getInstance().isDebugTileProviders()) {
Log.d(IMapView.LOGTAG,"TileLoader.tileLoadedFailed() on provider: " + getName()
+ " with tile: " + pState.getMapTile());
}
removeTileFromQueues(pState.getMapTile());
pState.getCallback().mapTileRequestFailed(pState);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:9,代码来源:MapTileModuleProviderBase.java
示例14: tileLoaded
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
@Override
protected void tileLoaded(final MapTileRequestState pState, final Drawable pDrawable) {
removeTileFromQueues(pState.getMapTile());
// don't return the tile because we'll wait for the fs provider to ask for it
// this prevent flickering when a load of delayed downloads complete for tiles
// that we might not even be interested in any more
pState.getCallback().mapTileRequestCompleted(pState, null);
// We want to return the Bitmap to the BitmapPool if applicable
if (pDrawable instanceof ReusableBitmapDrawable)
BitmapPool.getInstance().returnDrawableToPool((ReusableBitmapDrawable) pDrawable);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:12,代码来源:MapTileDownloader.java
示例15: test_put_twice
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
public void test_put_twice() {
final MapTile tile = new MapTile(1, 1, 1);
// request the same tile twice
final MapTileRequestState state = new MapTileRequestState(tile, new MapTileDownloader[] {},
mTileProviderCallback);
mTileProvider.loadMapTileAsync(state);
mTileProvider.loadMapTileAsync(state);
// check that is only one tile pending
assertEquals("One tile pending", 1, mTileProvider.mPending.size());
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:14,代码来源:MapTileProviderTest.java
示例16: test_order
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
/**
* Test that the tiles are loaded in most recently accessed order.
*
* @throws InterruptedException
*/
public void test_order() throws InterruptedException {
// final ArrayList<MapTile> tiles = new ArrayList<MapTile>();
final MapTile tile1 = new MapTile(1, 1, 1);
final MapTile tile2 = new MapTile(2, 2, 2);
final MapTile tile3 = new MapTile(3, 3, 3);
// request the three tiles
final MapTileRequestState state1 = new MapTileRequestState(tile1,
new MapTileModuleProviderBase[] {}, mTileProviderCallback);
mTileProvider.loadMapTileAsync(state1);
Thread.sleep(100); // give the thread time to run
final MapTileRequestState state2 = new MapTileRequestState(tile2,
new MapTileModuleProviderBase[] {}, mTileProviderCallback);
mTileProvider.loadMapTileAsync(state2);
Thread.sleep(100); // give the thread time to run
final MapTileRequestState state3 = new MapTileRequestState(tile3,
new MapTileModuleProviderBase[] {}, mTileProviderCallback);
mTileProvider.loadMapTileAsync(state3);
// wait up to 10 seconds (because it takes 1 second for each tile + an extra
// second)
long timeout=System.currentTimeMillis()+10000;
while (3 != mTiles.size() && System.currentTimeMillis() < timeout){
Thread.sleep(250);
}
// check that there are three tiles in the list (ie no duplicates)
assertEquals("Three tiles in the list", 3, mTiles.size());
// the tiles should have been loaded in the order 1, 3, 2
// because 1 was loaded immediately, 2 was next,
// but 3 was requested before 2 started, so it jumped the queue
assertEquals("tile1 is first", tile1, mTiles.get(0));
assertEquals("tile3 is second", tile3, mTiles.get(1));
assertEquals("tile2 is third", tile2, mTiles.get(2));
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:45,代码来源:MapTileProviderTest.java
示例17: test_jump_queue
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
/**
* Test that adding the same tile more than once moves it up the queue.
*
* @throws InterruptedException
*/
public void test_jump_queue() throws InterruptedException {
final MapTile tile1 = new MapTile(1, 1, 1);
final MapTile tile2 = new MapTile(2, 2, 2);
final MapTile tile3 = new MapTile(3, 3, 3);
// request tile1, tile2, tile3, then tile2 again
final MapTileRequestState state1 = new MapTileRequestState(tile1,
new MapTileModuleProviderBase[] {}, mTileProviderCallback);
mTileProvider.loadMapTileAsync(state1);
Thread.sleep(100); // give the thread time to run
final MapTileRequestState state2 = new MapTileRequestState(tile2,
new MapTileModuleProviderBase[] {}, mTileProviderCallback);
mTileProvider.loadMapTileAsync(state2);
Thread.sleep(100); // give the thread time to run
final MapTileRequestState state3 = new MapTileRequestState(tile3,
new MapTileModuleProviderBase[] {}, mTileProviderCallback);
mTileProvider.loadMapTileAsync(state3);
Thread.sleep(100); // give the thread time to run
final MapTileRequestState state4 = new MapTileRequestState(tile2,
new MapTileModuleProviderBase[] {}, mTileProviderCallback);
mTileProvider.loadMapTileAsync(state4);
// wait up to 10 seconds (because it takes 1 second for each tile + an extra
// second)
long timeout=System.currentTimeMillis()+10000;
while (3 != mTiles.size() && System.currentTimeMillis() < timeout){
Thread.sleep(250);
}
// check that there are three tiles in the list (ie no duplicates)
assertEquals("Three tiles in the list", 3, mTiles.size());
// the tiles should have been loaded in the order 1, 2, 3
// 3 jumped ahead of 2, but then 2 jumped ahead of it again
assertEquals("tile1 is first", tile1, mTiles.get(0));
assertEquals("tile2 is second", tile2, mTiles.get(1));
assertEquals("tile3 is third", tile3, mTiles.get(2));
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:44,代码来源:MapTileProviderTest.java
示例18: tileLoaded
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
@Override
protected void tileLoaded(final MapTileRequestState pState,
final Drawable pDrawable) {
removeTileFromQueues(pState.getMapTile());
// don't return the tile because we'll wait for the fs provider to
// ask for it
// this prevent flickering when a load of delayed downloads complete
// for tiles
// that we might not even be interested in any more
pState.getCallback().mapTileRequestCompleted(pState, null);
}
开发者ID:ABAKUS-ST,项目名称:StrazakOSM,代码行数:12,代码来源:WMSMapTileDownloader.java
示例19: mapTileRequestCompleted
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
@Override
public void mapTileRequestCompleted(final MapTileRequestState pState, final Drawable pDrawable) {
// synchronized (mWorking) {
mWorking.remove(pState.getMapTile());
//}
super.mapTileRequestCompleted(pState, pDrawable);
}
开发者ID:gabuzomeu,项目名称:osmLib,代码行数:8,代码来源:MapTileProviderArrayTTbox.java
示例20: mapTileRequestFailed
import org.osmdroid.tileprovider.MapTileRequestState; //导入依赖的package包/类
@Override
public void mapTileRequestFailed(final MapTileRequestState pState) {
final MapTileModuleProviderBase nextProvider = findNextAppropriateProvider(pState);
if (nextProvider != null) {
nextProvider.loadMapTileAsync(pState);
} else {
final MapTile tile = pState.getMapTile();
// synchronized (mWorking) {
mWorking.remove(tile);
// }
super.mapTileRequestFailed(pState);
}
}
开发者ID:gabuzomeu,项目名称:osmLib,代码行数:14,代码来源:MapTileProviderArrayTTbox.java
注:本文中的org.osmdroid.tileprovider.MapTileRequestState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论