Merge pull request #10236 from TacoTheDank/master

Miscellaneous performance lints
This commit is contained in:
Vitaliy 2020-11-23 01:34:42 +00:00 committed by GitHub
commit 7de4b6149c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
100 changed files with 226 additions and 225 deletions

View file

@ -800,7 +800,7 @@ public abstract class ByteString implements Iterable<Byte> {
// Copy the information we need into local variables so as to hold // Copy the information we need into local variables so as to hold
// the lock for as short a time as possible. // the lock for as short a time as possible.
cachedFlushBuffers = cachedFlushBuffers =
flushedBuffers.toArray(new ByteString[flushedBuffers.size()]); flushedBuffers.toArray(new ByteString[0]);
cachedBuffer = buffer; cachedBuffer = buffer;
cachedBufferPos = bufferPos; cachedBufferPos = bufferPos;
} }

View file

@ -242,8 +242,7 @@ final class FieldSet<FieldDescriptorType extends
// Wrap the contents in a new list so that the caller cannot change // Wrap the contents in a new list so that the caller cannot change
// the list's contents after setting it. // the list's contents after setting it.
final List newList = new ArrayList(); final List newList = new ArrayList((List) value);
newList.addAll((List) value);
for (final Object element : newList) { for (final Object element : newList) {
verifyType(descriptor.getLiteType(), element); verifyType(descriptor.getLiteType(), element);
} }

View file

