<NME> NavigateAnyPointActivity.java
<BEF> package cgeo.geocaching;

import cgeo.geocaching.activity.AbstractActionBarActivity;
import cgeo.geocaching.connector.internal.InternalConnector;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.list.StoredList;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.models.Geocache;
import cgeo.geocaching.models.Waypoint;
import cgeo.geocaching.storage.DataStore;
import cgeo.geocaching.ui.GeoItemSelectorUtils;
import cgeo.geocaching.ui.dialog.Dialogs;
import cgeo.geocaching.utils.Log;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;

import java.util.ArrayList;

import de.k3b.geo.api.GeoPointDto;
import de.k3b.geo.api.IGeoPointInfo;
import de.k3b.geo.io.GeoUri;

public class NavigateAnyPointActivity extends AbstractActionBarActivity {
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTheme(R.style.cgeo);

        InternalConnector.assertHistoryCacheExists(this);

        // check if "geo" action is requested
        boolean geoActionRequested = false;
        if (getIntent() != null) {
            final GeoUri parser = new GeoUri(GeoUri.OPT_DEFAULT);
            final IGeoPointInfo geo = parser.fromUri(getIntent().getDataString());
            if (geo != null && !GeoPointDto.isEmpty(geo)) {
                Log.i("Received a geo intent: lat=" + geo.getLatitude()
                        + ", lon=" + geo.getLongitude() + ", name=" + geo.getName()
                        + " form " + getIntent().getDataString());

        @Override
        public View getView(final int position, final View convertView, final ViewGroup parent) {

            Destination loc = getItem(position);

            View v = convertView;

            if (v == null) {
                v = getInflater().inflate(R.layout.simple_way_point,
                        null);
            }
            TextView longitude = (TextView) v
                    .findViewById(R.id.simple_way_point_longitude);
            TextView latitude = (TextView) v
                    .findViewById(R.id.simple_way_point_latitude);
            TextView date = (TextView) v.findViewById(R.id.date);

            String lonString = loc.getCoords().format(GeopointFormatter.Format.LON_DECMINUTE);
            String latString = loc.getCoords().format(GeopointFormatter.Format.LAT_DECMINUTE);

            @SuppressLint("SetTextI18n")
            latitude.setText(latString);
            date.setText(Formatter.formatShortDateTime(getContext(), loc.getDate()));

            return v;
        }

        private LayoutInflater getInflater() {

                    final TextView title = (TextView) view.findViewById(R.id.text);
                    title.setText("<" + context.getString(R.string.create_internal_cache_short) + ">");

                    final TextView info = (TextView) view.findViewById(R.id.info);
                    info.setText(context.getString(R.string.create_internal_cache));

                    return view;
                }
    private Button lonButton = null;
    private boolean changed = false;
    private List<Destination> historyOfSearchedLocations;
    private DestinationHistoryAdapter destionationHistoryAdapter;
    private ListView historyListView;
    private TextView historyFooter;

                .setTitle(R.string.add_target_to)
                .setAdapter(adapter, (dialog1, which) -> {
                    final String geocode;

    private int contextMenuItemPosition;

    String distanceUnit = "";

    @Override
    public void onCreate(Bundle savedInstanceState) {
                        final Waypoint newWaypoint = new Waypoint(null != name ? name : Waypoint.getDefaultWaypointName(cache, WaypointType.WAYPOINT), WaypointType.WAYPOINT, true);
                        newWaypoint.setCoords(new Geopoint(latitude, longitude));
                        newWaypoint.setGeocode(geocode);
                        cache.addOrChangeWaypoint(newWaypoint, true);
                    }
                    CacheDetailActivity.startActivity(context, geocode, which != 0);
                    context.finish();
                })
                .create();
        dialog.setCanceledOnTouchOutside(true);
        dialog.show();
    }

}
    }

    private DestinationHistoryAdapter getDestionationHistoryAdapter() {
        if (destionationHistoryAdapter == null) {
            destionationHistoryAdapter = new DestinationHistoryAdapter(this,
                    getHistoryOfSearchedLocations());
        }
        return destionationHistoryAdapter;
    }

    private List<Destination> getHistoryOfSearchedLocations() {
        init();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onStop() {
        super.onStop();
    }

    @Override
    public void onPause() {
        geoDirHandler.stopGeo();

<MSG> refactoring: code cleanup
<DFF> @@ -52,21 +52,18 @@ public class NavigateAnyPointActivity extends AbstractActivity {
 
         @Override
         public View getView(final int position, final View convertView, final ViewGroup parent) {
-
-            Destination loc = getItem(position);
-
-            View v = convertView;
-
-            if (v == null) {
-                v = getInflater().inflate(R.layout.simple_way_point,
+            View rowView = convertView;
+            if (rowView == null) {
+                rowView = getInflater().inflate(R.layout.simple_way_point,
                         null);
             }
-            TextView longitude = (TextView) v
+            TextView longitude = (TextView) rowView
                     .findViewById(R.id.simple_way_point_longitude);
-            TextView latitude = (TextView) v
+            TextView latitude = (TextView) rowView
                     .findViewById(R.id.simple_way_point_latitude);
-            TextView date = (TextView) v.findViewById(R.id.date);
+            TextView date = (TextView) rowView.findViewById(R.id.date);
 
+            Destination loc = getItem(position);
             String lonString = loc.getCoords().format(GeopointFormatter.Format.LON_DECMINUTE);
             String latString = loc.getCoords().format(GeopointFormatter.Format.LAT_DECMINUTE);
 
@@ -74,7 +71,7 @@ public class NavigateAnyPointActivity extends AbstractActivity {
             latitude.setText(latString);
             date.setText(Formatter.formatShortDateTime(getContext(), loc.getDate()));
 
-            return v;
+            return rowView;
         }
 
         private LayoutInflater getInflater() {
@@ -90,7 +87,7 @@ public class NavigateAnyPointActivity extends AbstractActivity {
     private Button lonButton = null;
     private boolean changed = false;
     private List<Destination> historyOfSearchedLocations;
-    private DestinationHistoryAdapter destionationHistoryAdapter;
+    private DestinationHistoryAdapter destinationHistoryAdapter;
     private ListView historyListView;
     private TextView historyFooter;
 
@@ -100,7 +97,7 @@ public class NavigateAnyPointActivity extends AbstractActivity {
 
     private int contextMenuItemPosition;
 
-    String distanceUnit = "";
+    private String distanceUnit = "";
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -190,11 +187,11 @@ public class NavigateAnyPointActivity extends AbstractActivity {
     }
 
     private DestinationHistoryAdapter getDestionationHistoryAdapter() {
-        if (destionationHistoryAdapter == null) {
-            destionationHistoryAdapter = new DestinationHistoryAdapter(this,
+        if (destinationHistoryAdapter == null) {
+            destinationHistoryAdapter = new DestinationHistoryAdapter(this,
                     getHistoryOfSearchedLocations());
         }
-        return destionationHistoryAdapter;
+        return destinationHistoryAdapter;
     }
 
     private List<Destination> getHistoryOfSearchedLocations() {
@@ -220,16 +217,6 @@ public class NavigateAnyPointActivity extends AbstractActivity {
         init();
     }
 
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-    }
-
-    @Override
-    public void onStop() {
-        super.onStop();
-    }
-
     @Override
     public void onPause() {
         geoDirHandler.stopGeo();

refactoring: code cleanup