org.osmdroid.config.Configuration Java Examples

The following examples show how to use org.osmdroid.config.Configuration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocationActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	Configuration.getInstance().load(this, getPreferences());
	map.onResume();
	this.setMyLoc(null);
	requestLocationUpdates();
	updateLocationMarkers();
	updateUi();
	map.setTileSource(TileSourceFactory.MAPNIK);
	map.setTilesScaledToDpi(true);

	if (mapAtInitialLoc()) {
		gotoLoc();
	}
}
 
Example #2
Source File: CreatePoiFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
private void mapSetup() {
    map = (MapView) getActivity().findViewById(R.id.createPoiMap);

    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));

    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);

    // add multi-touch capability
    map.setMultiTouchControls(true);

    // add compass to map
    CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
    compassOverlay.enableCompass();
    map.getOverlays().add(compassOverlay);

    // get map controller
    IMapController controller = map.getController();

    GeoPoint position = new GeoPoint(latitude, longitude);
    controller.setCenter(position);
    controller.setZoom(18);
    MapUtils.addMarker(getActivity(), map, latitude, longitude);
}
 
Example #3
Source File: PoiDetailsFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
private void setupMapPreview(double lat, double lon, String markerTitle) {
    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(getDialog().getContext(), PreferenceManager.getDefaultSharedPreferences(getDialog().getContext()));

    map = (MapView) getDialog().findViewById(R.id.poiDialogMap);
    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);
    map.setMultiTouchControls(true);

    // add compass to map
    CompassOverlay compassOverlay = new CompassOverlay(getDialog().getContext(), new InternalCompassOrientationProvider(getDialog().getContext()), map);
    compassOverlay.enableCompass();
    map.getOverlays().add(compassOverlay);

    // get map controller
    IMapController controller = map.getController();
    GeoPoint position = new GeoPoint(lat, lon);
    controller.setCenter(position);
    controller.setZoom(18);

    MapUtils.addMarker(getActivity(), map, lat, lon, markerTitle);
}
 
Example #4
Source File: EditPoiFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
private void mapSetup() {
    map = getActivity().findViewById(R.id.createPoiMap);
    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));
    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);
    map.setMultiTouchControls(true);

    CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
    compassOverlay.enableCompass();
    map.getOverlays().add(compassOverlay);

    IMapController controller = map.getController();
    GeoPoint position = new GeoPoint(POI.getLatitude(), POI.getLongitude());
    controller.setCenter(position);
    controller.setZoom(18);

    MapUtils.addMarker(getActivity(), map, POI.getLatitude(), POI.getLongitude());
}
 
Example #5
Source File: PoiListFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Show marker of POI on map preview, on {@link RecyclerView} long press
 *
 * @param element POI to  display
 */
private void openMapPreview(Element element) {
    if (map == null) {
        //important! set your user agent to prevent getting banned from the osm servers
        Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));

        map = getActivity().findViewById(R.id.mapPoiList);
        map.setTileSource(TileSourceFactory.MAPNIK);
        map.setTilesScaledToDpi(true);

        // add multi-touch capability
        map.setMultiTouchControls(true);

        // add compass to map
        CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
        compassOverlay.enableCompass();
        map.getOverlays().add(compassOverlay);
    }
    // get map controller
    IMapController controller = map.getController();
    GeoPoint position = new GeoPoint(element.lat, element.lon);
    controller.setCenter(position);
    controller.setZoom(18);

    MapUtils.addMarker(getActivity(), map, element);
}
 
