From c198c78b51cb60dfb56eee368fb793216d4972d9 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 23 Jul 2018 17:00:31 +0300 Subject: [PATCH] add check for internet before opening dialog --- .../search/QuickSearchDialogFragment.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index b69449bc88..a7260d032c 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -640,14 +640,21 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC sendEmptySearchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - Bundle args = new Bundle(); - SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet(); - args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery); - if (location != null) { - args.putString(MISSING_SEARCH_LOCATION_KEY, location.toString()); + OsmandApplication app = getMyApplication(); + if (app != null) { + if (!app.getSettings().isInternetConnectionAvailable()) { + Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show(); + } else { + if (location != null && searchQuery != null) { + Bundle args = new Bundle(); + SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet(); + args.putString(MISSING_SEARCH_LOCATION_KEY, location.toString()); + args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery); + fragment.setArguments(args); + fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG); + } + } } - fragment.setArguments(args); - fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG); } }); updateFab();