Add fixes
This commit is contained in:
parent
bc3a601f4e
commit
9aaf8f8b19
7 changed files with 29 additions and 35 deletions
|
@ -30,6 +30,6 @@ public interface ITileSource {
|
|||
|
||||
public String getReferer();
|
||||
|
||||
public void clearTiles(String path);
|
||||
public void deleteTiles(String path);
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,10 +224,6 @@ public abstract class TilesCache<T> {
|
|||
}
|
||||
}
|
||||
|
||||
protected synchronized void clearTileCache(String tileId) {
|
||||
cache.remove(tileId);
|
||||
}
|
||||
|
||||
public synchronized T get(String key) {
|
||||
return cache.get(key);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue