From 3c996a41a911c325b078c438cfb3da264b473f44 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Sat, 28 Apr 2018 15:32:07 +0300 Subject: [PATCH 1/4] Fixed unused array --- .../plus/wikivoyage/data/TravelDbHelper.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 388cbed36e..bc3fb3f4ed 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -362,22 +362,23 @@ public class TravelDbHelper { cursor.close(); } LinkedHashMap> res = new LinkedHashMap<>(); - parts = parts == null ? new String[]{} : parts; - for (String header : parts) { - WikivoyageSearchResult searchResult = headerObjs.get(header); - List results = navMap.get(header); - if (results != null) { - Collections.sort(results, new Comparator() { - @Override - public int compare(WikivoyageSearchResult o1, WikivoyageSearchResult o2) { - return collator.compare(o1.articleTitles.get(0), o2.articleTitles.get(0)); - } - }); - WikivoyageSearchResult emptyResult = new WikivoyageSearchResult(); - emptyResult.articleTitles.add(header); - emptyResult.cityId = -1; - searchResult = searchResult != null ? searchResult : emptyResult; - res.put(searchResult, results); + if (parts != null) { + for (String header : parts) { + WikivoyageSearchResult searchResult = headerObjs.get(header); + List results = navMap.get(header); + if (results != null) { + Collections.sort(results, new Comparator() { + @Override + public int compare(WikivoyageSearchResult o1, WikivoyageSearchResult o2) { + return collator.compare(o1.articleTitles.get(0), o2.articleTitles.get(0)); + } + }); + WikivoyageSearchResult emptyResult = new WikivoyageSearchResult(); + emptyResult.articleTitles.add(header); + emptyResult.cityId = -1; + searchResult = searchResult != null ? searchResult : emptyResult; + res.put(searchResult, results); + } } } return res; From d681498dd1d785f33618059b108af8ee5dbb6a84 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Sat, 28 Apr 2018 15:50:22 +0300 Subject: [PATCH 2/4] Fixed back button behavior --- .../article/WikivoyageArticleNavigationFragment.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java index 5cd8d6bce3..2623cc5907 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java @@ -147,13 +147,7 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr } private void sendResults(long cityId) { - Fragment fragment = getTargetFragment(); - if (fragment != null) { - Intent intent = new Intent(); - intent.putExtra(CITY_ID_KEY, cityId); - intent.putExtra(SELECTED_LANG_KEY, selectedLang); - fragment.onActivityResult(getTargetRequestCode(), OPEN_ARTICLE_REQUEST_CODE, intent); - } + WikivoyageArticleDialogFragment.showInstance(getMyApplication(), getFragmentManager(), cityId, selectedLang); } public static boolean showInstance(@NonNull FragmentManager fm, From 9bb3e653873854b67bd370f05cd13860467fb297 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Sat, 28 Apr 2018 15:59:15 +0300 Subject: [PATCH 3/4] Fixed back button behavior --- .../osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java index 87dea4e54b..a68bbbde16 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java @@ -22,6 +22,9 @@ import android.view.Window; import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndDialogFragment; +import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment; + +import static android.support.v4.app.FragmentManager.POP_BACK_STACK_INCLUSIVE; public class WikivoyageBaseDialogFragment extends BaseOsmAndDialogFragment { @@ -89,7 +92,7 @@ public class WikivoyageBaseDialogFragment extends BaseOsmAndDialogFragment { toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - dismiss(); + getFragmentManager().popBackStackImmediate(WikivoyageExploreDialogFragment.TAG, 0); } }); } From bb9a0b88d49f9b5250fbf9338478d308bfd010a6 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Sat, 28 Apr 2018 16:00:08 +0300 Subject: [PATCH 4/4] Removed unused import --- .../osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java index a68bbbde16..c31d264e08 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageBaseDialogFragment.java @@ -24,8 +24,6 @@ import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment; -import static android.support.v4.app.FragmentManager.POP_BACK_STACK_INCLUSIVE; - public class WikivoyageBaseDialogFragment extends BaseOsmAndDialogFragment { protected boolean nightMode;