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
// the lock for as short a time as possible.
cachedFlushBuffers =
flushedBuffers.toArray(new ByteString[flushedBuffers.size()]);
flushedBuffers.toArray(new ByteString[0]);
cachedBuffer = buffer;
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
// the list's contents after setting it.
final List newList = new ArrayList();
newList.addAll((List) value);
final List newList = new ArrayList((List) value);
for (final Object element : newList) {
verifyType(descriptor.getLiteType(), element);
}

View file

@ -345,7 +345,6 @@ public final class JtsAdapter {
for(int i = 0; i < geom.getNumGeometries(); ++i) {
final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
final List<Integer> nextPolyGeom = new ArrayList<>();
boolean valid = true;
// Add exterior ring
@ -362,7 +361,7 @@ public final class JtsAdapter {
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

View file

@ -322,7 +322,7 @@ public final class MvtReader {
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);
} 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 (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();
}
@ -533,7 +533,7 @@ public final class MvtReader {
if (outerPoly != null) {
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;
@ -569,7 +569,7 @@ public final class MvtReader {
if (outerPoly == null || (outerArea < 0 == area < 0)) {
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();
}
@ -590,7 +590,7 @@ public final class MvtReader {
if (outerPoly != null) {
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;

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;
}

View file

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

View file

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

View file

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

View file

@ -329,7 +329,7 @@ public class RouteDataObject {
public String getDestinationName(String lang, boolean transliterate, boolean direction){
//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 destRef1 = ("".equals(destRef)) ? "" : destRef + ", ";
String destRef1 = Algorithms.isEmpty(destRef) ? "" : destRef + ", ";
if(names != null) {
int[] kt = names.keys();
@ -373,7 +373,7 @@ public class RouteDataObject {
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault);
}
}
return "".equals(destRef) ? null : destRef;
return Algorithms.isEmpty(destRef) ? null : destRef;
}
public int getPoint31XTile(int i) {

View file

@ -61,9 +61,9 @@ public class Multipolygon {
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() {

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

View file

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

View file

@ -33,9 +33,10 @@ public class EntityParser {
if (mo.getEnName(false).length() == 0) {
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())) {
mo.setName(ts.substring(("name:").length()), tags.get(ts));
mo.setName(ts.substring(("name:").length()), entry.getValue());
}
}
if (mo.getName().length() == 0) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -754,21 +754,21 @@ public class GeneralRouter implements VehicleRouter {
}
public RouteAttributeEvalRule[] getRules() {
return rules.toArray(new RouteAttributeEvalRule[rules.size()]);
return rules.toArray(new RouteAttributeEvalRule[0]);
}
public String[] getParamKeys() {
if(paramContext == null) {
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() {
if(paramContext == null) {
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) {
@ -988,19 +988,19 @@ public class GeneralRouter implements VehicleRouter {
public RouteAttributeExpression[] getExpressions() {
return expressions.toArray(new RouteAttributeExpression[expressions.size()]);
return expressions.toArray(new RouteAttributeExpression[0]);
}
public String[] getParameters() {
return parameters.toArray(new String[parameters.size()]);
return parameters.toArray(new String[0]);
}
public String[] getTagValueCondDefTag() {
return tagValueCondDefTag.toArray(new String[tagValueCondDefTag.size()]);
return tagValueCondDefTag.toArray(new String[0]);
}
public String[] getTagValueCondDefValue() {
return tagValueCondDefValue.toArray(new String[tagValueCondDefValue.size()]);
return tagValueCondDefValue.toArray(new String[0]);
}
public boolean[] getTagValueCondDefNot() {

View file

@ -918,7 +918,7 @@ public class RoutePlannerFrontEnd {
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, RouteSegment recalculationEnd) throws IOException {
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.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>() {
@Override

View file

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

View file

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

View file

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

View file

@ -62,7 +62,7 @@ public class GeoPointParserUtil {
private static Map<String, String> getQueryParameters(String query) {
final LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
if (query != null && !query.equals("")) {
if (query != null && !query.isEmpty()) {
String[] params = query.split("[&/]");
for (String p : params) {
String[] keyValue = p.split("=");
@ -803,10 +803,10 @@ public class GeoPointParserUtil {
if (map.size() > 0)
uriString += "?";
int i = 0;
for (String key : map.keySet()) {
for (Map.Entry<String, String> entry : map.entrySet()) {
if (i > 0)
uriString += "&";
uriString += key + "=" + map.get(key);
uriString += entry.getKey() + "=" + entry.getValue();
i++;
}
return uriString;

View file

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

View file

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

View file

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

View file

@ -190,14 +190,15 @@ class AppVersionUpgradeOnInit {
migrateEnumPreferences();
SharedPreferences globalSharedPreferences = (SharedPreferences) settings.getGlobalPreferences();
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);
if (pref instanceof CommonPreference) {
CommonPreference<?> commonPreference = (CommonPreference<?>) pref;
if (!commonPreference.isGlobal()) {
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
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);
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);
if (pref instanceof CommonPreference) {
CommonPreference<?> commonPreference = (CommonPreference<?>) pref;
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);
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> {
@ -643,7 +643,7 @@ public class ContextMenuAdapter {
}
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) {

View file

@ -261,10 +261,11 @@ public class FavouritesDbHelper {
private boolean merge(Map<String, FavouritePoint> source, Map<String, FavouritePoint> destination) {
boolean changed = false;
for (String ks : source.keySet()) {
for (Map.Entry<String, FavouritePoint> entry : source.entrySet()) {
String ks = entry.getKey();
if (!destination.containsKey(ks)) {
changed = true;
destination.put(ks, source.get(ks));
destination.put(ks, entry.getValue());
}
}
return changed;
@ -360,7 +361,7 @@ public class FavouritesDbHelper {
}
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;
}
if (!p.isAddressSpecified()) {
@ -369,7 +370,7 @@ public class FavouritesDbHelper {
context.getSettings().SHOW_FAVORITES.set(true);
FavoriteGroup group = getOrCreateGroup(p, 0);
if (!p.getName().equals("")) {
if (!p.getName().isEmpty()) {
p.setVisible(group.visible);
if (FavouritePoint.SpecialPointType.PARKING.equals(p.getSpecialPointType())) {
p.setColor(ContextCompat.getColor(context, R.color.parking_icon_background));
@ -712,9 +713,10 @@ public class FavouritesDbHelper {
public boolean isGroupVisible(String name) {
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)) {
return flatGroups.get(groupName).isVisible();
return entry.getValue().isVisible();
}
}
return false;
@ -968,7 +970,7 @@ public class FavouritesDbHelper {
p.setName(name);
p.setCategory(cat);
FavoriteGroup group = getOrCreateGroup(p, 0);
if (!name.equals("")) {
if (!name.isEmpty()) {
p.setLatitude(query.getDouble(2));
p.setLongitude(query.getDouble(3));
group.points.add(p);
@ -1012,7 +1014,7 @@ public class FavouritesDbHelper {
public boolean addFavouriteDB(FavouritePoint p) {
if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) {
if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) {
return true;
}
SQLiteConnection db = openConnection(false);
@ -1022,7 +1024,7 @@ public class FavouritesDbHelper {
"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$
FavoriteGroup group = getOrCreateGroup(p, 0);
if (!p.getName().equals("")) {
if (!p.getName().isEmpty()) {
p.setVisible(group.visible);
p.setColor(group.color);
group.points.add(p);

View file

@ -408,10 +408,10 @@ public class GpxSelectionHelper {
boolean split = true;
if (group.splitDistance > 0) {
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) {
List<GPXTrackAnalysis> trackSegments = r.splitByTime(group.splitTime, joinSegments);
as = trackSegments.toArray(new GPXTrackAnalysis[trackSegments.size()]);
as = trackSegments.toArray(new GPXTrackAnalysis[0]);
} else {
split = false;
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 EAST = 'E';
{
static {
fixed2.setMinimumFractionDigits(2);
fixed1.setMinimumFractionDigits(1);
fixed1.setMinimumIntegerDigits(1);

View file

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

View file

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

View file

@ -176,7 +176,7 @@ public class HelpActivity extends OsmandActionBarActivity implements AdapterView
"feature_articles/osmand-3-8-released.html"));
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);
}
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.shared_string_show_details));
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
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();

View file

@ -208,11 +208,13 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
Map<String, GPXFile> data = collectRecordedData();
// 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);
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
if (!data.get(f).isEmpty()) {
WptPt pt = data.get(f).findPointToShow();
if (!gpx.isEmpty()) {
WptPt pt = gpx.findPointToShow();
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();
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) {
warnings.add(warn.getMessage());
return new SaveGpxResult(warnings, new ArrayList<String>());
}
GPXFile gpx = data.get(f);
GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified());
GpxDataItem item = new GpxDataItem(fout, analysis);
ctx.getGpxDbHelper().add(item);

View file

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

View file

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

View file

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

View file

@ -1860,7 +1860,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
protected Recording[] getRecordingsSorted() {
checkRecordings();
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>() {
@Override

View file

@ -223,7 +223,7 @@ public class DashChooseAppDirFragment {
paths.add("");
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() {
@Override

View file

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

View file

@ -404,7 +404,7 @@ public class ConfigureMapMenu {
bld.setTitle(R.string.map_magnifier);
bld.setNegativeButton(R.string.shared_string_dismiss, null);
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
public void onClick(View v) {
int which = (int) v.getTag();
@ -481,7 +481,7 @@ public class ConfigureMapMenu {
.createItem());
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;
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity)
.setId(MAP_LANGUAGE_ID)
@ -570,7 +570,7 @@ public class ConfigureMapMenu {
txtIds[index]);
refreshMapComplete(activity);
String localeDescr = txtIds[index];
localeDescr = localeDescr == null || localeDescr.equals("") ? activity
localeDescr = localeDescr == null || localeDescr.isEmpty() ? activity
.getString(R.string.local_map_names) : localeDescr;
adapter.getItem(pos).setDescription(localeDescr);
ad.notifyDataSetInvalidated();
@ -639,7 +639,7 @@ public class ConfigureMapMenu {
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) {

View file

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

View file

@ -582,7 +582,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
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) {
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() {
@Override
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();
} 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(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);
}

View file

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

View file

@ -513,10 +513,9 @@ public class ImportHelper {
private File getFileToSave(final String fileName, final File importDir, final WptPt pt) {
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$
}
if (fileName.endsWith(KML_SUFFIX)) {
} else if (fileName.endsWith(KML_SUFFIX)) {
builder.replace(builder.length() - KML_SUFFIX.length(), builder.length(), GPX_FILE_EXT);
} else if (fileName.endsWith(KMZ_SUFFIX)) {
builder.replace(builder.length() - KMZ_SUFFIX.length(), builder.length(), GPX_FILE_EXT);

View file

@ -367,8 +367,7 @@ public class MenuBuilder {
@Override
public void onFinish(List<ImageCard> cardList) {
if (!isHidden()) {
List<AbstractCard> cards = new ArrayList<>();
cards.addAll(cardList);
List<AbstractCard> cards = new ArrayList<AbstractCard>(cardList);
if (cardList.size() == 0) {
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);
textView.setAdapter(new MapillaryAutoCompleteAdapter(getContext(), R.layout.auto_complete_suggestion, getMyApplication()));
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.setSelection(selectedUsername.length());
}
@ -261,16 +261,16 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
String dateFrom = dateFromEt.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);
}
if (dateFrom.equals("")) {
if (dateFrom.isEmpty()) {
settings.MAPILLARY_FILTER_FROM_DATE.set(0L);
}
if (dateTo.equals("")) {
if (dateTo.isEmpty()) {
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);
} else {
mapActivity.getDashboard().hideDashboard();

View file

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

View file

@ -277,7 +277,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
}
}
((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 {
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();
for (String category : pointsByCategories.keySet()) {
for (Map.Entry<String, List<WptPt>> entry : pointsByCategories.entrySet()) {
String category = entry.getKey();
final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1];
categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(!isUpdateMode || (categories != null && categories.contains(category)))
@ -96,9 +97,9 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
}
})
.setCompoundButtonColorId(activeColorResId)
.setDescription(String.valueOf(pointsByCategories.get(category).size()))
.setDescription(String.valueOf(entry.getValue().size()))
.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)
.setTag(category)
.setOnClickListener(new View.OnClickListener() {

View file

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

View file

@ -403,7 +403,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
final GroupHeader groupHeader = (GroupHeader) header;
final MapMarkersGroup group = groupHeader.getGroup();
String groupName = group.getName();
if (groupName.equals("")) {
if (groupName.isEmpty()) {
groupName = app.getString(R.string.shared_string_favorites);
} else if (group.getType() == MapMarkersGroup.GPX_TYPE) {
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();
while (it.hasNext()) {
String category = it.next();
if (category.equals("")) {
if (category.isEmpty()) {
category = app.getResources().getString(R.string.shared_string_waypoints);
}
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 markerGroupName = marker.groupName;
if (markerGroupName != null) {
if (markerGroupName.equals("")) {
if (markerGroupName.isEmpty()) {
markerGroupName = app.getString(R.string.shared_string_favorites);
}
desc += "" + markerGroupName;

View file

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

View file

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

View file

@ -73,7 +73,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
super(app);
liveMonitoringHelper = new LiveMonitoringHelper(app);
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();
pluginPreferences.add(settings.SAVE_TRACK_TO_GPX);
pluginPreferences.add(settings.SAVE_TRACK_INTERVAL);

View file

@ -554,7 +554,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
public void doAction(int actionResId) {
if (actionResId == R.string.shared_string_delete) {
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 {
operationTask = null;
}
@ -1009,7 +1009,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
List<GpxInfo> progress = new ArrayList<>();
loadGPXFolder(mapPath, result, loadTask, progress, "");
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);
progress.add(info);
if (progress.size() > 7) {
loadTask.loadFile(progress.toArray(new GpxInfo[progress.size()]));
loadTask.loadFile(progress.toArray(new GpxInfo[0]));
progress.clear();
}
}
@ -1475,7 +1475,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
list.add(GPXDataSetType.SLOPE);
}
if (list.size() > 0) {
gpxItem.chartTypes = list.toArray(new GPXDataSetType[list.size()]);
gpxItem.chartTypes = list.toArray(new GPXDataSetType[0]);
}
final OsmandSettings settings = app.getSettings();
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);
}
}
tabTypes = tabTypeList.toArray(new GPXTabItemType[tabTypeList.size()]);
tabTypes = tabTypeList.toArray(new GPXTabItemType[0]);
Context context = tabs.getContext();
titles = new String[tabTypes.length];

View file

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

View file

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

View file

@ -427,8 +427,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
f.setArguments(args);
f.show(getChildFragmentManager(), "exceedDialog");
} 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()))) {
SaveExtraValidationDialogFragment f = new SaveExtraValidationDialogFragment();
Bundle args = new Bundle();

View file

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

View file

@ -296,7 +296,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
uploadItems(osmEditsSelected.toArray(new OsmPoint[osmEditsSelected.size()]));
uploadItems(osmEditsSelected.toArray(new OsmPoint[0]));
mode.finish();
return true;
}
@ -594,7 +594,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial
public void onClick(int type) {
List<OsmPoint> points = getPointsToExport();
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
public void uploadEnded(Map<OsmPoint, String> loadErrorsMap) {
super.uploadEnded(loadErrorsMap);
for (OsmPoint osmPoint : loadErrorsMap.keySet()) {
if (loadErrorsMap.get(osmPoint) == null) {
osmEdits.remove(osmPoint);
for (Map.Entry<OsmPoint, String> entry : loadErrorsMap.entrySet()) {
if (entry.getValue() == null) {
osmEdits.remove(entry.getKey());
}
}
recreateAdapterData();

View file

@ -59,8 +59,8 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
}
int uploaded = 0;
int pointsNum = loadErrorsMap.keySet().size();
for (OsmPoint point : loadErrorsMap.keySet()) {
if (loadErrorsMap.get(point) == null) {
for (String s : loadErrorsMap.values()) {
if (s == null) {
uploaded++;
}
}
@ -200,13 +200,14 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
boolean[] hasErrors = new boolean[loadErrorsMap.keySet().size()];
ArrayList<OsmPoint> pointsWithErrors = new ArrayList<>();
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 ?
((OsmNotesPoint) point).getText() :
((OpenstreetmapPoint) point).getName();
pointNames[i] = TextUtils.isEmpty(pointNames[i]) ?
"id:" + point.getId() : pointNames[i];
hasErrors[i] = loadErrorsMap.get(point) != null;
hasErrors[i] = entry.getValue() != null;
if (hasErrors[i]) {
pointsWithErrors.add(point);
}
@ -221,7 +222,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
new UploadingMultipleErrorDialogFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(POINTS_WITH_ERRORS,
pointsWithErrors.toArray(new OsmPoint[pointsWithErrors.size()]));
pointsWithErrors.toArray(new OsmPoint[0]));
bundle.putStringArray(POINT_NAMES, pointNames);
bundle.putBooleanArray(HAS_ERROR, hasErrors);
fragment.setArguments(bundle);

View file

@ -36,7 +36,7 @@ public class PoiSubTypeDialogFragment extends DialogFragment {
} else {
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() {
@Override
public void onClick(DialogInterface dialog, int which) {

View file

@ -31,7 +31,7 @@ public class PoiTypeDialogFragment extends DialogFragment {
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
public void onClick(DialogInterface dialog, int which) {
PoiCategory aType = categories.get(which);

View file

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

View file

@ -84,7 +84,7 @@ public class SendPoiDialogFragment extends DialogFragment {
messageLabel.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
messageEditText.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);
uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@ -233,7 +233,7 @@ public class SendPoiDialogFragment extends DialogFragment {
}
if (modifiedItemsOutOfLimit != 0) {
comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ").concat(getString(R.string.items_modified)).concat(".");
} else if (!comment.equals("")){
} else if (!comment.isEmpty()){
comment = comment.concat(".");
}
return comment;

View file

@ -231,9 +231,8 @@ public class PoiFiltersHelper {
public List<PoiUIFilter> getTopDefinedPoiFilters(boolean includeDeleted) {
List<PoiUIFilter> top = this.cacheTopStandardFilters;
if (top == null) {
top = new ArrayList<>();
// user defined
top.addAll(getUserDefinedPoiFilters(true));
top = new ArrayList<>(getUserDefinedPoiFilters(true));
// default
MapPoiTypes poiTypes = application.getPoiTypes();
for (AbstractPoiType t : poiTypes.getTopVisibleFilters()) {
@ -751,14 +750,15 @@ public class PoiFiltersHelper {
}
Map<PoiCategory, LinkedHashSet<String>> types = p.getAcceptedTypes();
SQLiteStatement insertCategories = db.compileStatement("INSERT INTO " + CATEGORIES_NAME + " VALUES (?, ?, ?)");
for (PoiCategory a : types.keySet()) {
if (types.get(a) == null) {
for (Map.Entry<PoiCategory, LinkedHashSet<String>> entry : types.entrySet()) {
PoiCategory a = entry.getKey();
if (entry.getValue() == null) {
insertCategories.bindString(1, p.getFilterId());
insertCategories.bindString(2, a.getKeyName());
insertCategories.bindNull(3);
insertCategories.execute();
} else {
for (String s : types.get(a)) {
for (String s : entry.getValue()) {
insertCategories.bindString(1, p.getFilterId());
insertCategories.bindString(2, a.getKeyName());
insertCategories.bindString(3, s);

View file

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

View file

@ -311,8 +311,9 @@ public class MapRenderRepositories {
}
boolean containsJapanMapData = false;
boolean useLive = context.getSettings().USE_OSM_LIVE_FOR_ROUTING.get();
for (String mapName : files.keySet()) {
BinaryMapIndexReader fr = files.get(mapName);
for (Map.Entry<String, BinaryMapIndexReader> entry : files.entrySet()) {
String mapName = entry.getKey();
BinaryMapIndexReader fr = entry.getValue();
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) {
if (!nativeFiles.contains(mapName)) {
@ -727,7 +728,7 @@ public class MapRenderRepositories {
currentRenderingContext.height = requestedBox.getPixHeight();
currentRenderingContext.nightMode = nightMode;
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.transliterate =
!languagesNotTransliterateOnBasemap.contains(app.getLanguage());

View file

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

View file

@ -486,7 +486,7 @@ public class ResourceManager {
try {
progress.startTask(context.getString(R.string.installing_new_resources), -1);
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);
context.getSettings().PREVIOUS_INSTALLED_VERSION.set(fv);
copyRegionsBoundaries();
@ -1100,7 +1100,7 @@ public class ResourceManager {
}
}
}
return readers.toArray(new BinaryMapIndexReader[readers.size()]);
return readers.toArray(new BinaryMapIndexReader[0]);
}
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() {
@ -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() {

View file

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

View file

@ -121,7 +121,7 @@ public class RouteProvider {
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.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@ -820,7 +821,7 @@ public class SettingsHelper {
}
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<QuickAction> quickActions = new ArrayList<>();
List<PoiUIFilter> poiUIFilters = new ArrayList<>();

View file

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

View file

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

View file

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

View file

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

View file

@ -897,7 +897,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
}
private boolean nameIsEmpty() {
return changedProfile.name.trim().equals("");
return changedProfile.name.trim().isEmpty();
}
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) {
OsmandSettings settings = app.getSettings();
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
if (pref.get().equals("")) {
if (pref.get().isEmpty()) {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (pref.getModeValue(m).equals("")) {
if (pref.getModeValue(m).isEmpty()) {
pref.setModeValue(m, "13");
}
}
@ -456,7 +456,7 @@ public class SRTMPlugin extends OsmandPlugin {
List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues()));
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());
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) {
for(String filename : fileModified.keySet()) {
for(Map.Entry<String, Long> entry : fileModified.entrySet()) {
String filename = entry.getKey();
try {
log.info("Indexing " + type + " file " + filename);
ContentValues cv = new ContentValues();
cv.put("filename", filename);
cv.put("date_modified", fileModified.get(filename));
cv.put("date_modified", entry.getValue());
SQLiteTileSource ts = rs.get(filename);
QuadRect rt = ts.getRectBoundary(ZOOM_BOUNDARY, 1);
if (rt != null) {

View file

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

View file

@ -181,7 +181,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
}
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);

View file

@ -232,20 +232,22 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) {
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 y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
BackgroundType background = pressedLatLonSmall.get(latLon);
BackgroundType background = entry.getValue();
Bitmap pressedBitmapSmall = background.getTouchBackground(activity, true);
Rect destRect = getIconDestinationRect(
x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), textScale);
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 y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
BackgroundType background = pressedLatLonFull.get(latLon);
BackgroundType background = entry.getValue();
Bitmap pressedBitmap = background.getTouchBackground(activity, false);
int offsetY = background.getOffsetY(activity, textScale);
Rect destRect = getIconDestinationRect(

View file

@ -1387,7 +1387,7 @@ public class MapControlsLayer extends OsmandMapLayer {
}
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() {
@Override
public void onClick(DialogInterface dialog, int which) {

View file

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

View file

@ -222,7 +222,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
@Override
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$
List<String> files = new ArrayList<String>();
if(prologSystem == null) {

View file

@ -216,7 +216,7 @@ public class TravelDbHelper {
}
query += ") ";
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.moveToFirst()) {
do {
@ -468,7 +468,7 @@ public class TravelDbHelper {
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()) {
do {
WikivoyageSearchResult rs = new WikivoyageSearchResult();

View file

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

View file

@ -128,7 +128,7 @@ public class CurrentPositionHelper {
}
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) {
RoutingConfiguration defCfg = RoutingConfiguration.getDefault().build("geocoding", 10,
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;
private static final DecimalFormat fixed2 = new DecimalFormat("0.00");
private static final DecimalFormat fixed1 = new DecimalFormat("0.0");
{
static {
fixed2.setMinimumFractionDigits(2);
fixed1.setMinimumFractionDigits(1);
fixed1.setMinimumIntegerDigits(1);