formatting

This commit is contained in:
simon 2020-12-09 17:15:48 +02:00
parent f31ad60d47
commit 2aac3e5fd8

View file

@ -77,6 +77,7 @@ import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import static net.osmand.IndexConstants.VOICE_INDEX_DIR;
/**
@ -95,7 +96,7 @@ public class ResourceManager {
protected static ResourceManager manager = null;
protected File dirWithTiles;
protected File dirWithTiles ;
private List<TilesCache> tilesCacheList = new ArrayList<>();
private BitmapTilesCache bitmapTilesCache;
@ -127,11 +128,10 @@ public class ResourceManager {
private List<BinaryMapIndexReader> readers = new ArrayList<>(BinaryMapReaderResourceType.values().length);
private boolean useForRouting;
private boolean useForPublicTransport;
public BinaryMapReaderResource(File f, BinaryMapIndexReader initialReader) {
this.filename = f;
this.initialReader = initialReader;
while (readers.size() < BinaryMapReaderResourceType.values().length) {
while(readers.size() < BinaryMapReaderResourceType.values().length) {
readers.add(null);
}
}
@ -210,7 +210,7 @@ public class ResourceManager {
private final Map<String, RegionAddressRepository> addressMap = new ConcurrentHashMap<String, RegionAddressRepository>();
protected final Map<String, AmenityIndexRepository> amenityRepositories = new ConcurrentHashMap<String, AmenityIndexRepository>();
// protected final Map<String, BinaryMapIndexReader> routingMapFiles = new ConcurrentHashMap<String, BinaryMapIndexReader>();
// protected final Map<String, BinaryMapIndexReader> routingMapFiles = new ConcurrentHashMap<String, BinaryMapIndexReader>();
protected final Map<String, BinaryMapReaderResource> transportRepositories = new ConcurrentHashMap<String, BinaryMapReaderResource>();
protected final Map<String, String> indexFileNames = new ConcurrentHashMap<String, String>();
@ -295,7 +295,7 @@ public class ResourceManager {
// ".nomedia" indicates there are no pictures and no music to list in this dir for the Gallery app
try {
context.getAppPath(".nomedia").createNewFile(); //$NON-NLS-1$
} catch (Exception e) {
} catch( Exception e ) {
}
for (TilesCache tilesCache : tilesCacheList) {
tilesCache.setDirWithTiles(dirWithTiles);
@ -325,7 +325,7 @@ public class ResourceManager {
return null;
}
public synchronized void tileDownloaded(DownloadRequest request) {
public synchronized void tileDownloaded(DownloadRequest request){
if (request instanceof TileLoadDownloadRequest) {
TileLoadDownloadRequest req = ((TileLoadDownloadRequest) request);
TilesCache cache = getTilesCache(req.tileSource);
@ -340,7 +340,7 @@ public class ResourceManager {
return cache != null && cache.tileExistOnFileSystem(file, map, x, y, zoom);
}
public void clearTileForMap(String file, ITileSource map, int x, int y, int zoom) {
public void clearTileForMap(String file, ITileSource map, int x, int y, int zoom){
TilesCache cache = getTilesCache(map);
if (cache != null) {
cache.getTileForMap(file, map, x, y, zoom, true, false, true, true);
@ -378,7 +378,7 @@ public class ResourceManager {
////////////////////////////////////////////// Working with indexes ////////////////////////////////////////////////
public List<String> reloadIndexesOnStart(AppInitializer progress, List<String> warnings) {
public List<String> reloadIndexesOnStart(AppInitializer progress, List<String> warnings){
close();
// check we have some assets to copy to sdcard
warnings.addAll(checkAssets(progress, false));
@ -431,7 +431,7 @@ public class ResourceManager {
return warnings;
}
public List<String> indexFontFiles(IProgress progress) {
public List<String> indexFontFiles(IProgress progress){
File file = context.getAppPath(IndexConstants.FONT_INDEX_DIR);
file.mkdirs();
List<String> warnings = new ArrayList<String>();
@ -478,7 +478,7 @@ public class ResourceManager {
public List<String> checkAssets(IProgress progress, boolean forceUpdate) {
String fv = Version.getFullVersion(context);
if (context.getAppInitializer().isAppVersionChanged()) {
if(context.getAppInitializer().isAppVersionChanged()) {
copyMissingJSAssets();
}
if (!fv.equalsIgnoreCase(context.getSettings().PREVIOUS_INSTALLED_VERSION.get()) || forceUpdate) {
@ -542,7 +542,6 @@ public class ResourceManager {
private final static String ASSET_COPY_MODE__overwriteOnlyIfExists = "overwriteOnlyIfExists";
private final static String ASSET_COPY_MODE__alwaysOverwriteOrCopy = "alwaysOverwriteOrCopy";
private final static String ASSET_COPY_MODE__copyOnlyIfDoesNotExist = "copyOnlyIfDoesNotExist";
private void unpackBundledAssets(AssetManager assetManager, File appDataDir, IProgress progress, boolean isFirstInstall) throws IOException, XmlPullParserException {
List<AssetEntry> assetEntries = DownloadOsmandIndexesHelper.getBundledAssets(assetManager);
for (AssetEntry asset : assetEntries) {
@ -584,7 +583,7 @@ public class ResourceManager {
}
public static void copyAssets(AssetManager assetManager, String assetName, File file) throws IOException {
if (file.exists()) {
if(file.exists()){
Algorithms.removeAllFiles(file);
}
file.getParentFile().mkdirs();
@ -596,9 +595,9 @@ public class ResourceManager {
}
private List<File> collectFiles(File dir, String ext, List<File> files) {
if (dir.exists() && dir.canRead()) {
if(dir.exists() && dir.canRead()) {
File[] lf = dir.listFiles();
if (lf == null || lf.length == 0) {
if(lf == null || lf.length == 0) {
return files;
}
for (File f : lf) {
@ -611,9 +610,10 @@ public class ResourceManager {
}
private void renameRoadsFiles(ArrayList<File> files, File roadsPath) {
Iterator<File> it = files.iterator();
while (it.hasNext()) {
while(it.hasNext()) {
File f = it.next();
if (f.getName().endsWith("-roads" + IndexConstants.BINARY_MAP_INDEX_EXT)) {
f.renameTo(new File(roadsPath, f.getName().replace("-roads" + IndexConstants.BINARY_MAP_INDEX_EXT,
@ -636,7 +636,6 @@ public class ResourceManager {
collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
if (Version.isPaidVersion(context)) {
collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
collectFiles(context.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
}
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(context)) {
collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
@ -710,9 +709,9 @@ public class ResourceManager {
if (dateCreated == 0) {
dateCreated = f.lastModified();
}
if (f.getParentFile().getName().equals(liveDir.getName())) {
if(f.getParentFile().getName().equals(liveDir.getName())) {
boolean toUse = changesManager.index(f, dateCreated, mapReader);
if (!toUse) {
if(!toUse) {
try {
mapReader.close();
} catch (IOException e) {
@ -720,7 +719,7 @@ public class ResourceManager {
}
continue;
}
} else if (!wikiMap && !srtmMap) {
} else if(!wikiMap && !srtmMap) {
changesManager.indexMainMap(f, dateCreated);
}
indexFileNames.put(f.getName(), dateFormat.format(dateCreated)); //$NON-NLS-1$
@ -782,7 +781,7 @@ public class ResourceManager {
}
}
Iterator<Entry<PoiCategory, Map<String, PoiType>>> it = toAddPoiTypes.entrySet().iterator();
while (it.hasNext()) {
while(it.hasNext()) {
Entry<PoiCategory, Map<String, PoiType>> next = it.next();
PoiCategory category = next.getKey();
category.addExtraPoiTypes(next.getValue());
@ -802,6 +801,7 @@ public class ResourceManager {
}
public void initMapBoundariesCacheNative() {
File indCache = context.getAppPath(INDEXES_CACHE);
if (indCache.exists()) {
@ -887,7 +887,7 @@ public class ResourceManager {
if (!repos.isEmpty()) {
for (AmenityIndexRepository r : repos) {
List<Amenity> res = r.searchAmenitiesOnThePath(locations, radius, filter, matcher);
if (res != null) {
if(res != null) {
amenities.addAll(res);
}
}
@ -901,10 +901,10 @@ public class ResourceManager {
}
public boolean containsAmenityRepositoryToSearch(boolean searchByName) {
public boolean containsAmenityRepositoryToSearch(boolean searchByName){
for (AmenityIndexRepository index : getAmenityRepositories()) {
if (searchByName) {
if (index instanceof AmenityIndexRepositoryBinary) {
if(searchByName){
if(index instanceof AmenityIndexRepositoryBinary){
return true;
}
} else {
@ -929,7 +929,7 @@ public class ResourceManager {
}
if (index instanceof AmenityIndexRepositoryBinary) {
if (index.checkContainsInt(top, left, bottom, right)) {
if (index.checkContains(lat, lon)) {
if(index.checkContains(lat, lon)){
list.add(0, (AmenityIndexRepositoryBinary) index);
} else {
list.add((AmenityIndexRepositoryBinary) index);
@ -975,11 +975,11 @@ public class ResourceManager {
////////////////////////////////////////////// Working with address ///////////////////////////////////////////
public RegionAddressRepository getRegionRepository(String name) {
public RegionAddressRepository getRegionRepository(String name){
return addressMap.get(name);
}
public Collection<RegionAddressRepository> getAddressRepositories() {
public Collection<RegionAddressRepository> getAddressRepositories(){
return addressMap.values();
}
@ -1032,7 +1032,7 @@ public class ResourceManager {
public List<TransportRoute> getRoutesForStop(TransportStop stop) {
List<TransportRoute> rts = stop.getRoutes();
if (rts != null) {
if(rts != null) {
return rts;
}
return Collections.emptyList();
@ -1043,12 +1043,12 @@ public class ResourceManager {
return renderer.updateMapIsNeeded(rotatedTileBox, drawSettings);
}
public void updateRendererMap(RotatedTileBox rotatedTileBox, OnMapLoadedListener mapLoadedListener) {
public void updateRendererMap(RotatedTileBox rotatedTileBox, OnMapLoadedListener mapLoadedListener){
renderer.interruptLoadingMap();
asyncLoadingThread.requestToLoadMap(new MapLoadRequest(rotatedTileBox, mapLoadedListener));
}
public void interruptRendering() {
public void interruptRendering(){
renderer.interruptLoadingMap();
}
@ -1069,12 +1069,12 @@ public class ResourceManager {
indexFileNames.remove(fileName);
renderer.closeConnection(fileName);
BinaryMapReaderResource resource = fileReaders.remove(fileName);
if (resource != null) {
if(resource != null) {
resource.close();
}
}
public synchronized void close() {
public synchronized void close(){
for (TilesCache tc : tilesCacheList) {
tc.close();
}
@ -1084,7 +1084,7 @@ public class ResourceManager {
transportRepositories.clear();
addressMap.clear();
amenityRepositories.clear();
for (BinaryMapReaderResource res : fileReaders.values()) {
for(BinaryMapReaderResource res : fileReaders.values()) {
res.close();
}
fileReaders.clear();
@ -1151,12 +1151,13 @@ public class ResourceManager {
return readers.toArray(new BinaryMapIndexReader[0]);
}
public Map<String, String> getIndexFileNames() {
return new LinkedHashMap<String, String>(indexFileNames);
}
public boolean containsBasemap() {
public boolean containsBasemap(){
return !basemapFileNames.isEmpty();
}