Example #6
Source File: BookmarkDatastore.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
public BookmarkDatastore() {

        Configuration.getInstance().getOsmdroidTileCache().mkdirs();
        db_file = new File(Configuration.getInstance().getOsmdroidTileCache().getAbsolutePath() + File.separator + DATABASE_FILENAME);


        try {
            mDatabase = SQLiteDatabase.openOrCreateDatabase(db_file, null);
            mDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE + " (" +
                COLUMN_LAT+ " INTEGER , " +
                COLUMN_LON + " INTEGER, " +
                COLUMN_TITLE + " TEXT, " +
                COLUMN_ID + " TEXT, " +
                COLUMN_DESC+" TEXT, PRIMARY KEY (" + COLUMN_ID + ") );");
        } catch (Throwable ex) {
            Log.e(IMapView.LOGTAG, "Unable to start the bookmark database. Check external storage availability.", ex);
        }
    }
 
Example #7
Source File: MainActivity.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * refreshes the current osmdroid cache paths with user preferences plus soe logic to work around
 * file system permissions on api23 devices. it's primarily used for out android tests.
 * @param ctx
 * @return current cache size in bytes
 */
public static long updateStoragePreferences(Context ctx){

    //loads the osmdroid config from the shared preferences object.
    //if this is the first time launching this app, all settings are set defaults with one exception,
    //the tile cache. the default is the largest write storage partition, which could end up being
    //this app's private storage, depending on device config and permissions

    Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));

    //also note that our preference activity has the corresponding save method on the config object, but it can be called at any time.


    File dbFile = new File(Configuration.getInstance().getOsmdroidTileCache().getAbsolutePath() + File.separator + SqlTileWriter.DATABASE_FILENAME);
    if (dbFile.exists()) {
        return dbFile.length();
    }
    return -1;
}
 
Example #8
Source File: LocationUtils.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * Get the most recent location from the GPS or Network provider.
 *
 * @return return the most recent location, or null if there's no known location
 */
public static Location getLastKnownLocation(final LocationManager pLocationManager) {
	if (pLocationManager == null) {
		return null;
	}
	final Location gpsLocation = getLastKnownLocation(pLocationManager, LocationManager.GPS_PROVIDER);
	final Location networkLocation = getLastKnownLocation(pLocationManager, LocationManager.NETWORK_PROVIDER);
	if (gpsLocation == null) {
		return networkLocation;
	} else if (networkLocation == null) {
		return gpsLocation;
	} else {
		// both are non-null - use the most recent
		if (networkLocation.getTime() > gpsLocation.getTime() + Configuration.getInstance().getGpsWaitTime()) {
			return networkLocation;
		} else {
			return gpsLocation;
		}
	}
}
 
