Performance: Iteration over 'keySet()' may be optimized

This commit is contained in:
TacoTheDank 2020-11-19 15:19:27 -05:00
parent 270e7e873d
commit 6b16170168
21 changed files with 83 additions and 67 deletions

View file

@ -2501,8 +2501,9 @@ public class BinaryMapIndexReader {
} }
} }
} }
for (MapObject e : resMap.keySet()) { for (Entry<MapObject, Street> entry : resMap.entrySet()) {
Street s = resMap.get(e); MapObject e = entry.getKey();
Street s = entry.getValue();
if (e instanceof Building && MapUtils.getDistance(e.getLocation(), lat, lon) < 40) { if (e instanceof Building && MapUtils.getDistance(e.getLocation(), lat, lon) < 40) {
Building b = (Building) e; Building b = (Building) e;
System.out.println(b.getName() + " " + s); System.out.println(b.getName() + " " + s);

View file

@ -518,8 +518,8 @@ public class TileSourceManager {
} }
if (override || !metainfo.exists()) { if (override || !metainfo.exists()) {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metainfo))); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metainfo)));
for (String key : properties.keySet()) { for (Map.Entry<String, String> entry : properties.entrySet()) {
writer.write("[" + key + "]\n" + properties.get(key) + "\n"); writer.write("[" + entry.getKey() + "]\n" + entry.getValue() + "\n");
} }
writer.close(); writer.close();
} }

View file

