From 68c24c47e39ad02ea9c6c69106135938c918bc91 Mon Sep 17 00:00:00 2001 From: sonalyadav Date: Thu, 19 Dec 2024 19:30:44 +0530 Subject: [PATCH] added condition in if statement --- .../free/nrw/commons/explore/map/ExploreMapPresenter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapPresenter.java b/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapPresenter.java index 94b9cf5ad..3d882377a 100644 --- a/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapPresenter.java +++ b/app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapPresenter.java @@ -205,17 +205,17 @@ public class ExploreMapPresenter * @return Returns true if search this area button is used around our current location */ public boolean searchCloseToCurrentLocation() { - if (null == exploreMapFragmentView.getLastMapFocus()) { + if (exploreMapFragmentView.getLastMapFocus() == null || exploreMapFragmentView.getMapFocus() == null) { return true; } - Location mylocation = new Location(""); - Location dest_location = new Location(""); + final Location mylocation = new Location(""); + final Location dest_location = new Location(""); dest_location.setLatitude(exploreMapFragmentView.getMapFocus().getLatitude()); dest_location.setLongitude(exploreMapFragmentView.getMapFocus().getLongitude()); mylocation.setLatitude(exploreMapFragmentView.getLastMapFocus().getLatitude()); mylocation.setLongitude(exploreMapFragmentView.getLastMapFocus().getLongitude()); - Float distance = mylocation.distanceTo(dest_location); + final float distance = mylocation.distanceTo(dest_location); if (distance > 2000.0 * 3 / 4) { return false;