@ -345,7 +345,6 @@ public final class JtsAdapter {
for(int i = 0; i < geom.getNumGeometries(); ++i) { for(int i = 0; i < geom.getNumGeometries(); ++i) {
final Polygon nextPoly = (Polygon) geom.getGeometryN(i); final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
final List<Integer> nextPolyGeom = new ArrayList<>();
boolean valid = true; boolean valid = true;
// Add exterior ring // Add exterior ring
@ -362,7 +361,7 @@ public final class JtsAdapter {
CoordinateArrays.reverse(exteriorRing.getCoordinates()); CoordinateArrays.reverse(exteriorRing.getCoordinates());
} }
nextPolyGeom.addAll(linesToGeomCmds(exteriorRing, mvtClosePath, cursor, 2)); final List<Integer> nextPolyGeom = new ArrayList<>(linesToGeomCmds(exteriorRing, mvtClosePath, cursor, 2));
// Add interior rings // Add interior rings

View file

@ -322,7 +322,7 @@ public final class MvtReader {
geoms.add(geomFactory.createLineString(nextCoordSeq)); geoms.add(geomFactory.createLineString(nextCoordSeq));
} }
return geoms.size() == 1 ? geoms.get(0) : geomFactory.createMultiLineString(geoms.toArray(new LineString[geoms.size()])); return geoms.size() == 1 ? geoms.get(0) : geomFactory.createMultiLineString(geoms.toArray(new LineString[0]));
} }
/** /**
@ -450,7 +450,7 @@ public final class MvtReader {
return polygons.get(0); return polygons.get(0);
} else { } else {
return geomFactory.createMultiPolygon(polygons.toArray(new Polygon[polygons.size()])); return geomFactory.createMultiPolygon(polygons.toArray(new Polygon[0]));
} }
} }
@ -512,7 +512,7 @@ public final class MvtReader {
if (area > 0d) { if (area > 0d) {
if (outerPoly != null) { if (outerPoly != null) {
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()]))); polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
holes.clear(); holes.clear();
} }
@ -533,7 +533,7 @@ public final class MvtReader {
if (outerPoly != null) { if (outerPoly != null) {
holes.toArray(); holes.toArray();
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()]))); polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
} }
return polygons; return polygons;
@ -569,7 +569,7 @@ public final class MvtReader {
if (outerPoly == null || (outerArea < 0 == area < 0)) { if (outerPoly == null || (outerArea < 0 == area < 0)) {
if (outerPoly != null) { if (outerPoly != null) {
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()]))); polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
holes.clear(); holes.clear();
} }
@ -590,7 +590,7 @@ public final class MvtReader {
if (outerPoly != null) { if (outerPoly != null) {
holes.toArray(); holes.toArray();
polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()]))); polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[0])));
} }
return polygons; return polygons;

View file

@ -1247,7 +1247,7 @@ public class GPXUtilities {
} }
} }
} }
g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[splitSegments.size()])); g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[0]));
return g; return g;
} }

View file

@ -68,7 +68,7 @@ public class TspHeldKarp {
} }
break; break;
} }
System.err.printf("."); System.err.print(".");
PriorityQueue<Node> children = new PriorityQueue<Node>(11, new NodeComparator()); PriorityQueue<Node> children = new PriorityQueue<Node>(11, new NodeComparator());
children.add(exclude(currentNode, i, currentNode.parent[i])); children.add(exclude(currentNode, i, currentNode.parent[i]));
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {

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

@ -241,9 +241,7 @@ public class CachedOsmandIndexes {
cblock.type = mr.getType(); cblock.type = mr.getType();
mi.cities.add(cblock); mi.cities.add(cblock);
} }
for(String s : index.getAdditionalTagsList()) { mi.attributeTagsTable.addAll(index.getAdditionalTagsList());
mi.attributeTagsTable.add(s);
}
reader.addressIndexes.add(mi); reader.addressIndexes.add(mi);
reader.indexes.add(mi); reader.indexes.add(mi);
} }

View file

@ -329,7 +329,7 @@ public class RouteDataObject {
public String getDestinationName(String lang, boolean transliterate, boolean direction){ public String getDestinationName(String lang, boolean transliterate, boolean direction){
//Issue #3289: Treat destination:ref like a destination, not like a ref //Issue #3289: Treat destination:ref like a destination, not like a ref
String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction); String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction);
String destRef1 = ("".equals(destRef)) ? "" : destRef + ", "; String destRef1 = Algorithms.isEmpty(destRef) ? "" : destRef + ", ";
if(names != null) { if(names != null) {
int[] kt = names.keys(); int[] kt = names.keys();
@ -373,7 +373,7 @@ public class RouteDataObject {
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault); return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault);
} }
} }
return "".equals(destRef) ? null : destRef; return Algorithms.isEmpty(destRef) ? null : destRef;
} }
public int getPoint31XTile(int i) { public int getPoint31XTile(int i) {

View file

@ -61,9 +61,9 @@ public class Multipolygon {
innerLinearRings.add(innerRing.toLinearRing()); innerLinearRings.add(innerRing.toLinearRing());
} }
} }
polygons.add(geometryFactory.createPolygon(outerRing.toLinearRing(), innerLinearRings.toArray(new LinearRing[innerLinearRings.size()]))); polygons.add(geometryFactory.createPolygon(outerRing.toLinearRing(), innerLinearRings.toArray(new LinearRing[0])));
} }
return geometryFactory.createMultiPolygon(polygons.toArray(new Polygon[polygons.size()])); return geometryFactory.createMultiPolygon(polygons.toArray(new Polygon[0]));
} }
public long getId() { public long getId() {

View file

@ -140,7 +140,7 @@ public class TileSourceManager {
} }
} }
} }
return randoms.toArray(new String[randoms.size()]); return randoms.toArray(new String[0]);
} }
public void setMinZoom(int minZoom) { public void setMinZoom(int minZoom) {
@ -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

@ -70,7 +70,7 @@ public class RenderingRule {
i++; i++;
} }
} }
properties = props.toArray(new RenderingRuleProperty[props.size()]); properties = props.toArray(new RenderingRuleProperty[0]);
} }
private int getPropertyIndex(String property){ private int getPropertyIndex(String property){

View file

@ -318,7 +318,7 @@ public class RenderingRuleStorageProperties {
} }
public RenderingRuleProperty[] getPoperties() { public RenderingRuleProperty[] getPoperties() {
return rules.toArray(new RenderingRuleProperty[rules.size()]); return rules.toArray(new RenderingRuleProperty[0]);
} }
public List<RenderingRuleProperty> getCustomRules() { public List<RenderingRuleProperty> getCustomRules() {

View file

@ -432,8 +432,7 @@ public class RenderingRulesStorage {
for(RenderingRule ch : caseChildren) { for(RenderingRule ch : caseChildren) {
List<RenderingRule> apply = applyRules; List<RenderingRule> apply = applyRules;
if(!renderingRule.getIfChildren().isEmpty()) { if(!renderingRule.getIfChildren().isEmpty()) {
apply = new ArrayList<RenderingRule>(); apply = new ArrayList<>(renderingRule.getIfChildren());
apply.addAll(renderingRule.getIfChildren());
if(applyRules != null) { if(applyRules != null) {
apply.addAll(applyRules); apply.addAll(applyRules);
} }
@ -492,10 +491,10 @@ public class RenderingRulesStorage {
} }
public String[] getRenderingAttributeNames() { public String[] getRenderingAttributeNames() {
return renderingAttributes.keySet().toArray(new String[renderingAttributes.size()]); return renderingAttributes.keySet().toArray(new String[0]);
} }
public RenderingRule[] getRenderingAttributeValues() { public RenderingRule[] getRenderingAttributeValues() {
return renderingAttributes.values().toArray(new RenderingRule[renderingAttributes.size()]); return renderingAttributes.values().toArray(new RenderingRule[0]);
} }
public RenderingRule[] getRules(int state){ public RenderingRule[] getRules(int state){

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 +"}");
} }
@ -221,7 +221,7 @@ public class RenderingRulesStoragePrinter {
mp+=", "; mp+=", ";
} }
} }
if(mp.equals("")) { if(mp.isEmpty()) {
mp = "java.util.Collections.EMPTY_MAP"; mp = "java.util.Collections.EMPTY_MAP";
} else { } else {
mp = "createMap(" +mp +")"; mp = "createMap(" +mp +")";
@ -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

@ -80,7 +80,7 @@ public class RenderingRulesTransformer {
for (int i = 0; i < nl.getLength();) { for (int i = 0; i < nl.getLength();) {
Element app = (Element) nl.item(i); Element app = (Element) nl.item(i);
String pt = app.getAttribute("pattern"); String pt = app.getAttribute("pattern");
if (!pt.equals("")) { if (!pt.isEmpty()) {
if (!patterns.containsKey(pt)) { if (!patterns.containsKey(pt)) {
throw new IllegalStateException("Pattern '" + pt + "' is not defined"); throw new IllegalStateException("Pattern '" + pt + "' is not defined");
} }

View file

@ -754,21 +754,21 @@ public class GeneralRouter implements VehicleRouter {
} }
public RouteAttributeEvalRule[] getRules() { public RouteAttributeEvalRule[] getRules() {
return rules.toArray(new RouteAttributeEvalRule[rules.size()]); return rules.toArray(new RouteAttributeEvalRule[0]);
} }
public String[] getParamKeys() { public String[] getParamKeys() {
if(paramContext == null) { if(paramContext == null) {
return new String[0]; return new String[0];
} }
return paramContext.vars.keySet().toArray(new String[paramContext.vars.size()]); return paramContext.vars.keySet().toArray(new String[0]);
} }
public String[] getParamValues() { public String[] getParamValues() {
if(paramContext == null) { if(paramContext == null) {
return new String[0]; return new String[0];
} }
return paramContext.vars.values().toArray(new String[paramContext.vars.size()]); return paramContext.vars.values().toArray(new String[0]);
} }
private Object evaluate(RouteDataObject ro) { private Object evaluate(RouteDataObject ro) {
@ -988,19 +988,19 @@ public class GeneralRouter implements VehicleRouter {
public RouteAttributeExpression[] getExpressions() { public RouteAttributeExpression[] getExpressions() {
return expressions.toArray(new RouteAttributeExpression[expressions.size()]); return expressions.toArray(new RouteAttributeExpression[0]);
} }
public String[] getParameters() { public String[] getParameters() {
return parameters.toArray(new String[parameters.size()]); return parameters.toArray(new String[0]);
} }
public String[] getTagValueCondDefTag() { public String[] getTagValueCondDefTag() {
return tagValueCondDefTag.toArray(new String[tagValueCondDefTag.size()]); return tagValueCondDefTag.toArray(new String[0]);
} }
public String[] getTagValueCondDefValue() { public String[] getTagValueCondDefValue() {
return tagValueCondDefValue.toArray(new String[tagValueCondDefValue.size()]); return tagValueCondDefValue.toArray(new String[0]);
} }
public boolean[] getTagValueCondDefNot() { public boolean[] getTagValueCondDefNot() {

View file

@ -918,7 +918,7 @@ public class RoutePlannerFrontEnd {
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, RouteSegment recalculationEnd) throws IOException { private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, RouteSegment recalculationEnd) throws IOException {
refreshProgressDistance(ctx); refreshProgressDistance(ctx);
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]); RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new RouteRegion[0]);
ctx.checkOldRoutingFiles(ctx.startX, ctx.startY); ctx.checkOldRoutingFiles(ctx.startX, ctx.startY);
ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY); ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY);

View file

@ -1717,7 +1717,7 @@ public class RouteResultPreparation {
} }
} }
} }
Integer[] array = possibleTurns.toArray(new Integer[possibleTurns.size()]); Integer[] array = possibleTurns.toArray(new Integer[0]);
Arrays.sort(array, new Comparator<Integer>() { Arrays.sort(array, new Comparator<Integer>() {
@Override @Override

View file

@ -802,7 +802,7 @@ public class RoutingContext {
} }
public BinaryMapIndexReader[] getMaps() { public BinaryMapIndexReader[] getMaps() {
return map.keySet().toArray(new BinaryMapIndexReader[map.size()]); return map.keySet().toArray(new BinaryMapIndexReader[0]);
} }
public int getVisitedSegments() { public int getVisitedSegments() {

View file

@ -325,9 +325,7 @@ public class TransportStopsRouteReader {
// merge first part // merge first part
if (commonStopFirst < commonStopSecond if (commonStopFirst < commonStopSecond
|| (commonStopFirst == commonStopSecond && firstSegment.get(0).isMissingStop())) { || (commonStopFirst == commonStopSecond && firstSegment.get(0).isMissingStop())) {
for (int i = 0; i <= commonStopFirst; i++) { firstSegment.subList(0, commonStopFirst + 1).clear();
firstSegment.remove(0);
}
for (int i = commonStopSecond; i >= 0; i--) { for (int i = commonStopSecond; i >= 0; i--) {
firstSegment.add(0, segmentToMerge.get(i)); firstSegment.add(0, segmentToMerge.get(i));
} }

View file

@ -720,7 +720,7 @@ public class SearchPhrase {
if (result.containsKey(currRegionName)) { if (result.containsKey(currRegionName)) {
result.get(currRegionName).add(r); result.get(currRegionName).add(r);
} else { } else {
result.put(currRegionName, new ArrayList<>(Arrays.asList(r))); result.put(currRegionName, new ArrayList<>(Collections.singletonList(r)));
} }
it.remove(); it.remove();
} }

View file

@ -62,7 +62,7 @@ public class GeoPointParserUtil {
private static Map<String, String> getQueryParameters(String query) { private static Map<String, String> getQueryParameters(String query) {
final LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); final LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
if (query != null && !query.equals("")) { if (query != null && !query.isEmpty()) {
String[] params = query.split("[&/]"); String[] params = query.split("[&/]");
for (String p : params) { for (String p : params) {
String[] keyValue = p.split("="); String[] keyValue = p.split("=");
@ -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

@ -6,6 +6,7 @@ import java.text.DateFormatSymbols;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -1812,7 +1813,7 @@ public class OpeningHoursParser {
TokenType currentParse = TokenType.TOKEN_UNKNOWN; TokenType currentParse = TokenType.TOKEN_UNKNOWN;
TokenType currentParseParent = TokenType.TOKEN_UNKNOWN; TokenType currentParseParent = TokenType.TOKEN_UNKNOWN;
List<Token[]> listOfPairs = new ArrayList<>(); List<Token[]> listOfPairs = new ArrayList<>();
Set<TokenType> presentTokens = new HashSet<>(); Set<TokenType> presentTokens = EnumSet.noneOf(TokenType.class);
Token[] currentPair = new Token[2]; Token[] currentPair = new Token[2];
listOfPairs.add(currentPair); listOfPairs.add(currentPair);
Token prevToken = null; Token prevToken = null;

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

@ -373,7 +373,7 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
dialog.cancel(); dialog.cancel();
} }
}); });
info.setItems(attributes.toArray(new String[attributes.size()]), new DialogInterface.OnClickListener() { info.setItems(attributes.toArray(new String[0]), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
} }

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

@ -208,7 +208,7 @@ public class ContextMenuAdapter {
} }
items.removeAll(itemsToRemove); items.removeAll(itemsToRemove);
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title, return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
items.toArray(new ContextMenuItem[items.size()]), app, lightTheme, changeAppModeListener); items.toArray(new ContextMenuItem[0]), app, lightTheme, changeAppModeListener);
} }
public class ContextMenuArrayAdapter extends ArrayAdapter<ContextMenuItem> { public class ContextMenuArrayAdapter extends ArrayAdapter<ContextMenuItem> {
@ -643,7 +643,7 @@ public class ContextMenuAdapter {
} }
public static OnItemDeleteAction makeDeleteAction(final List<? extends OsmandPreference> prefs) { public static OnItemDeleteAction makeDeleteAction(final List<? extends OsmandPreference> prefs) {
return makeDeleteAction(prefs.toArray(new OsmandPreference[prefs.size()])); return makeDeleteAction(prefs.toArray(new OsmandPreference[0]));
} }
private static void resetSetting(ApplicationMode appMode, OsmandPreference preference, boolean profileOnly) { private static void resetSetting(ApplicationMode appMode, OsmandPreference preference, boolean profileOnly) {

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;
@ -360,7 +361,7 @@ public class FavouritesDbHelper {
} }
public boolean addFavourite(FavouritePoint p, boolean saveImmediately) { public boolean addFavourite(FavouritePoint p, boolean saveImmediately) {
if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) { if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) {
return true; return true;
} }
if (!p.isAddressSpecified()) { if (!p.isAddressSpecified()) {
@ -369,7 +370,7 @@ public class FavouritesDbHelper {
context.getSettings().SHOW_FAVORITES.set(true); context.getSettings().SHOW_FAVORITES.set(true);
FavoriteGroup group = getOrCreateGroup(p, 0); FavoriteGroup group = getOrCreateGroup(p, 0);
if (!p.getName().equals("")) { if (!p.getName().isEmpty()) {
p.setVisible(group.visible); p.setVisible(group.visible);
if (FavouritePoint.SpecialPointType.PARKING.equals(p.getSpecialPointType())) { if (FavouritePoint.SpecialPointType.PARKING.equals(p.getSpecialPointType())) {
p.setColor(ContextCompat.getColor(context, R.color.parking_icon_background)); p.setColor(ContextCompat.getColor(context, R.color.parking_icon_background));
@ -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;
@ -968,7 +970,7 @@ public class FavouritesDbHelper {
p.setName(name); p.setName(name);
p.setCategory(cat); p.setCategory(cat);
FavoriteGroup group = getOrCreateGroup(p, 0); FavoriteGroup group = getOrCreateGroup(p, 0);
if (!name.equals("")) { if (!name.isEmpty()) {
p.setLatitude(query.getDouble(2)); p.setLatitude(query.getDouble(2));
p.setLongitude(query.getDouble(3)); p.setLongitude(query.getDouble(3));
group.points.add(p); group.points.add(p);
@ -1012,7 +1014,7 @@ public class FavouritesDbHelper {
public boolean addFavouriteDB(FavouritePoint p) { public boolean addFavouriteDB(FavouritePoint p) {
if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) { if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) {
return true; return true;
} }
SQLiteConnection db = openConnection(false); SQLiteConnection db = openConnection(false);
@ -1022,7 +1024,7 @@ public class FavouritesDbHelper {
"INSERT INTO " + FAVOURITE_TABLE_NAME + " (" + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " "INSERT INTO " + FAVOURITE_TABLE_NAME + " (" + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", "
+ FAVOURITE_COL_LAT + ", " + FAVOURITE_COL_LON + ")" + " VALUES (?, ?, ?, ?)", new Object[]{p.getName(), p.getCategory(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$ + FAVOURITE_COL_LAT + ", " + FAVOURITE_COL_LON + ")" + " VALUES (?, ?, ?, ?)", new Object[]{p.getName(), p.getCategory(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
FavoriteGroup group = getOrCreateGroup(p, 0); FavoriteGroup group = getOrCreateGroup(p, 0);
if (!p.getName().equals("")) { if (!p.getName().isEmpty()) {
p.setVisible(group.visible); p.setVisible(group.visible);
p.setColor(group.color); p.setColor(group.color);
group.points.add(p); group.points.add(p);

View file

@ -408,10 +408,10 @@ public class GpxSelectionHelper {
boolean split = true; boolean split = true;
if (group.splitDistance > 0) { if (group.splitDistance > 0) {
List<GPXTrackAnalysis> trackSegments = r.splitByDistance(group.splitDistance, joinSegments); List<GPXTrackAnalysis> trackSegments = r.splitByDistance(group.splitDistance, joinSegments);
as = trackSegments.toArray(new GPXTrackAnalysis[trackSegments.size()]); as = trackSegments.toArray(new GPXTrackAnalysis[0]);
} else if (group.splitTime > 0) { } else if (group.splitTime > 0) {
List<GPXTrackAnalysis> trackSegments = r.splitByTime(group.splitTime, joinSegments); List<GPXTrackAnalysis> trackSegments = r.splitByTime(group.splitTime, joinSegments);
as = trackSegments.toArray(new GPXTrackAnalysis[trackSegments.size()]); as = trackSegments.toArray(new GPXTrackAnalysis[0]);
} else { } else {
split = false; split = false;
as = new GPXTrackAnalysis[] {GPXTrackAnalysis.segment(0, r)}; as = new GPXTrackAnalysis[] {GPXTrackAnalysis.segment(0, r)};

View file

@ -63,7 +63,7 @@ public class OsmAndFormatter {
private static final char WEST = 'W'; private static final char WEST = 'W';
private static final char EAST = 'E'; private static final char EAST = 'E';
{ static {
fixed2.setMinimumFractionDigits(2); fixed2.setMinimumFractionDigits(2);
fixed1.setMinimumFractionDigits(1); fixed1.setMinimumFractionDigits(1);
fixed1.setMinimumIntegerDigits(1); fixed1.setMinimumIntegerDigits(1);

View file

@ -412,8 +412,8 @@ public class OsmandApplication extends MultiDexApplication {
if (defaultLocale == null) { if (defaultLocale == null) {
defaultLocale = Locale.getDefault(); defaultLocale = Locale.getDefault();
} }
if (!"".equals(lang)) { if (!Algorithms.isEmpty(lang)) {
if (!"".equals(country)) { if (!Algorithms.isEmpty(country)) {
preferredLocale = new Locale(lang, country); preferredLocale = new Locale(lang, country);
} else { } else {
preferredLocale = new Locale(lang); preferredLocale = new Locale(lang);
@ -421,9 +421,9 @@ public class OsmandApplication extends MultiDexApplication {
} }
Locale selectedLocale = null; Locale selectedLocale = null;
if (!"".equals(lang) && !config.locale.equals(preferredLocale)) { if (!Algorithms.isEmpty(lang) && !config.locale.equals(preferredLocale)) {
selectedLocale = preferredLocale; selectedLocale = preferredLocale;
} else if ("".equals(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) { } else if (Algorithms.isEmpty(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) {
selectedLocale = defaultLocale; selectedLocale = defaultLocale;
preferredLocale = null; preferredLocale = null;
} }
@ -812,12 +812,12 @@ public class OsmandApplication extends MultiDexApplication {
if (preferredLocale != null) { if (preferredLocale != null) {
Configuration config = context.getResources().getConfiguration(); Configuration config = context.getResources().getConfiguration();
String lang = preferredLocale.getLanguage(); String lang = preferredLocale.getLanguage();
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) { if (!Algorithms.isEmpty(lang) && !config.locale.getLanguage().equals(lang)) {
preferredLocale = new Locale(lang); preferredLocale = new Locale(lang);
Locale.setDefault(preferredLocale); Locale.setDefault(preferredLocale);
config.locale = preferredLocale; config.locale = preferredLocale;
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
} else if("".equals(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) { } else if (Algorithms.isEmpty(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) {
Locale.setDefault(defaultLocale); Locale.setDefault(defaultLocale);
config.locale = defaultLocale; config.locale = defaultLocale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

View file

@ -309,9 +309,7 @@ public class TargetPointsHelper {
public List<TargetPoint> getIntermediatePointsNavigation() { public List<TargetPoint> getIntermediatePointsNavigation() {
List<TargetPoint> intermediatePoints = new ArrayList<>(); List<TargetPoint> intermediatePoints = new ArrayList<>();
if (settings.USE_INTERMEDIATE_POINTS_NAVIGATION.get()) { if (settings.USE_INTERMEDIATE_POINTS_NAVIGATION.get()) {
for (TargetPoint t : this.intermediatePoints) { intermediatePoints.addAll(this.intermediatePoints);
intermediatePoints.add(t);
}
} }
return intermediatePoints; return intermediatePoints;
} }
@ -347,8 +345,7 @@ public class TargetPointsHelper {
} }
public List<TargetPoint> getIntermediatePointsWithTarget() { public List<TargetPoint> getIntermediatePointsWithTarget() {
List<TargetPoint> res = new ArrayList<>(); List<TargetPoint> res = new ArrayList<>(this.intermediatePoints);
res.addAll(this.intermediatePoints);
if(pointToNavigate != null) { if(pointToNavigate != null) {
res.add(pointToNavigate); res.add(pointToNavigate);
} }

View file

@ -176,7 +176,7 @@ public class HelpActivity extends OsmandActionBarActivity implements AdapterView
"feature_articles/osmand-3-8-released.html")); "feature_articles/osmand-3-8-released.html"));
String releasedate = ""; String releasedate = "";
if (!this.getString(R.string.app_edition).equals("")) { if (!this.getString(R.string.app_edition).isEmpty()) {
releasedate = ", " + this.getString(R.string.shared_string_release).toLowerCase() + ": " + this.getString(R.string.app_edition); releasedate = ", " + this.getString(R.string.shared_string_release).toLowerCase() + ": " + this.getString(R.string.app_edition);
} }
String version = Version.getFullVersion(getMyApplication()) + releasedate; String version = Version.getFullVersion(getMyApplication()) + releasedate;

View file

@ -1148,7 +1148,7 @@ public class MapActivityActions implements DialogProvider {
items.add(getString(R.string.show_location)); items.add(getString(R.string.show_location));
items.add(getString(R.string.shared_string_show_details)); items.add(getString(R.string.shared_string_show_details));
AlertDialog.Builder menu = new AlertDialog.Builder(mapActivity); AlertDialog.Builder menu = new AlertDialog.Builder(mapActivity);
menu.setItems(items.toArray(new String[items.size()]), new DialogInterface.OnClickListener() { menu.setItems(items.toArray(new String[0]), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int item) { public void onClick(DialogInterface dialog, int item) {
dialog.dismiss(); dialog.dismiss();

View file

@ -208,11 +208,13 @@ 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();
GPXFile gpx = entry.getValue();
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 (!gpx.isEmpty()) {
WptPt pt = data.get(f).findPointToShow(); WptPt pt = gpx.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 +237,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
} }
} }
Exception warn = GPXUtilities.writeGpxFile(fout, data.get(f)); Exception warn = GPXUtilities.writeGpxFile(fout, gpx);
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);
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

@ -165,7 +165,7 @@ public class StartGPSStatus extends OsmAndAction {
// if (g.activity.length() == 0) { // if (g.activity.length() == 0) {
PackageManager pm = mapActivity.getPackageManager(); PackageManager pm = mapActivity.getPackageManager();
try { try {
String appName = !g.paidAppName.equals("") && String appName = !g.paidAppName.isEmpty() &&
g.installed(mapActivity, g.paidAppName) ? g.paidAppName : g.appName; g.installed(mapActivity, g.paidAppName) ? g.paidAppName : g.appName;
intent = pm.getLaunchIntentForPackage(appName); intent = pm.getLaunchIntentForPackage(appName);
} catch (RuntimeException e) { } catch (RuntimeException e) {

View file

@ -166,9 +166,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
} }
}); });
for (AbstractPoiType p : res) { filters.addAll(res);
filters.add(p);
}
filters.add(poiFilters.getSearchByNamePOIFilter()); filters.add(poiFilters.getSearchByNamePOIFilter());
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) { if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
filters.add(poiFilters.getNominatimPOIFilter()); filters.add(poiFilters.getNominatimPOIFilter());

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

@ -1860,7 +1860,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
protected Recording[] getRecordingsSorted() { protected Recording[] getRecordingsSorted() {
checkRecordings(); checkRecordings();
Collection<Recording> allObjects = getAllRecordings(); Collection<Recording> allObjects = getAllRecordings();
Recording[] res = allObjects.toArray(new Recording[allObjects.size()]); Recording[] res = allObjects.toArray(new Recording[0]);
Arrays.sort(res, new Comparator<Recording>() { Arrays.sort(res, new Comparator<Recording>() {
@Override @Override

View file

@ -223,7 +223,7 @@ public class DashChooseAppDirFragment {
paths.add(""); paths.add("");
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED); types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED);
editalert.setSingleChoiceItems(items.toArray(new String[items.size()]), selected, editalert.setSingleChoiceItems(items.toArray(new String[0]), selected,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override

View file

@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -298,9 +299,7 @@ public class LogcatActivity extends ActionBarProgressActivity {
LogcatActivity activity = logcatActivity.get(); LogcatActivity activity = logcatActivity.get();
if (activity != null) { if (activity != null) {
boolean autoscroll = !activity.recyclerView.canScrollVertically(1); boolean autoscroll = !activity.recyclerView.canScrollVertically(1);
for(String s : values) { activity.logs.addAll(Arrays.asList(values));
activity.logs.add(s);
}
activity.adapter.notifyDataSetChanged(); activity.adapter.notifyDataSetChanged();
if(autoscroll) { if(autoscroll) {
activity.recyclerView.scrollToPosition(activity.logs.size() - 1); activity.recyclerView.scrollToPosition(activity.logs.size() - 1);

View file

@ -404,7 +404,7 @@ public class ConfigureMapMenu {
bld.setTitle(R.string.map_magnifier); bld.setTitle(R.string.map_magnifier);
bld.setNegativeButton(R.string.shared_string_dismiss, null); bld.setNegativeButton(R.string.shared_string_dismiss, null);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter( DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
values.toArray(new String[values.size()]), nightMode, i, app, selectedProfileColor, themeRes, new View.OnClickListener() { values.toArray(new String[0]), nightMode, i, app, selectedProfileColor, themeRes, new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
int which = (int) v.getTag(); int which = (int) v.getTag();
@ -481,7 +481,7 @@ public class ConfigureMapMenu {
.createItem()); .createItem());
String localeDescr = activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get(); String localeDescr = activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get();
localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names) localeDescr = localeDescr == null || localeDescr.isEmpty() ? activity.getString(R.string.local_map_names)
: localeDescr; : localeDescr;
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity) adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity)
.setId(MAP_LANGUAGE_ID) .setId(MAP_LANGUAGE_ID)
@ -570,7 +570,7 @@ public class ConfigureMapMenu {
txtIds[index]); txtIds[index]);
refreshMapComplete(activity); refreshMapComplete(activity);
String localeDescr = txtIds[index]; String localeDescr = txtIds[index];
localeDescr = localeDescr == null || localeDescr.equals("") ? activity localeDescr = localeDescr == null || localeDescr.isEmpty() ? activity
.getString(R.string.local_map_names) : localeDescr; .getString(R.string.local_map_names) : localeDescr;
adapter.getItem(pos).setDescription(localeDescr); adapter.getItem(pos).setDescription(localeDescr);
ad.notifyDataSetInvalidated(); ad.notifyDataSetInvalidated();
@ -639,7 +639,7 @@ public class ConfigureMapMenu {
return mp.get(lhs).compareTo(mp.get(rhs)); return mp.get(lhs).compareTo(mp.get(rhs));
} }
}); });
return lst.toArray(new String[lst.size()]); return lst.toArray(new String[0]);
} }
public static String[] getMapNamesValues(Context ctx, String[] ids) { public static String[] getMapNamesValues(Context ctx, String[] ids) {

View file

@ -349,7 +349,7 @@ public class DownloadFileHelper {
private int currentRead = 0; private int currentRead = 0;
public CountingMultiInputStream(List<InputStream> streams) { public CountingMultiInputStream(List<InputStream> streams) {
this.delegate = streams.toArray(new InputStream[streams.size()]); this.delegate = streams.toArray(new InputStream[0]);
} }
@Override @Override

View file

@ -582,7 +582,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
operationTask = null; operationTask = null;
} }
if (operationTask != null) { if (operationTask != null) {
operationTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, selectedItems.toArray(new LocalIndexInfo[selectedItems.size()])); operationTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, selectedItems.toArray(new LocalIndexInfo[0]));
} }
if (actionMode != null) { if (actionMode != null) {
actionMode.finish(); actionMode.finish();

View file

@ -166,12 +166,12 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
dialog.setPositiveButton(R.string.shared_string_update, new DialogInterface.OnClickListener() { dialog.setPositiveButton(R.string.shared_string_update, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
getMyActivity().startDownload(indexItems.toArray(new IndexItem[indexItems.size()])); getMyActivity().startDownload(indexItems.toArray(new IndexItem[0]));
} }
}); });
dialog.create().show(); dialog.create().show();
} else { } else {
getMyActivity().startDownload(indexItems.toArray(new IndexItem[indexItems.size()])); getMyActivity().startDownload(indexItems.toArray(new IndexItem[0]));
} }
} }
}); });

View file

@ -871,7 +871,7 @@ public class ExternalApiHelper {
searchTypes.add(HOUSE); searchTypes.add(HOUSE);
searchTypes.add(STREET_INTERSECTION); searchTypes.add(STREET_INTERSECTION);
} }
searchSettings = searchSettings.setSearchTypes(searchTypes.toArray(new ObjectType[searchTypes.size()])); searchSettings = searchSettings.setSearchTypes(searchTypes.toArray(new ObjectType[0]));
core.search(searchQuery, false, null, searchSettings); core.search(searchQuery, false, null, searchSettings);
} }

View file

@ -101,7 +101,7 @@ public class MapMarkerDialogHelper {
String desc = OsmAndFormatter.getFormattedDate(app, marker.creationDate); String desc = OsmAndFormatter.getFormattedDate(app, marker.creationDate);
String markerGroupName = marker.groupName; String markerGroupName = marker.groupName;
if (markerGroupName != null) { if (markerGroupName != null) {
if (markerGroupName.equals("")) { if (markerGroupName.isEmpty()) {
markerGroupName = app.getString(R.string.shared_string_favorites); markerGroupName = app.getString(R.string.shared_string_favorites);
} }
desc += "" + markerGroupName; desc += "" + markerGroupName;

View file

@ -513,10 +513,9 @@ public class ImportHelper {
private File getFileToSave(final String fileName, final File importDir, final WptPt pt) { private File getFileToSave(final String fileName, final File importDir, final WptPt pt) {
final StringBuilder builder = new StringBuilder(fileName); final StringBuilder builder = new StringBuilder(fileName);
if ("".equals(fileName)) { if (Algorithms.isEmpty(fileName)) {
builder.append("import_").append(new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time))).append(GPX_FILE_EXT); //$NON-NLS-1$ builder.append("import_").append(new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time))).append(GPX_FILE_EXT); //$NON-NLS-1$
} } else if (fileName.endsWith(KML_SUFFIX)) {
if (fileName.endsWith(KML_SUFFIX)) {
builder.replace(builder.length() - KML_SUFFIX.length(), builder.length(), GPX_FILE_EXT); builder.replace(builder.length() - KML_SUFFIX.length(), builder.length(), GPX_FILE_EXT);
} else if (fileName.endsWith(KMZ_SUFFIX)) { } else if (fileName.endsWith(KMZ_SUFFIX)) {
builder.replace(builder.length() - KMZ_SUFFIX.length(), builder.length(), GPX_FILE_EXT); builder.replace(builder.length() - KMZ_SUFFIX.length(), builder.length(), GPX_FILE_EXT);

View file

@ -367,8 +367,7 @@ public class MenuBuilder {
@Override @Override
public void onFinish(List<ImageCard> cardList) { public void onFinish(List<ImageCard> cardList) {
if (!isHidden()) { if (!isHidden()) {
List<AbstractCard> cards = new ArrayList<>(); List<AbstractCard> cards = new ArrayList<AbstractCard>(cardList);
cards.addAll(cardList);
if (cardList.size() == 0) { if (cardList.size() == 0) {
cards.add(new NoImagesCard(mapActivity)); cards.add(new NoImagesCard(mapActivity));
} }

View file

@ -123,7 +123,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) view.findViewById(R.id.auto_complete_text_view); final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) view.findViewById(R.id.auto_complete_text_view);
textView.setAdapter(new MapillaryAutoCompleteAdapter(getContext(), R.layout.auto_complete_suggestion, getMyApplication())); textView.setAdapter(new MapillaryAutoCompleteAdapter(getContext(), R.layout.auto_complete_suggestion, getMyApplication()));
String selectedUsername = settings.MAPILLARY_FILTER_USERNAME.get(); String selectedUsername = settings.MAPILLARY_FILTER_USERNAME.get();
if (!selectedUsername.equals("") && settings.USE_MAPILLARY_FILTER.get()) { if (!selectedUsername.isEmpty() && settings.USE_MAPILLARY_FILTER.get()) {
textView.setText(selectedUsername); textView.setText(selectedUsername);
textView.setSelection(selectedUsername.length()); textView.setSelection(selectedUsername.length());
} }
@ -261,16 +261,16 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
String dateFrom = dateFromEt.getText().toString(); String dateFrom = dateFromEt.getText().toString();
String dateTo = dateToEt.getText().toString(); String dateTo = dateToEt.getText().toString();
if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("") || settings.MAPILLARY_FILTER_PANO.get()) { if (!settings.MAPILLARY_FILTER_USERNAME.get().isEmpty() || !dateFrom.isEmpty() || !dateTo.isEmpty() || settings.MAPILLARY_FILTER_PANO.get()) {
settings.USE_MAPILLARY_FILTER.set(true); settings.USE_MAPILLARY_FILTER.set(true);
} }
if (dateFrom.equals("")) { if (dateFrom.isEmpty()) {
settings.MAPILLARY_FILTER_FROM_DATE.set(0L); settings.MAPILLARY_FILTER_FROM_DATE.set(0L);
} }
if (dateTo.equals("")) { if (dateTo.isEmpty()) {
settings.MAPILLARY_FILTER_TO_DATE.set(0L); settings.MAPILLARY_FILTER_TO_DATE.set(0L);
} }
if (!username.equals("") && settings.MAPILLARY_FILTER_USERNAME.get().equals("")) { if (!username.isEmpty() && settings.MAPILLARY_FILTER_USERNAME.get().isEmpty()) {
view.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE); view.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE);
} else { } else {
mapActivity.getDashboard().hideDashboard(); mapActivity.getDashboard().hideDashboard();

View file

@ -205,7 +205,7 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
long to = settings.MAPILLARY_FILTER_TO_DATE.get(); long to = settings.MAPILLARY_FILTER_TO_DATE.get();
boolean pano = settings.MAPILLARY_FILTER_PANO.get(); boolean pano = settings.MAPILLARY_FILTER_PANO.get();
if (!userKey.equals("")) { if (!userKey.isEmpty()) {
String key = (String) userData.get("userkey"); String key = (String) userData.get("userkey");
if (!userKey.equals(key)) { if (!userKey.equals(key)) {
return true; return true;

View file

@ -277,7 +277,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
} }
} }
((ImageView) mainView.findViewById(R.id.action_bar_image)) ((ImageView) mainView.findViewById(R.id.action_bar_image))
.setImageDrawable(new LayerDrawable(imgList.toArray(new Drawable[imgList.size()]))); .setImageDrawable(new LayerDrawable(imgList.toArray(new Drawable[0])));
} else { } else {
mainView.findViewById(R.id.action_bar_image_container).setVisibility(View.GONE); mainView.findViewById(R.id.action_bar_image_container).setVisibility(View.GONE);
} }

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,9 +97,9 @@ 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.isEmpty() ? 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)
.setTag(category) .setTag(category)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {

View file

@ -131,7 +131,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
String descr; String descr;
if ((descr = marker.groupName) != null) { if ((descr = marker.groupName) != null) {
if (descr.equals("")) { if (descr.isEmpty()) {
descr = mapActivity.getString(R.string.shared_string_favorites); descr = mapActivity.getString(R.string.shared_string_favorites);
} }
} else { } else {

View file

@ -403,7 +403,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
final GroupHeader groupHeader = (GroupHeader) header; final GroupHeader groupHeader = (GroupHeader) header;
final MapMarkersGroup group = groupHeader.getGroup(); final MapMarkersGroup group = groupHeader.getGroup();
String groupName = group.getName(); String groupName = group.getName();
if (groupName.equals("")) { if (groupName.isEmpty()) {
groupName = app.getString(R.string.shared_string_favorites); groupName = app.getString(R.string.shared_string_favorites);
} else if (group.getType() == MapMarkersGroup.GPX_TYPE) { } else if (group.getType() == MapMarkersGroup.GPX_TYPE) {
groupName = groupName.replace(IndexConstants.GPX_FILE_EXT, "").replace("/", " ").replace("_", " "); groupName = groupName.replace(IndexConstants.GPX_FILE_EXT, "").replace("/", " ").replace("_", " ");
@ -579,7 +579,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
Iterator<String> it = categories.iterator(); Iterator<String> it = categories.iterator();
while (it.hasNext()) { while (it.hasNext()) {
String category = it.next(); String category = it.next();
if (category.equals("")) { if (category.isEmpty()) {
category = app.getResources().getString(R.string.shared_string_waypoints); category = app.getResources().getString(R.string.shared_string_waypoints);
} }
sb.append(category); sb.append(category);

View file

@ -145,7 +145,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
String desc = app.getString(R.string.passed, OsmAndFormatter.getFormattedDate(app, marker.visitedDate)); String desc = app.getString(R.string.passed, OsmAndFormatter.getFormattedDate(app, marker.visitedDate));
String markerGroupName = marker.groupName; String markerGroupName = marker.groupName;
if (markerGroupName != null) { if (markerGroupName != null) {
if (markerGroupName.equals("")) { if (markerGroupName.isEmpty()) {
markerGroupName = app.getString(R.string.shared_string_favorites); markerGroupName = app.getString(R.string.shared_string_favorites);
} }
desc += "" + markerGroupName; desc += "" + markerGroupName;

View file

@ -197,7 +197,7 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
String descr; String descr;
if ((descr = marker.groupName) != null) { if ((descr = marker.groupName) != null) {
if (descr.equals("")) { if (descr.isEmpty()) {
descr = mapActivity.getString(R.string.shared_string_favorites); descr = mapActivity.getString(R.string.shared_string_favorites);
} }
} else { } else {

View file

@ -57,7 +57,7 @@ public class TracksGroupsAdapter extends GroupsAdapter {
Iterator<String> it = categories.iterator(); Iterator<String> it = categories.iterator();
while (it.hasNext()) { while (it.hasNext()) {
String category = it.next(); String category = it.next();
if (!category.equals("")) { if (!category.isEmpty()) {
sb.append(category); sb.append(category);
if (it.hasNext()) { if (it.hasNext()) {
sb.append(", "); sb.append(", ");

View file

@ -73,7 +73,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
super(app); super(app);
liveMonitoringHelper = new LiveMonitoringHelper(app); liveMonitoringHelper = new LiveMonitoringHelper(app);
final List<ApplicationMode> am = ApplicationMode.allPossibleValues(); final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
ApplicationMode.regWidgetVisibility("monitoring", am.toArray(new ApplicationMode[am.size()])); ApplicationMode.regWidgetVisibility("monitoring", am.toArray(new ApplicationMode[0]));
settings = app.getSettings(); settings = app.getSettings();
pluginPreferences.add(settings.SAVE_TRACK_TO_GPX); pluginPreferences.add(settings.SAVE_TRACK_TO_GPX);
pluginPreferences.add(settings.SAVE_TRACK_INTERVAL); pluginPreferences.add(settings.SAVE_TRACK_INTERVAL);

View file

@ -554,7 +554,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
public void doAction(int actionResId) { public void doAction(int actionResId) {
if (actionResId == R.string.shared_string_delete) { if (actionResId == R.string.shared_string_delete) {
operationTask = new DeleteGpxTask(); operationTask = new DeleteGpxTask();
operationTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, selectedItems.toArray(new GpxInfo[selectedItems.size()])); operationTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, selectedItems.toArray(new GpxInfo[0]));
} else { } else {
operationTask = null; operationTask = null;
} }
@ -1009,7 +1009,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
List<GpxInfo> progress = new ArrayList<>(); List<GpxInfo> progress = new ArrayList<>();
loadGPXFolder(mapPath, result, loadTask, progress, ""); loadGPXFolder(mapPath, result, loadTask, progress, "");
if (!progress.isEmpty()) { if (!progress.isEmpty()) {
loadTask.loadFile(progress.toArray(new GpxInfo[progress.size()])); loadTask.loadFile(progress.toArray(new GpxInfo[0]));
} }
} }
} }
@ -1029,7 +1029,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
result.add(info); result.add(info);
progress.add(info); progress.add(info);
if (progress.size() > 7) { if (progress.size() > 7) {
loadTask.loadFile(progress.toArray(new GpxInfo[progress.size()])); loadTask.loadFile(progress.toArray(new GpxInfo[0]));
progress.clear(); progress.clear();
} }
} }
@ -1475,7 +1475,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
list.add(GPXDataSetType.SLOPE); list.add(GPXDataSetType.SLOPE);
} }
if (list.size() > 0) { if (list.size() > 0) {
gpxItem.chartTypes = list.toArray(new GPXDataSetType[list.size()]); gpxItem.chartTypes = list.toArray(new GPXDataSetType[0]);
} }
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(gpxItem.locationStart.lat, gpxItem.locationStart.lon, settings.setMapLocationToShow(gpxItem.locationStart.lat, gpxItem.locationStart.lon,

View file

@ -410,7 +410,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_SPEED); tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_SPEED);
} }
} }
tabTypes = tabTypeList.toArray(new GPXTabItemType[tabTypeList.size()]); tabTypes = tabTypeList.toArray(new GPXTabItemType[0]);
Context context = tabs.getContext(); Context context = tabs.getContext();
titles = new String[tabTypes.length]; titles = new String[tabTypes.length];

View file

@ -222,8 +222,8 @@ public class AddPOIAction extends QuickAction {
} }
addPoiToStringSet(getPoiTypes(activity).getOtherMapCategory(), tagKeys, valueKeys); addPoiToStringSet(getPoiTypes(activity).getOtherMapCategory(), tagKeys, valueKeys);
tagKeys.addAll(EditPoiDialogFragment.BASIC_TAGS); tagKeys.addAll(EditPoiDialogFragment.BASIC_TAGS);
mAdapter.setTagData(tagKeys.toArray(new String[tagKeys.size()])); mAdapter.setTagData(tagKeys.toArray(new String[0]));
mAdapter.setValueData(valueKeys.toArray(new String[valueKeys.size()])); mAdapter.setValueData(valueKeys.toArray(new String[0]));
Button addTagButton = (Button) view.findViewById(R.id.addTagButton); Button addTagButton = (Button) view.findViewById(R.id.addTagButton);
addTagButton.setOnClickListener(new View.OnClickListener() { addTagButton.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -89,8 +89,8 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
addPoiToStringSet(abstractPoiType, tagKeys, valueKeys); addPoiToStringSet(abstractPoiType, tagKeys, valueKeys);
} }
addPoiToStringSet(mapPoiTypes.getOtherMapCategory(), tagKeys, valueKeys); addPoiToStringSet(mapPoiTypes.getOtherMapCategory(), tagKeys, valueKeys);
mAdapter.setTagData(tagKeys.toArray(new String[tagKeys.size()])); mAdapter.setTagData(tagKeys.toArray(new String[0]));
mAdapter.setValueData(valueKeys.toArray(new String[valueKeys.size()])); mAdapter.setValueData(valueKeys.toArray(new String[0]));
Button addTagButton = (Button) view.findViewById(R.id.addTagButton); Button addTagButton = (Button) view.findViewById(R.id.addTagButton);
addTagButton.setOnClickListener(new View.OnClickListener() { addTagButton.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -427,8 +427,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
f.setArguments(args); f.setArguments(args);
f.show(getChildFragmentManager(), "exceedDialog"); f.show(getChildFragmentManager(), "exceedDialog");
} else if (TextUtils.isEmpty(poiTypeEditText.getText())) { } else if (TextUtils.isEmpty(poiTypeEditText.getText())) {
HashSet<String> tagsCopy = new HashSet<>();
tagsCopy.addAll(editPoiData.getTagValues().keySet());
if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) { if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) {
SaveExtraValidationDialogFragment f = new SaveExtraValidationDialogFragment(); SaveExtraValidationDialogFragment f = new SaveExtraValidationDialogFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();

View file

@ -415,7 +415,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
List<GpxInfo> selectedItems = f.getSelectedItems(); List<GpxInfo> selectedItems = f.getSelectedItems();
sendGPXFiles(activity, f, sendGPXFiles(activity, f,
selectedItems.toArray(new GpxInfo[selectedItems.size()])); selectedItems.toArray(new GpxInfo[0]));
} }
}); });
return true; return true;

View file

@ -296,7 +296,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
uploadItems(osmEditsSelected.toArray(new OsmPoint[osmEditsSelected.size()])); uploadItems(osmEditsSelected.toArray(new OsmPoint[0]));
mode.finish(); mode.finish();
return true; return true;
} }
@ -594,7 +594,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial
public void onClick(int type) { public void onClick(int type) {
List<OsmPoint> points = getPointsToExport(); List<OsmPoint> points = getPointsToExport();
new BackupOpenstreetmapPointAsyncTask(type, exportType).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new BackupOpenstreetmapPointAsyncTask(type, exportType).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
points.toArray(new OsmPoint[points.size()])); points.toArray(new OsmPoint[0]));
} }
}; };
} }
@ -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);
} }
@ -221,7 +222,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
new UploadingMultipleErrorDialogFragment(); new UploadingMultipleErrorDialogFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable(POINTS_WITH_ERRORS, bundle.putSerializable(POINTS_WITH_ERRORS,
pointsWithErrors.toArray(new OsmPoint[pointsWithErrors.size()])); pointsWithErrors.toArray(new OsmPoint[0]));
bundle.putStringArray(POINT_NAMES, pointNames); bundle.putStringArray(POINT_NAMES, pointNames);
bundle.putBooleanArray(HAS_ERROR, hasErrors); bundle.putBooleanArray(HAS_ERROR, hasErrors);
fragment.setArguments(bundle); fragment.setArguments(bundle);

View file

@ -36,7 +36,7 @@ public class PoiSubTypeDialogFragment extends DialogFragment {
} else { } else {
addCategory(a, strings); addCategory(a, strings);
} }
final String[] subCats = strings.toArray(new String[strings.size()]); final String[] subCats = strings.toArray(new String[0]);
builder.setItems(subCats, new DialogInterface.OnClickListener() { builder.setItems(subCats, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {

View file

@ -31,7 +31,7 @@ public class PoiTypeDialogFragment extends DialogFragment {
categories.add(category); categories.add(category);
} }
} }
builder.setItems(vals.toArray(new String[vals.size()]), new Dialog.OnClickListener() { builder.setItems(vals.toArray(new String[0]), new Dialog.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
PoiCategory aType = categories.get(which); PoiCategory aType = categories.get(which);

View file

@ -250,7 +250,7 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
if (modifiedItemsOutOfLimit != 0) { if (modifiedItemsOutOfLimit != 0) {
comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ") comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ")
.concat(getString(R.string.items_modified)).concat("."); .concat(getString(R.string.items_modified)).concat(".");
} else if (!comment.equals("")) { } else if (!comment.isEmpty()) {
comment = comment.concat("."); comment = comment.concat(".");
} }
return comment; return comment;

View file

@ -84,7 +84,7 @@ public class SendPoiDialogFragment extends DialogFragment {
messageLabel.setVisibility(hasPOI ? View.VISIBLE : View.GONE); messageLabel.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
messageEditText.setVisibility(hasPOI ? View.VISIBLE : View.GONE); messageEditText.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
closeChangeSetCheckBox.setVisibility(hasPOI ? View.VISIBLE : View.GONE); closeChangeSetCheckBox.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
closeChangeSetCheckBox.setChecked(hasPOI && !defaultChangeSet.equals("")); closeChangeSetCheckBox.setChecked(hasPOI && !defaultChangeSet.isEmpty());
view.findViewById(R.id.osm_note_header).setVisibility(hasPOI ? View.GONE : View.VISIBLE); view.findViewById(R.id.osm_note_header).setVisibility(hasPOI ? View.GONE : View.VISIBLE);
uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -233,7 +233,7 @@ public class SendPoiDialogFragment extends DialogFragment {
} }
if (modifiedItemsOutOfLimit != 0) { if (modifiedItemsOutOfLimit != 0) {
comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ").concat(getString(R.string.items_modified)).concat("."); comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ").concat(getString(R.string.items_modified)).concat(".");
} else if (!comment.equals("")){ } else if (!comment.isEmpty()){
comment = comment.concat("."); comment = comment.concat(".");
} }
return comment; return comment;

View file

@ -231,9 +231,8 @@ public class PoiFiltersHelper {
public List<PoiUIFilter> getTopDefinedPoiFilters(boolean includeDeleted) { public List<PoiUIFilter> getTopDefinedPoiFilters(boolean includeDeleted) {
List<PoiUIFilter> top = this.cacheTopStandardFilters; List<PoiUIFilter> top = this.cacheTopStandardFilters;
if (top == null) { if (top == null) {
top = new ArrayList<>();
// user defined // user defined
top.addAll(getUserDefinedPoiFilters(true)); top = new ArrayList<>(getUserDefinedPoiFilters(true));
// default // default
MapPoiTypes poiTypes = application.getPoiTypes(); MapPoiTypes poiTypes = application.getPoiTypes();
for (AbstractPoiType t : poiTypes.getTopVisibleFilters()) { for (AbstractPoiType t : poiTypes.getTopVisibleFilters()) {
@ -751,14 +750,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)) {
@ -727,7 +728,7 @@ public class MapRenderRepositories {
currentRenderingContext.height = requestedBox.getPixHeight(); currentRenderingContext.height = requestedBox.getPixHeight();
currentRenderingContext.nightMode = nightMode; currentRenderingContext.nightMode = nightMode;
if(requestedBox.getZoom() <= zoomToOverviewLocalNames && if(requestedBox.getZoom() <= zoomToOverviewLocalNames &&
"".equals(prefs.MAP_PREFERRED_LOCALE.get())) { prefs.MAP_PREFERRED_LOCALE.get() != null && prefs.MAP_PREFERRED_LOCALE.get().isEmpty()) {
currentRenderingContext.preferredLocale = app.getLanguage(); currentRenderingContext.preferredLocale = app.getLanguage();
currentRenderingContext.transliterate = currentRenderingContext.transliterate =
!languagesNotTransliterateOnBasemap.contains(app.getLanguage()); !languagesNotTransliterateOnBasemap.contains(app.getLanguage());

View file

@ -438,7 +438,7 @@ public class TextRenderer {
String nameTag = isName ? "" : obj.getMapIndex().decodeType(tag).tag; String nameTag = isName ? "" : obj.getMapIndex().decodeType(tag).tag;
boolean skip = false; boolean skip = false;
// not completely correct we should check "name"+rc.preferredLocale // not completely correct we should check "name"+rc.preferredLocale
if (isName && !rc.preferredLocale.equals("") && if (isName && !rc.preferredLocale.isEmpty() &&
map.containsKey(obj.getMapIndex().nameEnEncodingType)) { map.containsKey(obj.getMapIndex().nameEnEncodingType)) {
skip = true; skip = true;
} }

View file

@ -486,7 +486,7 @@ public class ResourceManager {
try { try {
progress.startTask(context.getString(R.string.installing_new_resources), -1); progress.startTask(context.getString(R.string.installing_new_resources), -1);
AssetManager assetManager = context.getAssets(); AssetManager assetManager = context.getAssets();
boolean isFirstInstall = context.getSettings().PREVIOUS_INSTALLED_VERSION.get().equals(""); boolean isFirstInstall = context.getSettings().PREVIOUS_INSTALLED_VERSION.get().isEmpty();
unpackBundledAssets(assetManager, applicationDataDir, progress, isFirstInstall || forceUpdate); unpackBundledAssets(assetManager, applicationDataDir, progress, isFirstInstall || forceUpdate);
context.getSettings().PREVIOUS_INSTALLED_VERSION.set(fv); context.getSettings().PREVIOUS_INSTALLED_VERSION.set(fv);
copyRegionsBoundaries(); copyRegionsBoundaries();
@ -1100,7 +1100,7 @@ public class ResourceManager {
} }
} }
} }
return readers.toArray(new BinaryMapIndexReader[readers.size()]); return readers.toArray(new BinaryMapIndexReader[0]);
} }
public BinaryMapIndexReader[] getTransportRoutingMapFiles() { public BinaryMapIndexReader[] getTransportRoutingMapFiles() {
@ -1114,7 +1114,7 @@ public class ResourceManager {
} }
} }
} }
return readers.toArray(new BinaryMapIndexReader[readers.size()]); return readers.toArray(new BinaryMapIndexReader[0]);
} }
public BinaryMapIndexReader[] getQuickSearchFiles() { public BinaryMapIndexReader[] getQuickSearchFiles() {
@ -1129,7 +1129,7 @@ public class ResourceManager {
} }
} }
} }
return readers.toArray(new BinaryMapIndexReader[readers.size()]); return readers.toArray(new BinaryMapIndexReader[0]);
} }
public Map<String, String> getIndexFileNames() { public Map<String, String> getIndexFileNames() {

View file

@ -651,7 +651,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
((FavouritePoint) item).getSpecialPointType().getIconId(app), iconColor)); ((FavouritePoint) item).getSpecialPointType().getIconId(app), iconColor));
favoriteViewHolder.description.setText(point.getDescription()); favoriteViewHolder.description.setText(point.getDescription());
} else { } else {
if (point.getCategory().equals("")) { if (point.getCategory().isEmpty()) {
favoriteViewHolder.description.setText(R.string.shared_string_favorites); favoriteViewHolder.description.setText(R.string.shared_string_favorites);
} else { } else {
favoriteViewHolder.description.setText(point.getCategory()); favoriteViewHolder.description.setText(point.getCategory());

View file

@ -121,7 +121,7 @@ public class RouteProvider {
list.add(r); list.add(r);
} }
} }
return list.toArray(new RouteService[list.size()]); return list.toArray(new RouteService[0]);
} }
} }

View file

@ -55,6 +55,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -820,7 +821,7 @@ public class SettingsHelper {
} }
public static Map<ExportSettingsType, List<?>> getSettingsToOperate(List<SettingsItem> settingsItems, boolean importComplete) { public static Map<ExportSettingsType, List<?>> getSettingsToOperate(List<SettingsItem> settingsItems, boolean importComplete) {
Map<ExportSettingsType, List<?>> settingsToOperate = new HashMap<>(); Map<ExportSettingsType, List<?>> settingsToOperate = new EnumMap<>(ExportSettingsType.class);
List<ApplicationModeBean> profiles = new ArrayList<>(); List<ApplicationModeBean> profiles = new ArrayList<>();
List<QuickAction> quickActions = new ArrayList<>(); List<QuickAction> quickActions = new ArrayList<>();
List<PoiUIFilter> poiUIFilters = new ArrayList<>(); List<PoiUIFilter> poiUIFilters = new ArrayList<>();

View file

@ -59,9 +59,9 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
final BooleanPreference pref = (BooleanPreference) preference; final BooleanPreference pref = (BooleanPreference) preference;
CharSequence summaryOn = switchPreference.getSummaryOn(); CharSequence summaryOn = switchPreference.getSummaryOn();
CharSequence summaryOff = switchPreference.getSummaryOff(); CharSequence summaryOff = switchPreference.getSummaryOff();
final String on = summaryOn == null || summaryOn.toString().equals("") final String on = summaryOn == null || summaryOn.toString().isEmpty()
? getString(R.string.shared_string_enabled) : summaryOn.toString(); ? getString(R.string.shared_string_enabled) : summaryOn.toString();
final String off = summaryOff == null || summaryOff.toString().equals("") final String off = summaryOff == null || summaryOff.toString().isEmpty()
? getString(R.string.shared_string_disabled) : summaryOff.toString(); ? getString(R.string.shared_string_disabled) : summaryOff.toString();
final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic); final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary); final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);

View file

@ -158,7 +158,7 @@ public class SelectFolderBottomSheet extends BasePreferenceBottomSheet {
Fragment fragment = getTargetFragment(); Fragment fragment = getTargetFragment();
if (fragment instanceof BaseSettingsFragment) { if (fragment instanceof BaseSettingsFragment) {
String newPath = editText.getText().toString().trim(); String newPath = editText.getText().toString().trim();
if (!newPath.equals("")) { if (!newPath.isEmpty()) {
boolean pathChanged = !newPath.equals(currentPath); boolean pathChanged = !newPath.equals(currentPath);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putBoolean(TAG, true); bundle.putBoolean(TAG, true);

View file

@ -241,7 +241,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
divider.setVisibility(View.VISIBLE); divider.setVisibility(View.VISIBLE);
secondPart.setVisibility(View.VISIBLE); secondPart.setVisibility(View.VISIBLE);
String space = getSpaceDescription(item.getDirectory()); String space = getSpaceDescription(item.getDirectory());
if (!space.equals("")) { if (!space.isEmpty()) {
space = space.replaceAll("", ""); space = space.replaceAll("", "");
tvSummary.setText(space); tvSummary.setText(space);
tvSummary.setVisibility(View.VISIBLE); tvSummary.setVisibility(View.VISIBLE);

View file

@ -76,6 +76,7 @@ import org.apache.commons.logging.Log;
import java.io.File; import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -201,7 +202,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment {
} }
adapter = new ExportImportSettingsAdapter(app, nightMode, true); adapter = new ExportImportSettingsAdapter(app, nightMode, true);
Map<ExportSettingsType, List<?>> itemsMap = new HashMap<>(); Map<ExportSettingsType, List<?>> itemsMap = new EnumMap<>(ExportSettingsType.class);
if (settingsItems != null) { if (settingsItems != null) {
itemsMap = SettingsHelper.getSettingsToOperate(settingsItems, false); itemsMap = SettingsHelper.getSettingsToOperate(settingsItems, false);
adapter.updateSettingsList(itemsMap); adapter.updateSettingsList(itemsMap);

View file

@ -897,7 +897,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} }
private boolean nameIsEmpty() { private boolean nameIsEmpty() {
return changedProfile.name.trim().equals(""); return changedProfile.name.trim().isEmpty();
} }
private void disableSaveButtonWithErrorMessage(String errorMessage) { private void disableSaveButtonWithErrorMessage(String errorMessage) {

View file

@ -137,9 +137,9 @@ public class SRTMPlugin extends OsmandPlugin {
public boolean init(@NonNull final OsmandApplication app, Activity activity) { public boolean init(@NonNull final OsmandApplication app, Activity activity) {
OsmandSettings settings = app.getSettings(); OsmandSettings settings = app.getSettings();
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines"); CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
if (pref.get().equals("")) { if (pref.get().isEmpty()) {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) { for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (pref.getModeValue(m).equals("")) { if (pref.getModeValue(m).isEmpty()) {
pref.setModeValue(m, "13"); pref.setModeValue(m, "13");
} }
} }
@ -456,7 +456,7 @@ public class SRTMPlugin extends OsmandPlugin {
List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues())); List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues()));
possibleValuesList.remove(CONTOUR_LINES_DISABLED_VALUE); possibleValuesList.remove(CONTOUR_LINES_DISABLED_VALUE);
final String[] possibleValues = possibleValuesList.toArray(new String[possibleValuesList.size()]); final String[] possibleValues = possibleValuesList.toArray(new String[0]);
int i = possibleValuesList.indexOf(pref.get()); int i = possibleValuesList.indexOf(pref.get());
if (i >= 0) { if (i >= 0) {

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

@ -86,7 +86,7 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener {
} }
public void setTitle(String title) { public void setTitle(String title) {
if (title.equals("")) { if (title.isEmpty()) {
if (pointDescription.isWpt()) { if (pointDescription.isWpt()) {
title = mapActivity.getString(R.string.waypoint_one); title = mapActivity.getString(R.string.waypoint_one);
} else if (pointDescription.isRte()) { } else if (pointDescription.isRte()) {

View file

@ -181,7 +181,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
} }
if (imageRequests.size() > 0) { if (imageRequests.size() > 0) {
executeTaskInBackground(new PointImageReaderTask(this), imageRequests.toArray(new String[imageRequests.size()])); executeTaskInBackground(new PointImageReaderTask(this), imageRequests.toArray(new String[0]));
} }
} }
mapTextLayer.putData(this, displayedPoints); mapTextLayer.putData(this, displayedPoints);

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

@ -1387,7 +1387,7 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
bld.setTitle(R.string.map_magnifier); bld.setTitle(R.string.map_magnifier);
bld.setSingleChoiceItems(values.toArray(new String[values.size()]), i, bld.setSingleChoiceItems(values.toArray(new String[0]), i,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {

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)) {

View file

@ -222,7 +222,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
@Override @Override
public List<String> execute(List<Struct> listCmd){ public List<String> execute(List<Struct> listCmd){
Struct list = new Struct(listCmd.toArray(new Term[listCmd.size()])); Struct list = new Struct(listCmd.toArray(new Term[0]));
Var result = new Var("RESULT"); //$NON-NLS-1$ Var result = new Var("RESULT"); //$NON-NLS-1$
List<String> files = new ArrayList<String>(); List<String> files = new ArrayList<String>();
if(prologSystem == null) { if(prologSystem == null) {

View file

@ -216,7 +216,7 @@ public class TravelDbHelper {
} }
query += ") "; query += ") ";
if (params.size() > 0) { if (params.size() > 0) {
SQLiteCursor cursor = conn.rawQuery(query, params.toArray(new String[params.size()])); SQLiteCursor cursor = conn.rawQuery(query, params.toArray(new String[0]));
if (cursor != null) { if (cursor != null) {
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
do { do {
@ -468,7 +468,7 @@ public class TravelDbHelper {
params.add(lang); params.add(lang);
} }
} }
SQLiteCursor cursor = conn.rawQuery(query.toString(), params.toArray(new String[params.size()])); SQLiteCursor cursor = conn.rawQuery(query.toString(), params.toArray(new String[0]));
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
do { do {
WikivoyageSearchResult rs = new WikivoyageSearchResult(); WikivoyageSearchResult rs = new WikivoyageSearchResult();

View file

@ -341,7 +341,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
res.add(item); res.add(item);
} }
} }
return res.toArray(new IndexItem[res.size()]); return res.toArray(new IndexItem[0]);
} }
@NonNull @NonNull

View file

@ -128,7 +128,7 @@ public class CurrentPositionHelper {
} }
private void initCtx(SampleApplication app, List<BinaryMapIndexReader> checkReaders) { private void initCtx(SampleApplication app, List<BinaryMapIndexReader> checkReaders) {
BinaryMapIndexReader[] rs = checkReaders.toArray(new BinaryMapIndexReader[checkReaders.size()]); BinaryMapIndexReader[] rs = checkReaders.toArray(new BinaryMapIndexReader[0]);
if (rs.length > 0) { if (rs.length > 0) {
RoutingConfiguration defCfg = RoutingConfiguration.getDefault().build("geocoding", 10, RoutingConfiguration defCfg = RoutingConfiguration.getDefault().build("geocoding", 10,
new HashMap<String, String>()); new HashMap<String, String>());

View file

@ -23,7 +23,7 @@ public class SampleFormatter {
public final static float FEET_IN_ONE_METER = YARDS_IN_ONE_METER * 3f; public final static float FEET_IN_ONE_METER = YARDS_IN_ONE_METER * 3f;
private static final DecimalFormat fixed2 = new DecimalFormat("0.00"); private static final DecimalFormat fixed2 = new DecimalFormat("0.00");
private static final DecimalFormat fixed1 = new DecimalFormat("0.0"); private static final DecimalFormat fixed1 = new DecimalFormat("0.0");
{ static {
fixed2.setMinimumFractionDigits(2); fixed2.setMinimumFractionDigits(2);
fixed1.setMinimumFractionDigits(1); fixed1.setMinimumFractionDigits(1);
fixed1.setMinimumIntegerDigits(1); fixed1.setMinimumIntegerDigits(1);