Example #9
Source File: TileDownloader.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * @since 6.0.3
 * @return the expiration time (as Epoch timestamp in milliseconds)
 * @deprecated Use {@link TileSourcePolicy#computeExpirationTime(HttpURLConnection, long)} instead
 */
@Deprecated
public long computeExpirationTime(final String pHttpExpiresHeader, final String pHttpCacheControlHeader, final long pNow) {
    final Long override=Configuration.getInstance().getExpirationOverrideDuration();
    if (override != null) {
        return pNow + override;
    }

    final long extension = Configuration.getInstance().getExpirationExtendedDuration();
    final Long cacheControlDuration = getHttpCacheControlDuration(pHttpCacheControlHeader);
    if (cacheControlDuration != null) {
        return pNow + cacheControlDuration * 1000 + extension;
    }

    final Long httpExpiresTime = getHttpExpiresTime(pHttpExpiresHeader);
    if (httpExpiresTime != null) {
        return httpExpiresTime + extension;
    }

    return pNow + OpenStreetMapTileProviderConstants.DEFAULT_MAXIMUM_CACHED_FILE_AGE + extension;
}
 
Example #10
Source File: MapTileFileArchiveProvider.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
private synchronized InputStream getInputStream(final long pMapTileIndex,
		final ITileSource tileSource) {
	for (final IArchiveFile archiveFile : mArchiveFiles) {
		if (archiveFile!=null) {
			final InputStream in = archiveFile.getInputStream(tileSource, pMapTileIndex);
			if (in != null) {
				if (Configuration.getInstance().isDebugMode()) {
					Log.d(IMapView.LOGTAG, "Found tile " + MapTileIndex.toString(pMapTileIndex) + " in " + archiveFile);
				}
				return in;
			}
		}
	}

	return null;
}
 
Example #11
Source File: MapController.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * Start animating the map towards the given point.
 */
@Override
public void animateTo(int x, int y) {
    // If no layout, delay this call
    if (!mMapView.isLayoutOccurred()) {
        mReplayController.animateTo(x, y);
        return;
    }

    if (!mMapView.isAnimating()) {
        mMapView.mIsFlinging = false;
        final int xStart = (int)mMapView.getMapScrollX();
        final int yStart = (int)mMapView.getMapScrollY();

        final int dx = x - mMapView.getWidth() / 2;
        final int dy = y - mMapView.getHeight() / 2;

        if (dx != xStart || dy != yStart) {
            mMapView.getScroller().startScroll(xStart, yStart, dx, dy, Configuration.getInstance().getAnimationSpeedDefault());
            mMapView.postInvalidate();
        }
    }
}
 
Example #12
Source File: MapTileFileArchiveProvider.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
private void findArchiveFiles() {
	clearArcives();

         // path should be optionally configurable
         File cachePaths = Configuration.getInstance().getOsmdroidBasePath();
         final File[] files = cachePaths.listFiles();
         if (files != null) {
              for (final File file : files) {
                   final IArchiveFile archiveFile = ArchiveFileFactory.getArchiveFile(file);
                   if (archiveFile != null) {
                  		 archiveFile.setIgnoreTileSource(ignoreTileSource);
                        mArchiveFiles.add(archiveFile);
                   }
              }
         }
}
 
Example #13
Source File: MapTileFileArchiveProvider.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @since 6.0.0
 * @param pRegisterReceiver
 * @param pTileSource
 * @param pArchives
 * @param ignoreTileSource if true, tile source is ignored
 */
public MapTileFileArchiveProvider(final IRegisterReceiver pRegisterReceiver,
								  final ITileSource pTileSource, final IArchiveFile[] pArchives, final boolean ignoreTileSource) {
	super(pRegisterReceiver,
		Configuration.getInstance().getTileFileSystemThreads(),
		Configuration.getInstance().getTileFileSystemMaxQueueSize());

	this.ignoreTileSource=ignoreTileSource;
	setTileSource(pTileSource);

	if (pArchives == null) {
		mSpecificArchivesProvided = false;
		findArchiveFiles();
	} else {
		mSpecificArchivesProvided = true;
		for (int i = pArchives.length - 1; i >= 0; i--) {
			mArchiveFiles.add(pArchives[i]);
		}
	}

}
 
Example #14
Source File: SqlTileWriter.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * @since 6.0.2
 */
protected SQLiteDatabase getDb() {
    if (mDb != null) {
        return mDb;
    }
    synchronized (mLock) {
        Configuration.getInstance().getOsmdroidTileCache().mkdirs();
        db_file = new File(Configuration.getInstance().getOsmdroidTileCache().getAbsolutePath() + File.separator + DATABASE_FILENAME);
        if (mDb == null) {
            try {
                mDb = SQLiteDatabase.openOrCreateDatabase(db_file, null);
                mDb.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE + " (" + DatabaseFileArchive.COLUMN_KEY + " INTEGER , " + DatabaseFileArchive.COLUMN_PROVIDER + " TEXT, " + DatabaseFileArchive.COLUMN_TILE + " BLOB, " + COLUMN_EXPIRES + " INTEGER, PRIMARY KEY (" + DatabaseFileArchive.COLUMN_KEY + ", " + DatabaseFileArchive.COLUMN_PROVIDER + "));");
            } catch (Exception ex) {
                Log.e(IMapView.LOGTAG, "Unable to start the sqlite tile writer. Check external storage availability.", ex);
                catchException(ex);
                return null;
            }
        }
    }
    return mDb;
}
 
