Merge pull request #1307 from ujjwalagrawal17/toast

Fixes #1301 Changes toasts to snacks
This commit is contained in:
neslihanturan 2018-03-16 12:38:41 +02:00 committed by GitHub
commit 872b258720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View file

@ -274,7 +274,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
LatLng lastLocation = locationManager.getLastLocation(); LatLng lastLocation = locationManager.getLastLocation();
if (curLatLang != null && curLatLang.equals(lastLocation)) { //refresh view only if location has changed if (curLatLang != null && curLatLang.equals(lastLocation)) { //refresh view only if location has changed
if (isHardRefresh) { if (isHardRefresh) {
ViewUtil.showLongToast(this, R.string.nearby_location_has_not_changed); ViewUtil.showSnackbar(findViewById(R.id.container), R.string.nearby_location_has_not_changed);
} }
return; return;
} }
@ -301,9 +301,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
String gsonCurLatLng = gson.toJson(curLatLang); String gsonCurLatLng = gson.toJson(curLatLang);
if (placeList.size() == 0) { if (placeList.size() == 0) {
int duration = Toast.LENGTH_SHORT; ViewUtil.showSnackbar(findViewById(R.id.container), R.string.no_nearby);
Toast toast = Toast.makeText(this, R.string.no_nearby, duration);
toast.show();
} }
bundle.clear(); bundle.clear();

View file

@ -1,12 +1,12 @@
package fr.free.nrw.commons.utils; package fr.free.nrw.commons.utils;
import android.content.Context; import android.support.design.widget.Snackbar;
import android.support.annotation.StringRes; import android.view.View;
import android.widget.Toast;
public class ViewUtil { public class ViewUtil {
public static void showLongToast(final Context context, @StringRes final int stringResId) { public static void showSnackbar(View view, int messageResourceId) {
ExecutorUtils.uiExecutor().execute(() -> Toast.makeText(context, context.getString(stringResId), Toast.LENGTH_LONG).show()); Snackbar.make(view, messageResourceId, Snackbar.LENGTH_SHORT).show();
} }
} }