From c9f8057b136afe5b990130baff7110f730a06789 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 29 May 2018 12:59:21 +0300 Subject: [PATCH] Remove redundant code --- .../explore/ExploreTabFragment.java | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 2f05c8c578..7f4ac20953 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -16,7 +16,6 @@ import android.view.ViewGroup; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.base.BaseOsmAndFragment; @@ -207,22 +206,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv addNeededMapsCard(); } - private boolean showUpdateCard() { - OsmandSettings settings = getSettings(); - if (settings != null) { - return settings.SHOW_TRAVEL_UPDATE_CARD.get(); - } - return false; - } - - private boolean showNeededMapsCard() { - OsmandSettings settings = getSettings(); - if (settings != null) { - return settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.get(); - } - return false; - } - private void addDownloadUpdateCard() { final OsmandApplication app = getMyApplication(); if (app != null && adapter != null) { @@ -231,7 +214,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv boolean outdated = mainIndexItem != null && mainIndexItem.isOutdated(); File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook(); - if (selectedTravelBook == null || (outdated && showUpdateCard())) { + if (selectedTravelBook == null || (outdated && app.getSettings().SHOW_TRAVEL_UPDATE_CARD.get())) { boolean showOtherMaps = false; if (selectedTravelBook == null) { List items = downloadThread.getIndexes().getWikivoyageItems(); @@ -255,10 +238,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv downloadThread.cancelDownload(mainIndexItem); adapter.updateDownloadUpdateCard(false); } else if (!downloadUpdateCard.isDownload()) { - OsmandSettings settings = getSettings(); - if (settings != null) { - settings.SHOW_TRAVEL_UPDATE_CARD.set(false); - } + app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(false); removeDownloadUpdateCard(); } else if (downloadUpdateCard.isShowOtherMapsBtn()) { Activity activity = getActivity(); @@ -279,7 +259,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv private void addNeededMapsCard() { final OsmandApplication app = getMyApplication(); - if (app != null && !neededIndexItems.isEmpty() && adapter != null && showNeededMapsCard()) { + if (app != null && !neededIndexItems.isEmpty() && adapter != null && app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.get()) { neededMapsCard = new TravelNeededMapsCard(app, nightMode, neededIndexItems); neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() { @Override @@ -298,10 +278,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv adapter.updateNeededMapsCard(false); } } else { - OsmandSettings settings = getSettings(); - if (settings != null) { - settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.set(false); - } + app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(false); removeNeededMapsCard(); } }