From 6357648162a6f2cff787824562faca6fa85f948f Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 17 Apr 2018 15:26:41 +0300 Subject: [PATCH] add initialising wptCategories in createDisplayGroups --- .../src/net/osmand/plus/MapMarkersHelper.java | 13 +++++ .../adapters/MapMarkersGroupsAdapter.java | 56 ++++++++++--------- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 7092984999..68d161a848 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -1222,6 +1222,7 @@ public class MapMarkersHelper { private boolean wasShown = false; private boolean visibleUntilRestart; private List markers = new ArrayList<>(); + private TravelArticle wikivoyageArticle; // TODO should be removed from this class: private GroupHeader header; private CategoriesHeader categoriesHeader; @@ -1246,6 +1247,14 @@ public class MapMarkersHelper { return id; } + public TravelArticle getWikivoyageArticle() { + return wikivoyageArticle; + } + + public void setWikivoyageArticle(TravelArticle wikivoyageArticle) { + this.wikivoyageArticle = wikivoyageArticle; + } + public String getName() { return name; } @@ -1258,6 +1267,10 @@ public class MapMarkersHelper { this.wptCategories = wptCategories; } + public Set getWptCategories() { + return wptCategories; + } + public boolean isDisabled() { return disabled; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index 5935a3247f..a7e7391cb3 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -168,15 +168,31 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter 1) { group.setWasShown(true); Bundle args = new Bundle(); args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, group.getGpxPath()); @@ -521,14 +537,17 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter 1) { + Bundle args = new Bundle(); + args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, group.getGpxPath()); + args.putBoolean(SelectWptCategoriesBottomSheetDialogFragment.UPDATE_CATEGORIES_KEY, true); + SelectWptCategoriesBottomSheetDialogFragment fragment = new SelectWptCategoriesBottomSheetDialogFragment(); + fragment.setArguments(args); + fragment.setUsedOnMap(false); + fragment.show(mapActivity.getSupportFragmentManager(), SelectWptCategoriesBottomSheetDialogFragment.TAG); + } else { + mapActivity.getMyApplication().getMapMarkersHelper().addOrEnableGpxGroup(new File(group.getGpxPath())); + } } }); } @@ -542,22 +561,9 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles(); - for (TravelArticle art : savedArticles) { - String gpxName = travelDbHelper.getGPXName(art); - File path = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName); - if (path.getAbsolutePath().equals(group.getGpxPath())) { - MapMarkersHelper.WikivoyageArticleHeader wikivoyageArticleHeader = group.getWikivoyageArticleHeader(); - items.add(wikivoyageArticleHeader); - test = art; - } - } - } - if (mapActivity.getSupportFragmentManager() != null && test != null) { - WikivoyageArticleDialogFragment.showInstance(app, mapActivity.getSupportFragmentManager(), test.getCityId(), test.getLang()); + TravelArticle article = group.getWikivoyageArticle(); + if (mapActivity.getSupportFragmentManager() != null && article != null) { + WikivoyageArticleDialogFragment.showInstance(app, mapActivity.getSupportFragmentManager(), article.getCityId(), article.getLang()); } } });