From 270e7e873d52d9ae30b7889e2a967d10d96cc8cb Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 15:17:52 -0500 Subject: [PATCH] Performance: 'Collection.toArray()' call style --- .../main/java/com/google/protobuf/ByteString.java | 2 +- .../mapbox_vector_tile/adapt/jts/MvtReader.java | 12 ++++++------ .../src/main/java/net/osmand/GPXUtilities.java | 2 +- .../main/java/net/osmand/data/Multipolygon.java | 4 ++-- .../java/net/osmand/map/TileSourceManager.java | 2 +- .../main/java/net/osmand/render/RenderingRule.java | 2 +- .../render/RenderingRuleStorageProperties.java | 2 +- .../net/osmand/render/RenderingRulesStorage.java | 4 ++-- .../main/java/net/osmand/router/GeneralRouter.java | 14 +++++++------- .../net/osmand/router/RoutePlannerFrontEnd.java | 2 +- .../net/osmand/router/RouteResultPreparation.java | 2 +- .../java/net/osmand/router/RoutingContext.java | 2 +- OsmAnd/src/net/osmand/access/NavigationInfo.java | 2 +- OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java | 4 ++-- OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java | 4 ++-- .../osmand/plus/activities/MapActivityActions.java | 2 +- .../plus/audionotes/AudioVideoNotesPlugin.java | 2 +- .../plus/dashboard/DashChooseAppDirFragment.java | 2 +- .../net/osmand/plus/dialogs/ConfigureMapMenu.java | 4 ++-- .../osmand/plus/download/DownloadFileHelper.java | 2 +- .../plus/download/ui/LocalIndexesFragment.java | 2 +- .../plus/download/ui/UpdatesIndexFragment.java | 4 ++-- .../net/osmand/plus/helpers/ExternalApiHelper.java | 2 +- .../DirectionIndicationDialogFragment.java | 2 +- .../plus/monitoring/OsmandMonitoringPlugin.java | 2 +- .../osmand/plus/myplaces/AvailableGPXFragment.java | 8 ++++---- .../osmand/plus/myplaces/TrackSegmentFragment.java | 2 +- .../src/net/osmand/plus/osmedit/AddPOIAction.java | 4 ++-- .../plus/osmedit/AdvancedEditPoiFragment.java | 4 ++-- .../net/osmand/plus/osmedit/OsmEditingPlugin.java | 2 +- .../net/osmand/plus/osmedit/OsmEditsFragment.java | 4 ++-- .../plus/osmedit/OsmEditsUploadListenerHelper.java | 2 +- .../osmedit/dialogs/PoiSubTypeDialogFragment.java | 2 +- .../osmedit/dialogs/PoiTypeDialogFragment.java | 2 +- .../net/osmand/plus/resources/ResourceManager.java | 6 +++--- .../src/net/osmand/plus/routing/RouteProvider.java | 2 +- .../src/net/osmand/plus/srtmplugin/SRTMPlugin.java | 2 +- .../net/osmand/plus/views/layers/AidlMapLayer.java | 2 +- .../osmand/plus/views/layers/MapControlsLayer.java | 2 +- .../plus/voice/AbstractPrologCommandPlayer.java | 2 +- .../plus/wikivoyage/data/TravelDbHelper.java | 4 ++-- .../wikivoyage/explore/ExploreTabFragment.java | 2 +- .../android/sample1/CurrentPositionHelper.java | 2 +- 43 files changed, 69 insertions(+), 69 deletions(-) diff --git a/OsmAnd-java/src/main/java/com/google/protobuf/ByteString.java b/OsmAnd-java/src/main/java/com/google/protobuf/ByteString.java index 73d831f6ee..cb1307d3b5 100644 --- a/OsmAnd-java/src/main/java/com/google/protobuf/ByteString.java +++ b/OsmAnd-java/src/main/java/com/google/protobuf/ByteString.java @@ -800,7 +800,7 @@ public abstract class ByteString implements Iterable { // 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; } diff --git a/OsmAnd-java/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java b/OsmAnd-java/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java index 6083ca980e..73ce9eeb12 100644 --- a/OsmAnd-java/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java +++ b/OsmAnd-java/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java @@ -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; diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index 1d1b1da020..b8835ff2c6 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -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; } diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java b/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java index bf8c0a4964..6fb6db0f3c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java @@ -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() { diff --git a/OsmAnd-java/src/main/java/net/osmand/map/TileSourceManager.java b/OsmAnd-java/src/main/java/net/osmand/map/TileSourceManager.java index 9885aa2fbf..0bdcda71c9 100644 --- a/OsmAnd-java/src/main/java/net/osmand/map/TileSourceManager.java +++ b/OsmAnd-java/src/main/java/net/osmand/map/TileSourceManager.java @@ -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) { diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java index 0ae4314dd9..b402cca664 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java @@ -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){ diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleStorageProperties.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleStorageProperties.java index 3eafb803dd..4ae767561e 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleStorageProperties.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleStorageProperties.java @@ -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 getCustomRules() { diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java index d4d97d547c..11ac95cbd5 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java @@ -492,10 +492,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){ diff --git a/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java b/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java index 537e3a5f74..e6d19c1d58 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java @@ -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() { diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index 17eb567813..74dceb13a1 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -918,7 +918,7 @@ public class RoutePlannerFrontEnd { private List 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); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index d7ebbaba8f..4df69c3adc 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -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() { @Override diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java index 3bfbaec0da..584be83bb3 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingContext.java @@ -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() { diff --git a/OsmAnd/src/net/osmand/access/NavigationInfo.java b/OsmAnd/src/net/osmand/access/NavigationInfo.java index 3e087e27ae..edd296b38a 100644 --- a/OsmAnd/src/net/osmand/access/NavigationInfo.java +++ b/OsmAnd/src/net/osmand/access/NavigationInfo.java @@ -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) { } diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index d85d6ddd68..d188a7d0ee 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -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 { @@ -643,7 +643,7 @@ public class ContextMenuAdapter { } public static OnItemDeleteAction makeDeleteAction(final List 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) { diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 2651e7b988..026987d13b 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -408,10 +408,10 @@ public class GpxSelectionHelper { boolean split = true; if (group.splitDistance > 0) { List 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 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)}; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 749c5371ea..5a6a7560a5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -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(); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index b8d4ef0c92..92b991757b 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -1860,7 +1860,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { protected Recording[] getRecordingsSorted() { checkRecordings(); Collection allObjects = getAllRecordings(); - Recording[] res = allObjects.toArray(new Recording[allObjects.size()]); + Recording[] res = allObjects.toArray(new Recording[0]); Arrays.sort(res, new Comparator() { @Override diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java index 883010ea46..e976d0b4ea 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java @@ -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 diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 858f80e018..6e3b7fba8a 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -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(); @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java index 36d2f21b85..c85d63361a 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadFileHelper.java @@ -349,7 +349,7 @@ public class DownloadFileHelper { private int currentRead = 0; public CountingMultiInputStream(List streams) { - this.delegate = streams.toArray(new InputStream[streams.size()]); + this.delegate = streams.toArray(new InputStream[0]); } @Override diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 4cf4f1154a..9160160973 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -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(); diff --git a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java index 65baa93718..f7362edc76 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java @@ -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])); } } }); diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 6222663a00..da5f6359b0 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -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); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java index d624ec7947..27ad98ece4 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java @@ -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); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index ec255b1bbc..e6c5f2ff1b 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -73,7 +73,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { super(app); liveMonitoringHelper = new LiveMonitoringHelper(app); final List 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); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 6bac2a31ea..48c1dca711 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -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 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, diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index e53b51cf39..08c68ac3e8 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -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]; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java index 1db6bd0542..a46ddb0ba1 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java @@ -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 diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index b538ccd0c5..a99afa7a22 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -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 diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 6382acb107..90da6cc65d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -415,7 +415,7 @@ public class OsmEditingPlugin extends OsmandPlugin { public void onClick(DialogInterface dialog, int which) { List selectedItems = f.getSelectedItems(); sendGPXFiles(activity, f, - selectedItems.toArray(new GpxInfo[selectedItems.size()])); + selectedItems.toArray(new GpxInfo[0])); } }); return true; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index 3c1733f7ac..e647c63f8f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -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 points = getPointsToExport(); new BackupOpenstreetmapPointAsyncTask(type, exportType).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, - points.toArray(new OsmPoint[points.size()])); + points.toArray(new OsmPoint[0])); } }; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java index 1d09b522ab..4b6078265d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java @@ -221,7 +221,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); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java index 53b9ce0677..4c75a384ae 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java index cdcf88fb0a..2278d8e8bd 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiTypeDialogFragment.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index a87d5004bd..b70ded655b 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -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 getIndexFileNames() { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index a21b8898e6..37bb29d148 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -121,7 +121,7 @@ public class RouteProvider { list.add(r); } } - return list.toArray(new RouteService[list.size()]); + return list.toArray(new RouteService[0]); } } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index 7035a18863..9e66f72f74 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -456,7 +456,7 @@ public class SRTMPlugin extends OsmandPlugin { List 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) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java index 580f0c3490..df110a14cb 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 6a4cf344c7..9a24d0aba6 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java b/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java index fe17c52ab5..b0b0be8baf 100644 --- a/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java +++ b/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java @@ -222,7 +222,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat @Override public List execute(List 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 files = new ArrayList(); if(prologSystem == null) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 8ed755cf50..df591f4020 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -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(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index bedaa96810..88e814773b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -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 diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java index e490925754..9be931434e 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java @@ -128,7 +128,7 @@ public class CurrentPositionHelper { } private void initCtx(SampleApplication app, List 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());