Example #15
Source File: MyLocationNewOverlay.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onSnapToItem(final int x, final int y, final Point snapPoint,
		final IMapView mapView) {
	if (this.mLocation != null) {
		Projection pj = mMapView.getProjection();
		pj.toPixels(mGeoPoint, mSnapPixel);
		snapPoint.x = mSnapPixel.x;
		snapPoint.y = mSnapPixel.y;
		final double xDiff = x - mSnapPixel.x;
		final double yDiff = y - mSnapPixel.y;
		boolean snap = xDiff * xDiff + yDiff * yDiff < 64;
		if (Configuration.getInstance().isDebugMode()) {
                   Log.d(IMapView.LOGTAG, "snap=" + snap);
		}
		return snap;
	} else {
		return false;
	}
}
 
Example #16
Source File: SqlTileWriter.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * this could be a long running operation, don't run on the UI thread unless necessary.
 * This function prunes the database for old or expired tiles.
 *
 * @since 5.6
 */
public void runCleanupOperation() {
    final SQLiteDatabase db = getDb();
    if (db == null || !db.isOpen()) {
        if (Configuration.getInstance().isDebugMode()) {
            Log.d(IMapView.LOGTAG, "Finished init thread, aborted due to null database reference");
        }
        return;
    }

    // index creation is run now (regardless of the table size)
    // therefore potentially on a small table, for better index creation performances
    createIndex(db);

    final long dbLength = db_file.length();
    if (dbLength <= Configuration.getInstance().getTileFileSystemCacheMaxBytes()) {
        return;
    }

    runCleanupOperation(
            dbLength - Configuration.getInstance().getTileFileSystemCacheTrimBytes(),
            Configuration.getInstance().getTileGCBulkSize(),
            Configuration.getInstance().getTileGCBulkPauseInMillis(),
            true);
}
 
Example #17
Source File: TileWriter.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
public TileWriter() {

		if (!hasInited) {
			hasInited = true;
			// do this in the background because it takes a long time
			initThread = new Thread() {
				@Override
				public void run() {
					mUsedCacheSpace = 0; // because it's static

					calculateDirectorySize(Configuration.getInstance().getOsmdroidTileCache());

					if (mUsedCacheSpace > Configuration.getInstance().getTileFileSystemCacheMaxBytes()) {
						cutCurrentCache();
					}
					if (Configuration.getInstance().isDebugMode()) {
						Log.d(IMapView.LOGTAG, "Finished init thread");
					}
				}
			};
			initThread.setName("TileWriter#init");
			initThread.setPriority(Thread.MIN_PRIORITY);
			initThread.start();
		}
	}
 
Example #18
Source File: FastZoomSpeedAnimations.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //overrides the default animation speeds
    //note: the mapview creates the default double tap to zoom in animator when the map view is created
    //this we have to set the desired zoom speed here before the mapview is created/inflated
    Configuration.getInstance().setAnimationSpeedShort(100);
    Configuration.getInstance().setAnimationSpeedDefault(100);

    View root = inflater.inflate(R.layout.map_with_locationbox_controls, container,false);

    mMapView = root.findViewById(R.id.mapview);
    TextView textViewCurrentLocation = root.findViewById(R.id.textViewCurrentLocation);
    textViewCurrentLocation.setText("Animation Speed Test");
    ImageButton btn = root.findViewById(R.id.btnRotateLeft);
    btn.setOnClickListener(this);

    btn = root.findViewById(R.id.btnRotateRight);
    btn.setOnClickListener(this);
    return root;
}
 
Example #19
Source File: TileWriter.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public Drawable loadTile(final ITileSource pTileSource, final long pMapTileIndex) throws Exception{
	// Check the tile source to see if its file is available and if so, then render the
	// drawable and return the tile
	final File file = getFile(pTileSource, pMapTileIndex);
	if (!file.exists()) {
		return null;
	}

	final Drawable drawable = pTileSource.getDrawable(file.getPath());

	// Check to see if file has expired
	final long now = System.currentTimeMillis();
	final long lastModified = file.lastModified();
	final boolean fileExpired = lastModified < now - mMaximumCachedFileAge;

	if (fileExpired && drawable != null) {
		if (Configuration.getInstance().isDebugMode()) {
			Log.d(IMapView.LOGTAG,"Tile expired: " + MapTileIndex.toString(pMapTileIndex));
		}
		ExpirableBitmapDrawable.setState(drawable, ExpirableBitmapDrawable.EXPIRED);
	}

	return drawable;
}
 
Example #20
Source File: StoragePreferenceFragment.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    updateStorage(getContext());

    textViewCacheDirectory.setText(Configuration.getInstance().getOsmdroidTileCache().toString());
    textViewCacheMaxSize.setText(readableFileSize(Configuration.getInstance().getTileFileSystemCacheMaxBytes()));
    textViewCacheTrimSize.setText(readableFileSize(Configuration.getInstance().getTileFileSystemCacheTrimBytes()));
    textViewCacheFreeSpace.setText(readableFileSize(Configuration.getInstance().getOsmdroidTileCache().getFreeSpace()));

    File dbFile = new File(Configuration.getInstance().getOsmdroidTileCache().getAbsolutePath() + File.separator + SqlTileWriter.DATABASE_FILENAME);
    if (dbFile.exists()) {
        textViewCacheCurrentSize.setText(readableFileSize(dbFile.length()));
    } else {
        textViewCacheCurrentSize.setText("");
    }
}
 
Example #21
Source File: TileSourcePolicy.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * @since 6.1.7
 * @return the expiration time (as Epoch timestamp in milliseconds)
 */
public long computeExpirationTime(final HttpURLConnection pHttpURLConnection, final long pNow) {
    final String expires = pHttpURLConnection.getHeaderField(OpenStreetMapTileProviderConstants.HTTP_EXPIRES_HEADER);
    final String cacheControl = pHttpURLConnection.getHeaderField(OpenStreetMapTileProviderConstants.HTTP_CACHECONTROL_HEADER);
    final long result = computeExpirationTime(expires, cacheControl, pNow);
    if (Configuration.getInstance().isDebugMapTileDownloader()) {
        Log.d(IMapView.LOGTAG, "computeExpirationTime('" + expires + "','" + cacheControl + "'," + pNow + "=" + result);
    }
    return result;
}
 
Example #22
Source File: MapsForgeTileModuleProvider.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param receiverRegistrar
 * @param tileSource
 */
public MapsForgeTileModuleProvider(IRegisterReceiver receiverRegistrar, MapsForgeTileSource tileSource, IFilesystemCache tilewriter) {

    super(receiverRegistrar,
        Configuration.getInstance().getTileFileSystemThreads(),
        Configuration.getInstance().getTileFileSystemMaxQueueSize());

    this.tileSource = tileSource;
    this.tilewriter = tilewriter;

}
 
Example #23
Source File: NetworkLocationIgnorer.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * Whether we should ignore this location.
 *
 * @param pProvider
 *            the provider that provided the location
 * @param pTime
 *            the time of the location
 * @return true if we should ignore this location, false if not
 */
public boolean shouldIgnore(final String pProvider, final long pTime) {

	if (LocationManager.GPS_PROVIDER.equals(pProvider)) {
		mLastGps = pTime;
	} else {
		if (pTime < mLastGps + Configuration.getInstance().getGpsWaitTime()) {
			return true;
		}
	}

	return false;
}
 
Example #24
Source File: MapTileProviderBase.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * Called by implementation class methods indicating that they have produced an expired result
 * that can be used but better results may be delivered later. The tile is added to the cache,
 * and a MAPTILE_SUCCESS_ID message is sent.
 *
 * @param pState
 *            the map tile request state object
 * @param pDrawable
 *            the Drawable of the map tile
 */
