From 233a4ba3d7c4adf6e6c00750cbf5eab3e65d6d95 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 12 Feb 2021 17:13:26 +0200 Subject: [PATCH] remove "Show more" button when all travel files deleted. --- .../explore/ExploreTabFragment.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index ff692f8f1c..7255694422 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -186,28 +186,28 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv } } } - - TravelButtonCard travelButtonCard = new TravelButtonCard(app, nightMode); - travelButtonCard.setListener(new TravelNeededMapsCard.CardListener() { - @Override - public void onPrimaryButtonClick() { - if (activity instanceof WikivoyageExploreActivity) { - new LoadWikivoyageData((WikivoyageExploreActivity) activity,false).execute(); + if (app.getTravelHelper().isAnyTravelBookPresent()) { + TravelButtonCard travelButtonCard = new TravelButtonCard(app, nightMode); + travelButtonCard.setListener(new TravelNeededMapsCard.CardListener() { + @Override + public void onPrimaryButtonClick() { + if (activity instanceof WikivoyageExploreActivity) { + new LoadWikivoyageData((WikivoyageExploreActivity) activity, false).execute(); + } } - } - @Override - public void onSecondaryButtonClick() { + @Override + public void onSecondaryButtonClick() { - } + } - @Override - public void onIndexItemClick(IndexItem item) { - - } - }); - items.add(travelButtonCard); + @Override + public void onIndexItemClick(IndexItem item) { + } + }); + items.add(travelButtonCard); + } items.add(new StartEditingTravelCard(activity, nightMode)); adapter.setItems(items); final DownloadIndexesThread downloadThread = app.getDownloadThread(); @@ -248,11 +248,14 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv } private void addIndexItemCards(List mainIndexItem, List neededIndexItems) { - this.mainIndexItems.clear(); - this.mainIndexItems.addAll(mainIndexItem); + final OsmandApplication app = getMyApplication(); + if (app != null && !app.getTravelHelper().isAnyTravelBookPresent()) { + this.mainIndexItems.clear(); + this.mainIndexItems.addAll(mainIndexItem); + addDownloadUpdateCard(); + } this.neededIndexItems.clear(); this.neededIndexItems.addAll(neededIndexItems); - addDownloadUpdateCard(); addNeededMapsCard(); }