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 String getReferer();
|
||||||
|
|
||||||
public void clearTiles(String path);
|
public void deleteTiles(String path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
package net.osmand.map;
|
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.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -18,15 +26,6 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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;
|
import bsh.Interpreter;
|
||||||
|
|
||||||
|
|
||||||
|
@ -278,7 +277,7 @@ public class TileSourceManager {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearTiles(String path) {
|
public void deleteTiles(String path) {
|
||||||
File pf = new File(path);
|
File pf = new File(path);
|
||||||
File[] list = pf.listFiles();
|
File[] list = pf.listFiles();
|
||||||
if(list != null) {
|
if(list != null) {
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
import java.io.File;
|
import android.database.sqlite.SQLiteDiskIOException;
|
||||||
import java.io.FileInputStream;
|
import android.graphics.Bitmap;
|
||||||
import java.io.IOException;
|
import android.graphics.BitmapFactory;
|
||||||
import java.nio.ByteBuffer;
|
import android.widget.Toast;
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -20,11 +17,15 @@ import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
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 bsh.Interpreter;
|
||||||
import android.database.sqlite.SQLiteDiskIOException;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
|
|
||||||
public class SQLiteTileSource implements ITileSource {
|
public class SQLiteTileSource implements ITileSource {
|
||||||
|
@ -416,7 +417,7 @@ public class SQLiteTileSource implements ITileSource {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearTiles(String path) {
|
public void deleteTiles(String path) {
|
||||||
SQLiteConnection db = getDatabase();
|
SQLiteConnection db = getDatabase();
|
||||||
if (db == null || db.isReadOnly() || onlyReadonlyAvailable) {
|
if (db == null || db.isReadOnly() || onlyReadonlyAvailable) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.download.ui;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -483,7 +482,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
} else if (operation == CLEAR_TILES_OPERATION) {
|
} else if (operation == CLEAR_TILES_OPERATION) {
|
||||||
ITileSource src = (ITileSource) info.getAttachedObject();
|
ITileSource src = (ITileSource) info.getAttachedObject();
|
||||||
if(src != null) {
|
if(src != null) {
|
||||||
src.clearTiles(info.getPathToData());
|
src.deleteTiles(info.getPathToData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
total++;
|
total++;
|
||||||
|
|
|
@ -100,8 +100,8 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
ResourceManager manager = getMyApplication().getResourceManager();
|
ResourceManager manager = getMyApplication().getResourceManager();
|
||||||
manager.clearCacheAndTile(TileSourceManager.getMapillaryVectorSource());
|
manager.clearCacheAndTiles(TileSourceManager.getMapillaryVectorSource());
|
||||||
manager.clearCacheAndTile(TileSourceManager.getMapillaryRasterSource());
|
manager.clearCacheAndTiles(TileSourceManager.getMapillaryRasterSource());
|
||||||
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
|
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -337,12 +337,11 @@ public class ResourceManager {
|
||||||
return cache != null && cache.getTileForMapSync(file, map, x, y, zoom, loadFromInternetIfNeeded) != null;
|
return cache != null && cache.getTileForMapSync(file, map, x, y, zoom, loadFromInternetIfNeeded) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCacheAndTile(@NonNull ITileSource map) {
|
public void clearCacheAndTiles(@NonNull ITileSource map) {
|
||||||
String path = dirWithTiles.getAbsolutePath() + "/" + map.getName();
|
map.deleteTiles(new File(dirWithTiles, map.getName()).getAbsolutePath());
|
||||||
map.clearTiles(path);
|
|
||||||
TilesCache cache = getTilesCache(map);
|
TilesCache cache = getTilesCache(map);
|
||||||
if (cache != null) {
|
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) {
|
public synchronized T get(String key) {
|
||||||
return cache.get(key);
|
return cache.get(key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue