diff --git a/OsmAnd-java/src/net/osmand/map/ITileSource.java b/OsmAnd-java/src/net/osmand/map/ITileSource.java index 1711f8453e..a51b5bdeeb 100644 --- a/OsmAnd-java/src/net/osmand/map/ITileSource.java +++ b/OsmAnd-java/src/net/osmand/map/ITileSource.java @@ -30,6 +30,6 @@ public interface ITileSource { public String getReferer(); - public void clearTiles(String path); + public void deleteTiles(String path); } diff --git a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java index 95ef7fe3e5..4a0bcbc5cf 100644 --- a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java +++ b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java @@ -1,5 +1,13 @@ package net.osmand.map; +import net.osmand.PlatformUtil; +import net.osmand.osm.io.NetworkUtils; +import net.osmand.util.Algorithms; + +import org.apache.commons.logging.Log; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -18,15 +26,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import net.osmand.PlatformUtil; -import net.osmand.osm.io.NetworkUtils; -import net.osmand.util.Algorithms; - -import org.apache.commons.logging.Log; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - - import bsh.Interpreter; @@ -278,7 +277,7 @@ public class TileSourceManager { @Override - public void clearTiles(String path) { + public void deleteTiles(String path) { File pf = new File(path); File[] list = pf.listFiles(); if(list != null) { diff --git a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java index acf0dafce3..93ac107f5c 100644 --- a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java +++ b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java @@ -1,12 +1,9 @@ package net.osmand.plus; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.List; +import android.database.sqlite.SQLiteDiskIOException; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.widget.Toast; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -20,11 +17,15 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.text.MessageFormat; +import java.util.Arrays; +import java.util.List; + import bsh.Interpreter; -import android.database.sqlite.SQLiteDiskIOException; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.widget.Toast; public class SQLiteTileSource implements ITileSource { @@ -416,7 +417,7 @@ public class SQLiteTileSource implements ITileSource { @Override - public void clearTiles(String path) { + public void deleteTiles(String path) { SQLiteConnection db = getDatabase(); if (db == null || db.isReadOnly() || onlyReadonlyAvailable) { return; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 08b2f025b7..b7f1900df3 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -3,7 +3,6 @@ package net.osmand.plus.download.ui; import android.app.Activity; import android.content.DialogInterface; import android.content.res.Resources; -import android.content.res.TypedArray; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -483,7 +482,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } else if (operation == CLEAR_TILES_OPERATION) { ITileSource src = (ITileSource) info.getAttachedObject(); if(src != null) { - src.clearTiles(info.getPathToData()); + src.deleteTiles(info.getPathToData()); } } total++; diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java index 1a893db9a6..e81d7c881c 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java @@ -100,8 +100,8 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { @Override public void onClick(View view) { ResourceManager manager = getMyApplication().getResourceManager(); - manager.clearCacheAndTile(TileSourceManager.getMapillaryVectorSource()); - manager.clearCacheAndTile(TileSourceManager.getMapillaryRasterSource()); + manager.clearCacheAndTiles(TileSourceManager.getMapillaryVectorSource()); + manager.clearCacheAndTiles(TileSourceManager.getMapillaryRasterSource()); plugin.updateLayers(mapActivity.getMapView(), mapActivity); } }); diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index b339b1c17c..26fa4599c1 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -337,12 +337,11 @@ public class ResourceManager { return cache != null && cache.getTileForMapSync(file, map, x, y, zoom, loadFromInternetIfNeeded) != null; } - public void clearCacheAndTile(@NonNull ITileSource map) { - String path = dirWithTiles.getAbsolutePath() + "/" + map.getName(); - map.clearTiles(path); + public void clearCacheAndTiles(@NonNull ITileSource map) { + map.deleteTiles(new File(dirWithTiles, map.getName()).getAbsolutePath()); TilesCache cache = getTilesCache(map); if (cache != null) { - cache.clearTileCache(map.getName()); + cache.clearTiles(); } } diff --git a/OsmAnd/src/net/osmand/plus/resources/TilesCache.java b/OsmAnd/src/net/osmand/plus/resources/TilesCache.java index f346e84940..cf608a8979 100644 --- a/OsmAnd/src/net/osmand/plus/resources/TilesCache.java +++ b/OsmAnd/src/net/osmand/plus/resources/TilesCache.java @@ -224,10 +224,6 @@ public abstract class TilesCache { } } - protected synchronized void clearTileCache(String tileId) { - cache.remove(tileId); - } - public synchronized T get(String key) { return cache.get(key); }