@Override
public void mapTileRequestExpiredTile(MapTileRequestState pState, Drawable pDrawable) {
	putTileIntoCache(pState.getMapTile(), pDrawable, ExpirableBitmapDrawable.getState(pDrawable));

	// tell our caller we've finished and it should update its view
	sendMessage(MAPTILE_SUCCESS_ID);

	if (Configuration.getInstance().isDebugTileProviders()) {
		Log.d(IMapView.LOGTAG,"MapTileProviderBase.mapTileRequestExpiredTile(): " + MapTileIndex.toString(pState.getMapTile()));
	}
}
 
Example #25
Source File: SampleJumboCache.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onPause(){
	super.onPause();
	//reset the defaults
	Configuration.getInstance().setCacheMapTileCount((short)9);
	Configuration.getInstance().setCacheMapTileOvershoot((short)0);
}
 
Example #26
Source File: MapTileModuleProviderBase.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
protected MapTileRequestState nextTile() {

			synchronized (mQueueLockObject) {
				Long result = null;

				// get the most recently accessed tile
				// - the last item in the iterator that's not already being
				// processed
				Iterator<Long> iterator = mPending.keySet().iterator();

				// TODO this iterates the whole list, make this faster...
				while (iterator.hasNext()) {
					final Long mapTileIndex = iterator.next();
					if (!mWorking.containsKey(mapTileIndex)) {
						if (Configuration.getInstance().isDebugTileProviders()) {
							Log.d(IMapView.LOGTAG,"TileLoader.nextTile() on provider: " + getName()
									+ " found tile in working queue: " + MapTileIndex.toString(mapTileIndex));
						}
						result = mapTileIndex;
					}
				}

				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);
			}
		}
 
Example #27
Source File: PreferenceActivity.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
public static void resetSettings(Context ctx) {
    //delete all preference keys, if you're using this for your own application
    //you may want to consider some additional logic here (only clear osmdroid settings or
    //use something other than the default shared preferences map
    SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(ctx).edit();
    edit.clear();
    edit.commit();
    //this will repopulate the default settings
    Configuration.setConfigurationProvider(new DefaultConfigurationProvider());
    //this will save the default along with the user agent (important for downloading tiles)
    Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
}
 
Example #28
Source File: MapTileModuleProviderBase.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * 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: " + MapTileIndex.toString(pState.getMapTile()));
	}
	removeTileFromQueues(pState.getMapTile());
	ExpirableBitmapDrawable.setState(pDrawable, ExpirableBitmapDrawable.EXPIRED);
	pState.getCallback().mapTileRequestExpiredTile(pState, pDrawable);
}
 
Example #29
Source File: GeoPackageMapTileModuleProvider.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
public GeoPackageMapTileModuleProvider(File[] pFile,
                                       final Context context, IFilesystemCache cache) {
    //int pThreadPoolSize, final int pPendingQueueSize
    super(Configuration.getInstance().getTileFileSystemThreads(), Configuration.getInstance().getTileFileSystemMaxQueueSize());
    Log.i(IMapView.LOGTAG, "Geopackage support is BETA. Please report any issues");
    tileWriter = cache;
    // Get a manager
    manager = GeoPackageFactory.getManager(context);
    // Available databases


    // Import database
    for (int i = 0; i < pFile.length; i++) {
        try {
            manager.importGeoPackage((pFile[i]));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // Available databases
    List<String> databases = manager.databases();
    // Open database
    for (int i = 0; i < databases.size(); i++) {
        tileSources.add(manager.open(databases.get(i)));
    }

}
 
Example #30
Source File: MapTileModuleProviderBase.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
protected void removeTileFromQueues(final long pMapTileIndex) {
	synchronized (mQueueLockObject) {
		if (Configuration.getInstance().isDebugTileProviders()) {
			Log.d(IMapView.LOGTAG,"MapTileModuleProviderBase.removeTileFromQueues() on provider: "
					+ getName() + " for tile: " + MapTileIndex.toString(pMapTileIndex));
		}
		mPending.remove(pMapTileIndex);
		mWorking.remove(pMapTileIndex);
	}
}