<NME> NavigationLayer.java
<BEF> package cgeo.geocaching.maps.mapsforge.v6.layers;

import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.routing.Routing;
import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.utils.MapLineUtils;

import android.location.Location;

import org.mapsforge.core.graphics.Canvas;
import org.mapsforge.core.graphics.Paint;
import org.mapsforge.core.graphics.Path;
import org.mapsforge.core.graphics.Style;
import org.mapsforge.core.model.BoundingBox;
import org.mapsforge.core.model.Point;
import org.mapsforge.core.util.MercatorProjection;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.layer.Layer;

public class NavigationLayer extends Layer {

    private Geopoint currentCoords;
    private Geopoint destinationCoords;

    private Paint paint = null;
    private PostRealDistance postRealDistance = null;

    public interface PostRealDistance {
        void postRealDistance(float realDistance);
    }

    public NavigationLayer(final Geopoint coords, final PostRealDistance postRealDistance) {
        this.destinationCoords = coords;
        this.postRealDistance = postRealDistance;
        resetColor();
    }

    public void resetColor() {
        paint = AndroidGraphicFactory.INSTANCE.createPaint();
        paint.setStrokeWidth(MapLineUtils.getDirectionLineWidth(false));
        paint.setStyle(Style.STROKE);
        paint.setColor(MapLineUtils.getDirectionColor());
        paint.setTextSize(20);
    }

    public void setDestination(final Geopoint coords) {
        destinationCoords = coords;
    }

    public void setCoordinates(final Location coordinatesIn) {
        currentCoords = new Geopoint(coordinatesIn);
    }

    @Override
    public void draw(final BoundingBox boundingBox, final byte zoomLevel, final Canvas canvas, final Point topLeftPoint) {
        if (destinationCoords == null || currentCoords == null || !Settings.isMapDirection()) {
            return;
        }

        final long mapSize = MercatorProjection.getMapSize(zoomLevel, this.displayModel.getTileSize());

        final Geopoint[] routingPoints = Routing.getTrack(currentCoords, destinationCoords);
        final long mapSize = MercatorProjection.getMapSize(zoomLevel, this.displayModel.getTileSize());

        final Geopoint[] routingPoints = Routing.getTrack(currentCoords, destinationCoords);
        final ArrayList<Pair<Integer, Integer>> pixelPoints = new ArrayList<>();

        for (final Geopoint geopoint : routingPoints) {
            pixelPoints.add(translateToPixels(mapSize, topLeftPoint, geopoint));
        }
        canvas.drawPath(path, paint);

        // calculate distance
        if (null != postRealDistance && routingPoints.length > 1) {
            float distance = 0.0f;
            for (int i = 1; i < routingPoints.length; i++) {
                distance += routingPoints[i - 1].distanceTo(routingPoints[i]);
            }
            postRealDistance.postRealDistance(distance);
        }
    }

}

<MSG> Create ArrayList objects with the right capacity

<DFF> @@ -63,7 +63,7 @@ public class NavigationLayer extends Layer {
         final long mapSize = MercatorProjection.getMapSize(zoomLevel, this.displayModel.getTileSize());
 
         final Geopoint[] routingPoints = Routing.getTrack(currentCoords, destinationCoords);
-        final ArrayList<Pair<Integer, Integer>> pixelPoints = new ArrayList<>();
+        final ArrayList<Pair<Integer, Integer>> pixelPoints = new ArrayList<>(routingPoints.length);
 
         for (final Geopoint geopoint : routingPoints) {
             pixelPoints.add(translateToPixels(mapSize, topLeftPoint, geopoint));

Create ArrayList objects with the right capacity