From c3ee44ffac94ddd37cc2f8e126409e595c6579f6 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 12 Apr 2021 21:37:41 +0300 Subject: [PATCH] Fix possible NPE, remove unnecessary track visibility set --- .../WikivoyageArticleDialogFragment.java | 17 +++++++++-------- .../explore/travelcards/ArticleTravelCard.java | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 0205feaaf6..ba4f5b6f85 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -254,17 +254,18 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme saveBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - getMyApplication().getTravelHelper().createGpxFile(article); - GPXFile gpxFile = article.getGpxFile(); - if (saved) { + getMyApplication().getTravelHelper().createGpxFile(article); + GPXFile gpxFile = article.getGpxFile(); + if (saved) { + if (gpxFile != null) { getMyApplication().getSelectedGpxHelper().selectGpxFile(gpxFile, false, true); - helper.removeArticleFromSaved(article); - } else { - getMyApplication().getSelectedGpxHelper().selectGpxFile(gpxFile, true, true); - helper.addArticleToSaved(article); } - updateSaveButton(); + helper.removeArticleFromSaved(article); + } else { + helper.addArticleToSaved(article); } + updateSaveButton(); + } }); } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java index ef59c079a3..0a81e48c6d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java @@ -107,10 +107,11 @@ public class ArticleTravelCard extends BaseTravelCard { app.getTravelHelper().createGpxFile(article); GPXFile gpxFile = article.getGpxFile(); if (saved) { - app.getSelectedGpxHelper().selectGpxFile(gpxFile, false, true); + if (gpxFile != null) { + app.getSelectedGpxHelper().selectGpxFile(gpxFile, false, true); + } helper.removeArticleFromSaved(article); } else { - app.getSelectedGpxHelper().selectGpxFile(gpxFile, true, true); helper.addArticleToSaved(article); } updateSaveButton(holder);