diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index c090e66ee1..bdd0deb293 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -12,7 +12,6 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Toast; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -161,12 +160,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn downloadUpdateCard.setListener(new TravelDownloadUpdateCard.ClickListener() { @Override public void onPrimaryButtonClick() { - if (app.getSettings().isInternetConnectionAvailable()) { + if (indexItem != null) { new DownloadValidationManager(app).startDownload(getMyActivity(), indexItem); downloadUpdateCard.setLoadingInProgress(true); adapter.updateDownloadUpdateCard(); - } else { - Toast.makeText(app, app.getString(R.string.no_index_file_to_download), Toast.LENGTH_SHORT).show(); } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java index c2a9621ab0..2f1fe46289 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java @@ -107,6 +107,10 @@ public class TravelDownloadUpdateCard extends BaseTravelCard { return app.getString(download ? R.string.download_file : R.string.update_is_available); } + private boolean isInternetAvailable() { + return app.getSettings().isInternetConnectionAvailable(); + } + private Drawable getIcon() { int id = download ? R.drawable.travel_card_download_icon : R.drawable.travel_card_update_icon; return ContextCompat.getDrawable(app, id); @@ -114,6 +118,9 @@ public class TravelDownloadUpdateCard extends BaseTravelCard { @NonNull private String getDescription() { + if (!isInternetAvailable()) { + return app.getString(R.string.no_index_file_to_download); + } return app.getString(download ? R.string.travel_card_download_descr : R.string.travel_card_update_descr); } @@ -175,6 +182,7 @@ public class TravelDownloadUpdateCard extends BaseTravelCard { private boolean updatePrimaryButton(DownloadUpdateVH vh) { if (!loadingInProgress) { vh.primaryBtnContainer.setVisibility(View.VISIBLE); + vh.primaryButton.setEnabled(isInternetAvailable()); vh.primaryButton.setText(download ? R.string.shared_string_download : R.string.shared_string_update); vh.primaryButton.setOnClickListener(new View.OnClickListener() { @Override