@ -96,8 +96,9 @@ public abstract class MapRenderingTypes {
Map<String, String> common = new HashMap<String, String>(); Map<String, String> common = new HashMap<String, String>();
String ATTACHED_KEY = "seamark:attached"; String ATTACHED_KEY = "seamark:attached";
String type = ""; String type = "";
for (String s : tags.keySet()) { for (Entry<String, String> entry : tags.entrySet()) {
String value = tags.get(s); String s = entry.getKey();
String value = entry.getValue();
if (s.equals("seamark:type")) { if (s.equals("seamark:type")) {
type = value; type = value;
common.put(ATTACHED_KEY, openSeaType(value)); common.put(ATTACHED_KEY, openSeaType(value));

View file

@ -33,9 +33,10 @@ public class EntityParser {
if (mo.getEnName(false).length() == 0) { if (mo.getEnName(false).length() == 0) {
mo.setEnName(tags.get(OSMTagKey.NAME_EN.getValue())); mo.setEnName(tags.get(OSMTagKey.NAME_EN.getValue()));
} }
for (String ts : tags.keySet()) { for (Map.Entry<String, String> entry : tags.entrySet()) {
String ts = entry.getKey();
if (ts.startsWith("name:") && !ts.equals(OSMTagKey.NAME_EN.getValue())) { if (ts.startsWith("name:") && !ts.equals(OSMTagKey.NAME_EN.getValue())) {
mo.setName(ts.substring(("name:").length()), tags.get(ts)); mo.setName(ts.substring(("name:").length()), entry.getValue());
} }
} }
if (mo.getName().length() == 0) { if (mo.getName().length() == 0) {

View file

@ -63,8 +63,8 @@ public class NetworkUtils {
URL url; URL url;
try { try {
boolean firstPrm =!urlText.contains("?"); boolean firstPrm =!urlText.contains("?");
for (String key : additionalMapData.keySet()) { for (Map.Entry<String, String> entry : additionalMapData.entrySet()) {
urlText += (firstPrm ? "?" : "&") + key + "=" + URLEncoder.encode(additionalMapData.get(key), "UTF-8"); urlText += (firstPrm ? "?" : "&") + entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8");
firstPrm = false; firstPrm = false;
} }
log.info("Start uploading file to " + urlText + " " +fileToUpload.getName()); log.info("Start uploading file to " + urlText + " " +fileToUpload.getName());

View file

@ -152,9 +152,9 @@ public class RenderingRulesStoragePrinter {
for (int i = 0; i < 15; i++) { for (int i = 0; i < 15; i++) {
out.println("" + indent + ti + "RenderingRule rule" + i + " = null;"); out.println("" + indent + ti + "RenderingRule rule" + i + " = null;");
} }
for (String s : storage.renderingAttributes.keySet()) { for (Entry<String, RenderingRule> entry : storage.renderingAttributes.entrySet()) {
generateRenderingRule(storage, out, indent + ti, "rule", 0, storage.renderingAttributes.get(s)); generateRenderingRule(storage, out, indent + ti, "rule", 0, entry.getValue());
out.println("" + indent + ti + "storage.renderingAttributes.put(" + javaString(s) + ", rule0);"); out.println("" + indent + ti + "storage.renderingAttributes.put(" + javaString(entry.getKey()) + ", rule0);");
} }
out.println(""+indent +"}"); out.println(""+indent +"}");
} }
@ -242,9 +242,9 @@ public class RenderingRulesStoragePrinter {
private void printJavaInitConstants(RenderingRulesStorage storage, PrintStream out, String indent, String ti) { private void printJavaInitConstants(RenderingRulesStorage storage, PrintStream out, String indent, String ti) {
out.println("\n" + indent + "public void initConstants() {"); out.println("\n" + indent + "public void initConstants() {");
for (String s : storage.renderingConstants.keySet()) { for (Entry<String, String> entry : storage.renderingConstants.entrySet()) {
out.println("" + indent + ti + "storage.renderingConstants.put(" + javaString(s) + ", " out.println("" + indent + ti + "storage.renderingConstants.put(" + javaString(entry.getKey()) + ", "
+ javaString(storage.renderingConstants.get(s)) + ");"); + javaString(entry.getValue()) + ");");
} }
out.println(""+indent +"}"); out.println(""+indent +"}");
} }

View file

@ -803,10 +803,10 @@ public class GeoPointParserUtil {
if (map.size() > 0) if (map.size() > 0)
uriString += "?"; uriString += "?";
int i = 0; int i = 0;
for (String key : map.keySet()) { for (Map.Entry<String, String> entry : map.entrySet()) {
if (i > 0) if (i > 0)
uriString += "&"; uriString += "&";
uriString += key + "=" + map.get(key); uriString += entry.getKey() + "=" + entry.getValue();
i++; i++;
} }
return uriString; return uriString;

View file

@ -305,8 +305,8 @@ public class AndroidNetworkUtils {
try { try {
boolean firstPrm = !urlText.contains("?"); boolean firstPrm = !urlText.contains("?");
StringBuilder sb = new StringBuilder(urlText); StringBuilder sb = new StringBuilder(urlText);
for (String key : additionalParams.keySet()) { for (Map.Entry<String, String> entry : additionalParams.entrySet()) {
sb.append(firstPrm ? "?" : "&").append(key).append("=").append(URLEncoder.encode(additionalParams.get(key), "UTF-8")); sb.append(firstPrm ? "?" : "&").append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), "UTF-8"));
firstPrm = false; firstPrm = false;
} }
urlText = sb.toString(); urlText = sb.toString();

View file

@ -190,14 +190,15 @@ class AppVersionUpgradeOnInit {
migrateEnumPreferences(); migrateEnumPreferences();
SharedPreferences globalSharedPreferences = (SharedPreferences) settings.getGlobalPreferences(); SharedPreferences globalSharedPreferences = (SharedPreferences) settings.getGlobalPreferences();
Map<String, ?> globalPrefsMap = globalSharedPreferences.getAll(); Map<String, ?> globalPrefsMap = globalSharedPreferences.getAll();
for (String key : globalPrefsMap.keySet()) { for (Map.Entry<String, ?> entry : globalPrefsMap.entrySet()) {
String key = entry.getKey();
OsmandPreference<?> pref = settings.getPreference(key); OsmandPreference<?> pref = settings.getPreference(key);
if (pref instanceof CommonPreference) { if (pref instanceof CommonPreference) {
CommonPreference<?> commonPreference = (CommonPreference<?>) pref; CommonPreference<?> commonPreference = (CommonPreference<?>) pref;
if (!commonPreference.isGlobal()) { if (!commonPreference.isGlobal()) {
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
if (!commonPreference.isSetForMode(mode) && !commonPreference.hasDefaultValueForMode(mode)) { if (!commonPreference.isSetForMode(mode) && !commonPreference.hasDefaultValueForMode(mode)) {
settings.setPreference(key, globalPrefsMap.get(key), mode); settings.setPreference(key, entry.getValue(), mode);
} }
} }
} }
@ -205,12 +206,13 @@ class AppVersionUpgradeOnInit {
} }
SharedPreferences defaultProfilePreferences = (SharedPreferences) settings.getProfilePreferences(ApplicationMode.DEFAULT); SharedPreferences defaultProfilePreferences = (SharedPreferences) settings.getProfilePreferences(ApplicationMode.DEFAULT);
Map<String, ?> defaultPrefsMap = defaultProfilePreferences.getAll(); Map<String, ?> defaultPrefsMap = defaultProfilePreferences.getAll();
for (String key : defaultPrefsMap.keySet()) { for (Map.Entry<String, ?> entry : defaultPrefsMap.entrySet()) {
String key = entry.getKey();
OsmandPreference<?> pref = settings.getPreference(key); OsmandPreference<?> pref = settings.getPreference(key);
if (pref instanceof CommonPreference) { if (pref instanceof CommonPreference) {
CommonPreference<?> commonPreference = (CommonPreference<?>) pref; CommonPreference<?> commonPreference = (CommonPreference<?>) pref;
if (commonPreference.isGlobal() && !commonPreference.isSet()) { if (commonPreference.isGlobal() && !commonPreference.isSet()) {
settings.setPreference(key, defaultPrefsMap.get(key)); settings.setPreference(key, entry.getValue());
} }
} }
} }

View file

@ -261,10 +261,11 @@ public class FavouritesDbHelper {
private boolean merge(Map<String, FavouritePoint> source, Map<String, FavouritePoint> destination) { private boolean merge(Map<String, FavouritePoint> source, Map<String, FavouritePoint> destination) {
boolean changed = false; boolean changed = false;
for (String ks : source.keySet()) { for (Map.Entry<String, FavouritePoint> entry : source.entrySet()) {
String ks = entry.getKey();
if (!destination.containsKey(ks)) { if (!destination.containsKey(ks)) {
changed = true; changed = true;
destination.put(ks, source.get(ks)); destination.put(ks, entry.getValue());
} }
} }
return changed; return changed;
@ -712,9 +713,10 @@ public class FavouritesDbHelper {
public boolean isGroupVisible(String name) { public boolean isGroupVisible(String name) {
String nameLowercase = name.toLowerCase(); String nameLowercase = name.toLowerCase();
for (String groupName : flatGroups.keySet()) { for (Map.Entry<String, FavoriteGroup> entry : flatGroups.entrySet()) {
String groupName = entry.getKey();
if (groupName.toLowerCase().equals(nameLowercase) || FavoriteGroup.getDisplayName(context, groupName).equals(name)) { if (groupName.toLowerCase().equals(nameLowercase) || FavoriteGroup.getDisplayName(context, groupName).equals(name)) {
return flatGroups.get(groupName).isVisible(); return entry.getValue().isVisible();
} }
} }
return false; return false;

View file

@ -208,11 +208,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
Map<String, GPXFile> data = collectRecordedData(); Map<String, GPXFile> data = collectRecordedData();
// save file // save file
for (final String f : data.keySet()) { for (final Map.Entry<String, GPXFile> entry : data.entrySet()) {
final String f = entry.getKey();
log.debug("Filename: " + f); log.debug("Filename: " + f);
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT); File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
if (!data.get(f).isEmpty()) { if (!entry.getValue().isEmpty()) {
WptPt pt = data.get(f).findPointToShow(); WptPt pt = entry.getValue().findPointToShow();
String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$ String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$
Integer trackStorageDirectory = ctx.getSettings().TRACK_STORAGE_DIRECTORY.get(); Integer trackStorageDirectory = ctx.getSettings().TRACK_STORAGE_DIRECTORY.get();
if (!OsmandSettings.REC_DIRECTORY.equals(trackStorageDirectory)) { if (!OsmandSettings.REC_DIRECTORY.equals(trackStorageDirectory)) {
@ -235,13 +236,13 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
} }
} }
Exception warn = GPXUtilities.writeGpxFile(fout, data.get(f)); Exception warn = GPXUtilities.writeGpxFile(fout, entry.getValue());
if (warn != null) { if (warn != null) {
warnings.add(warn.getMessage()); warnings.add(warn.getMessage());
return new SaveGpxResult(warnings, new ArrayList<String>()); return new SaveGpxResult(warnings, new ArrayList<String>());
} }
GPXFile gpx = data.get(f); GPXFile gpx = entry.getValue();
GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified()); GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified());
GpxDataItem item = new GpxDataItem(fout, analysis); GpxDataItem item = new GpxDataItem(fout, analysis);
ctx.getGpxDbHelper().add(item); ctx.getGpxDbHelper().add(item);

View file

@ -25,9 +25,9 @@ public class FileSettingsAPIImpl implements SettingsAPI {
Properties props = new Properties(); Properties props = new Properties();
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
props.load(fis); props.load(fis);
for (Object key : props.keySet()) { for (Entry<Object, Object> entry : props.entrySet()) {
String k = key.toString(); String k = entry.getKey().toString();
map.put(k, props.get(key)); map.put(k, entry.getValue());
} }
} }
} }

View file

@ -81,7 +81,8 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
Map<String, List<WptPt>> pointsByCategories = gpxFile.getPointsByCategories(); Map<String, List<WptPt>> pointsByCategories = gpxFile.getPointsByCategories();
for (String category : pointsByCategories.keySet()) { for (Map.Entry<String, List<WptPt>> entry : pointsByCategories.entrySet()) {
String category = entry.getKey();
final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1];
categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(!isUpdateMode || (categories != null && categories.contains(category))) .setChecked(!isUpdateMode || (categories != null && categories.contains(category)))
@ -96,7 +97,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
} }
}) })
.setCompoundButtonColorId(activeColorResId) .setCompoundButtonColorId(activeColorResId)
.setDescription(String.valueOf(pointsByCategories.get(category).size())) .setDescription(String.valueOf(entry.getValue().size()))
.setIcon(getContentIcon(R.drawable.ic_action_folder)) .setIcon(getContentIcon(R.drawable.ic_action_folder))
.setTitle(category.equals("") ? getString(R.string.shared_string_waypoints) : category) .setTitle(category.equals("") ? getString(R.string.shared_string_waypoints) : category)
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp) .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp)

View file

@ -684,9 +684,9 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial
@Override @Override
public void uploadEnded(Map<OsmPoint, String> loadErrorsMap) { public void uploadEnded(Map<OsmPoint, String> loadErrorsMap) {
super.uploadEnded(loadErrorsMap); super.uploadEnded(loadErrorsMap);
for (OsmPoint osmPoint : loadErrorsMap.keySet()) { for (Map.Entry<OsmPoint, String> entry : loadErrorsMap.entrySet()) {
if (loadErrorsMap.get(osmPoint) == null) { if (entry.getValue() == null) {
osmEdits.remove(osmPoint); osmEdits.remove(entry.getKey());
} }
} }
recreateAdapterData(); recreateAdapterData();

View file

@ -59,8 +59,8 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
} }
int uploaded = 0; int uploaded = 0;
int pointsNum = loadErrorsMap.keySet().size(); int pointsNum = loadErrorsMap.keySet().size();
for (OsmPoint point : loadErrorsMap.keySet()) { for (String s : loadErrorsMap.values()) {
if (loadErrorsMap.get(point) == null) { if (s == null) {
uploaded++; uploaded++;
} }
} }
@ -200,13 +200,14 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
boolean[] hasErrors = new boolean[loadErrorsMap.keySet().size()]; boolean[] hasErrors = new boolean[loadErrorsMap.keySet().size()];
ArrayList<OsmPoint> pointsWithErrors = new ArrayList<>(); ArrayList<OsmPoint> pointsWithErrors = new ArrayList<>();
int i = 0; int i = 0;
for (OsmPoint point : loadErrorsMap.keySet()) { for (Map.Entry<OsmPoint, String> entry : loadErrorsMap.entrySet()) {
OsmPoint point = entry.getKey();
pointNames[i] = point.getGroup() == OsmPoint.Group.BUG ? pointNames[i] = point.getGroup() == OsmPoint.Group.BUG ?
((OsmNotesPoint) point).getText() : ((OsmNotesPoint) point).getText() :
((OpenstreetmapPoint) point).getName(); ((OpenstreetmapPoint) point).getName();
pointNames[i] = TextUtils.isEmpty(pointNames[i]) ? pointNames[i] = TextUtils.isEmpty(pointNames[i]) ?
"id:" + point.getId() : pointNames[i]; "id:" + point.getId() : pointNames[i];
hasErrors[i] = loadErrorsMap.get(point) != null; hasErrors[i] = entry.getValue() != null;
if (hasErrors[i]) { if (hasErrors[i]) {
pointsWithErrors.add(point); pointsWithErrors.add(point);
} }

View file

@ -751,14 +751,15 @@ public class PoiFiltersHelper {
} }
Map<PoiCategory, LinkedHashSet<String>> types = p.getAcceptedTypes(); Map<PoiCategory, LinkedHashSet<String>> types = p.getAcceptedTypes();
SQLiteStatement insertCategories = db.compileStatement("INSERT INTO " + CATEGORIES_NAME + " VALUES (?, ?, ?)"); SQLiteStatement insertCategories = db.compileStatement("INSERT INTO " + CATEGORIES_NAME + " VALUES (?, ?, ?)");
for (PoiCategory a : types.keySet()) { for (Map.Entry<PoiCategory, LinkedHashSet<String>> entry : types.entrySet()) {
if (types.get(a) == null) { PoiCategory a = entry.getKey();
if (entry.getValue() == null) {
insertCategories.bindString(1, p.getFilterId()); insertCategories.bindString(1, p.getFilterId());
insertCategories.bindString(2, a.getKeyName()); insertCategories.bindString(2, a.getKeyName());
insertCategories.bindNull(3); insertCategories.bindNull(3);
insertCategories.execute(); insertCategories.execute();
} else { } else {
for (String s : types.get(a)) { for (String s : entry.getValue()) {
insertCategories.bindString(1, p.getFilterId()); insertCategories.bindString(1, p.getFilterId());
insertCategories.bindString(2, a.getKeyName()); insertCategories.bindString(2, a.getKeyName());
insertCategories.bindString(3, s); insertCategories.bindString(3, s);

View file

@ -535,20 +535,19 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
return getName(); return getName();
} }
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
for (PoiCategory p : acceptedTypes.keySet()) { for (Entry<PoiCategory, LinkedHashSet<String>> entry : acceptedTypes.entrySet()) {
LinkedHashSet<String> set = acceptedTypes.get(p); LinkedHashSet<String> set = entry.getValue();
if (set == null) { if (set == null) {
if (res.length() > 0) { if (res.length() > 0) {
res.append(", "); res.append(", ");
} }
res.append(p.getTranslation()); res.append(entry.getKey().getTranslation());
} }
if (res.length() > chars) { if (res.length() > chars) {
return res.toString(); return res.toString();
} }
} }
for (PoiCategory p : acceptedTypes.keySet()) { for (LinkedHashSet<String> set : acceptedTypes.values()) {
LinkedHashSet<String> set = acceptedTypes.get(p);
if (set != null) { if (set != null) {
for (String st : set) { for (String st : set) {
if (res.length() > 0) { if (res.length() > 0) {
@ -616,8 +615,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
public boolean areAllTypesAccepted() { public boolean areAllTypesAccepted() {
if (poiTypes.getCategories(false).size() == acceptedTypes.size()) { if (poiTypes.getCategories(false).size() == acceptedTypes.size()) {
for (PoiCategory a : acceptedTypes.keySet()) { for (LinkedHashSet<String> strings : acceptedTypes.values()) {
if (acceptedTypes.get(a) != null) { if (strings != null) {
return false; return false;
} }
} }
@ -711,8 +710,9 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
private void putAllAcceptedTypes(Map<PoiCategory, LinkedHashSet<String>> types) { private void putAllAcceptedTypes(Map<PoiCategory, LinkedHashSet<String>> types) {
for (PoiCategory category : types.keySet()) { for (Entry<PoiCategory, LinkedHashSet<String>> entry : types.entrySet()) {
LinkedHashSet<String> typesSet = types.get(category); PoiCategory category = entry.getKey();
LinkedHashSet<String> typesSet = entry.getValue();
if (acceptedTypes.containsKey(category)) { if (acceptedTypes.containsKey(category)) {
if (acceptedTypes.get(category) != null && typesSet != null) { if (acceptedTypes.get(category) != null && typesSet != null) {
acceptedTypes.get(category).addAll(typesSet); acceptedTypes.get(category).addAll(typesSet);

View file

@ -311,8 +311,9 @@ public class MapRenderRepositories {
} }
boolean containsJapanMapData = false; boolean containsJapanMapData = false;
boolean useLive = context.getSettings().USE_OSM_LIVE_FOR_ROUTING.get(); boolean useLive = context.getSettings().USE_OSM_LIVE_FOR_ROUTING.get();
for (String mapName : files.keySet()) { for (Map.Entry<String, BinaryMapIndexReader> entry : files.entrySet()) {
BinaryMapIndexReader fr = files.get(mapName); String mapName = entry.getKey();
BinaryMapIndexReader fr = entry.getValue();
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) || if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) { fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) {
if (!nativeFiles.contains(mapName)) { if (!nativeFiles.contains(mapName)) {

View file

@ -114,12 +114,13 @@ public class TerrainLayer extends MapTileLayer {
} }
private void indexNonCachedResources(Map<String, Long> fileModified, Map<String, SQLiteTileSource> rs) { private void indexNonCachedResources(Map<String, Long> fileModified, Map<String, SQLiteTileSource> rs) {
for(String filename : fileModified.keySet()) { for(Map.Entry<String, Long> entry : fileModified.entrySet()) {
String filename = entry.getKey();
try { try {
log.info("Indexing " + type + " file " + filename); log.info("Indexing " + type + " file " + filename);
ContentValues cv = new ContentValues(); ContentValues cv = new ContentValues();
cv.put("filename", filename); cv.put("filename", filename);
cv.put("date_modified", fileModified.get(filename)); cv.put("date_modified", entry.getValue());
SQLiteTileSource ts = rs.get(filename); SQLiteTileSource ts = rs.get(filename);
QuadRect rt = ts.getRectBoundary(ZOOM_BOUNDARY, 1); QuadRect rt = ts.getRectBoundary(ZOOM_BOUNDARY, 1);
if (rt != null) { if (rt != null) {

View file

@ -232,20 +232,22 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) { if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) {
textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get(); textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
} }
for (LatLon latLon : pressedLatLonSmall.keySet()) { for (Entry<LatLon, BackgroundType> entry : pressedLatLonSmall.entrySet()) {
LatLon latLon = entry.getKey();
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
BackgroundType background = pressedLatLonSmall.get(latLon); BackgroundType background = entry.getValue();
Bitmap pressedBitmapSmall = background.getTouchBackground(activity, true); Bitmap pressedBitmapSmall = background.getTouchBackground(activity, true);
Rect destRect = getIconDestinationRect( Rect destRect = getIconDestinationRect(
x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), textScale); x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), textScale);
canvas.drawBitmap(pressedBitmapSmall, null, destRect, paint); canvas.drawBitmap(pressedBitmapSmall, null, destRect, paint);
} }
for (LatLon latLon : pressedLatLonFull.keySet()) { for (Entry<LatLon, BackgroundType> entry : pressedLatLonFull.entrySet()) {
LatLon latLon = entry.getKey();
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
BackgroundType background = pressedLatLonFull.get(latLon); BackgroundType background = entry.getValue();
Bitmap pressedBitmap = background.getTouchBackground(activity, false); Bitmap pressedBitmap = background.getTouchBackground(activity, false);
int offsetY = background.getOffsetY(activity, textScale); int offsetY = background.getOffsetY(activity, textScale);
Rect destRect = getIconDestinationRect( Rect destRect = getIconDestinationRect(

View file

@ -61,7 +61,8 @@ public class MapTextLayer extends OsmandMapLayer {
@Override @Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
TIntHashSet set = new TIntHashSet(); TIntHashSet set = new TIntHashSet();
for (OsmandMapLayer l : textObjects.keySet()) { for (Map.Entry<OsmandMapLayer, Collection<?>> entry : textObjects.entrySet()) {
OsmandMapLayer l = entry.getKey();
MapTextProvider provider = (MapTextProvider) l; MapTextProvider provider = (MapTextProvider) l;
if (!view.isLayerVisible(l) || !provider.isTextVisible()) { if (!view.isLayerVisible(l) || !provider.isTextVisible()) {
continue; continue;
@ -69,7 +70,7 @@ public class MapTextLayer extends OsmandMapLayer {
updateTextSize(); updateTextSize();
paintTextIcon.setFakeBoldText(provider.isFakeBoldText()); paintTextIcon.setFakeBoldText(provider.isFakeBoldText());
for (Object o : textObjects.get(l)) { for (Object o : entry.getValue()) {
LatLon loc = provider.getTextLocation(o); LatLon loc = provider.getTextLocation(o);
String name = provider.getText(o); String name = provider.getText(o);
if (loc == null || TextUtils.isEmpty(name)) { if (loc == null || TextUtils.isEmpty(name)) {