mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Display toast if no nearby places found
This commit is contained in:
parent
9e17405b92
commit
d0622d14b1
1 changed files with 18 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package fr.free.nrw.commons.nearby;
|
package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -10,6 +11,7 @@ import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
@ -51,7 +53,7 @@ public class NearbyActivity extends BaseActivity {
|
||||||
locationManager = new LocationServiceManager(this);
|
locationManager = new LocationServiceManager(this);
|
||||||
locationManager.registerLocationManager();
|
locationManager.registerLocationManager();
|
||||||
curLatLang = locationManager.getLatestLocation();
|
curLatLang = locationManager.getLatestLocation();
|
||||||
nearbyAsyncTask = new NearbyAsyncTask();
|
nearbyAsyncTask = new NearbyAsyncTask(this);
|
||||||
nearbyAsyncTask.execute();
|
nearbyAsyncTask.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +106,7 @@ public class NearbyActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void refreshView() {
|
protected void refreshView() {
|
||||||
nearbyAsyncTask = new NearbyAsyncTask();
|
nearbyAsyncTask = new NearbyAsyncTask(this);
|
||||||
nearbyAsyncTask.execute();
|
nearbyAsyncTask.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,6 +122,12 @@ public class NearbyActivity extends BaseActivity {
|
||||||
|
|
||||||
private class NearbyAsyncTask extends AsyncTask<Void, Integer, List<Place>> {
|
private class NearbyAsyncTask extends AsyncTask<Void, Integer, List<Place>> {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
private NearbyAsyncTask (Context context) {
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
|
|
@ -151,6 +159,14 @@ public class NearbyActivity extends BaseActivity {
|
||||||
gsonPlaceList = gson.toJson(placeList);
|
gsonPlaceList = gson.toJson(placeList);
|
||||||
gsonCurLatLng = gson.toJson(curLatLang);
|
gsonCurLatLng = gson.toJson(curLatLang);
|
||||||
|
|
||||||
|
if (placeList.size() == 0) {
|
||||||
|
CharSequence text = "No nearby places found";
|
||||||
|
int duration = Toast.LENGTH_SHORT;
|
||||||
|
|
||||||
|
Toast toast = Toast.makeText(mContext, text, duration);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
|
||||||
bundle.clear();
|
bundle.clear();
|
||||||
bundle.putString("PlaceList", gsonPlaceList);
|
bundle.putString("PlaceList", gsonPlaceList);
|
||||||
bundle.putString("CurLatLng", gsonCurLatLng);
|
bundle.putString("CurLatLng", gsonCurLatLng);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue