diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java index e0a65e1a5..34715183f 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java @@ -1,8 +1,12 @@ package fr.free.nrw.commons.nearby; + +import android.content.Context; + import android.content.DialogInterface; import android.content.Intent; import android.location.LocationManager; + import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; @@ -14,6 +18,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.ProgressBar; +import android.widget.Toast; import butterknife.BindView; import butterknife.ButterKnife; @@ -57,7 +62,7 @@ public class NearbyActivity extends BaseActivity { locationManager = new LocationServiceManager(this); locationManager.registerLocationManager(); curLatLang = locationManager.getLatestLocation(); - nearbyAsyncTask = new NearbyAsyncTask(); + nearbyAsyncTask = new NearbyAsyncTask(this); nearbyAsyncTask.execute(); } @@ -148,7 +153,7 @@ public class NearbyActivity extends BaseActivity { } protected void refreshView() { - nearbyAsyncTask = new NearbyAsyncTask(); + nearbyAsyncTask = new NearbyAsyncTask(this); nearbyAsyncTask.execute(); } @@ -164,6 +169,12 @@ public class NearbyActivity extends BaseActivity { private class NearbyAsyncTask extends AsyncTask> { + private Context mContext; + + private NearbyAsyncTask (Context context) { + mContext = context; + } + @Override protected void onPreExecute() { super.onPreExecute(); @@ -195,6 +206,12 @@ public class NearbyActivity extends BaseActivity { gsonPlaceList = gson.toJson(placeList); gsonCurLatLng = gson.toJson(curLatLang); + if (placeList.size() == 0) { + int duration = Toast.LENGTH_SHORT; + Toast toast = Toast.makeText(mContext, R.string.no_nearby, duration); + toast.show(); + } + bundle.clear(); bundle.putString("PlaceList", gsonPlaceList); bundle.putString("CurLatLng", gsonCurLatLng); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6ffb94a83..53773d31a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -159,6 +159,7 @@ Tap this message (or hit back) to skip this step. Optional permission: Get current location for category suggestions OK Nearby Places + No nearby places found Warning This file already exists on Commons. Are you sure you want to proceed? Yes