From 354354a9d42b1f39e0aafbd69d31b9b77415e03c Mon Sep 17 00:00:00 2001 From: Joel Dean Date: Wed, 13 Jun 2018 19:37:13 -0500 Subject: [PATCH] Added a function to return an instance of the current class so that PMD passes due to it failing when .this is used incorrectly. --- .../android/activities/GeoPointMapActivity.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/collect_app/src/main/java/org/odk/collect/android/activities/GeoPointMapActivity.java b/collect_app/src/main/java/org/odk/collect/android/activities/GeoPointMapActivity.java index cfc226d6a2e..bc0ee78e3ec 100644 --- a/collect_app/src/main/java/org/odk/collect/android/activities/GeoPointMapActivity.java +++ b/collect_app/src/main/java/org/odk/collect/android/activities/GeoPointMapActivity.java @@ -131,10 +131,20 @@ public void onCreate(Bundle savedInstanceState) { isMapReady = false; ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMapAsync(googleMap -> { setupMap(googleMap); - locationClient.setListener(GeoPointMapActivity.this); + locationClient.setListener(getActivity()); }); } + /** + * Utilizing GeoPointMapActivity.this for the current activity instance causes + * PMD to fail so this method prevents that. + * + * @return an instance of this activity + */ + private GeoPointMapActivity getActivity() { + return this; + } + @Override protected void onStart() { super.onStart(); @@ -241,7 +251,7 @@ public void onClick(View v) { // Menu Layer Toggle ImageButton layers = findViewById(R.id.layer_menu); - layers.setOnClickListener(v -> helper.showLayersDialog(GeoPointMapActivity.this)); + layers.setOnClickListener(v -> helper.showLayersDialog(getActivity())); zoomDialogView = getLayoutInflater().inflate(R.layout.geo_zoom_dialog, null); zoomLocationButton = zoomDialogView.findViewById(R.id.zoom_location); zoomLocationButton.setOnClickListener(v -> {