diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java index 2bff73d7b2..b66ca9c467 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java @@ -80,7 +80,7 @@ public class DownloadResources extends DownloadResourceGroup { List items = getWikivoyageItems(); if (items != null) { for (IndexItem ii : items) { - if (ii.getFileName().equals(fileName)) { + if (ii.getTargetFile(app).getName().equals(fileName)) { return ii; } } diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java index 9caf70d5b9..b4f21895f4 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java @@ -301,7 +301,7 @@ public class WikiArticleHelper { return null; } String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + P_CLOSED.length()); - while (firstParagraphHtml.length() == (P_OPENED.length() + P_CLOSED.length()) + while (firstParagraphHtml.substring(P_OPENED.length(), firstParagraphHtml.length() - P_CLOSED.length()).trim().isEmpty() && (firstParagraphEnd + P_CLOSED.length()) < content.length()) { firstParagraphStart = content.indexOf(P_OPENED, firstParagraphEnd); firstParagraphEnd = firstParagraphStart == -1 ? -1 : content.indexOf(P_CLOSED, firstParagraphStart); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index d50d05e42b..ef6dbd921e 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -46,6 +46,7 @@ public class TravelDbHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelDbHelper.class); + private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite"; private static final String ARTICLES_TABLE_NAME = "travel_articles"; private static final String POPULAR_TABLE_NAME = "popular_articles"; private static final String ARTICLES_POP_INDEX = "popularity_index"; @@ -185,6 +186,11 @@ public class TravelDbHelper implements TravelHelper { return null; } + @Override + public String getWikivoyageFileName() { + return WORLD_WIKIVOYAGE_FILE_NAME; + } + public List getExistingTravelBooks() { return existingTravelBooks; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index b55c398817..d8112cee0c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -49,4 +49,6 @@ public interface TravelHelper { // For TravelOBFHelper it could always return "" and should be no problem // Bookmarks should be refactored properly to support multiple files String getSelectedTravelBookName(); + + String getWikivoyageFileName(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index e1dc65ebfd..94d342ddc6 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -37,8 +37,10 @@ import static net.osmand.CollatorStringMatcher.StringMatcherMode.CHECK_EQUALS_FR public class TravelObfHelper implements TravelHelper { private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class); - public static final String ROUTE_ARTICLE = "route_article"; - public static final int SEARCH_RADIUS = 100000; + + private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.travel.obf"; + private static final String ROUTE_ARTICLE = "route_article"; + private static final int SEARCH_RADIUS = 100000; private final OsmandApplication app; private final Collator collator; @@ -392,4 +394,9 @@ public class TravelObfHelper implements TravelHelper { public String getSelectedTravelBookName() { return ""; } + + @Override + public String getWikivoyageFileName() { + return WORLD_WIKIVOYAGE_FILE_NAME; + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 22310e4292..c53027fb7a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -45,8 +45,6 @@ import java.util.List; public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEvents, TravelLocalDataHelper.Listener { - private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite"; - private static boolean SHOW_TRAVEL_UPDATE_CARD = true; private static boolean SHOW_TRAVEL_NEEDED_MAPS_CARD = true; @@ -342,14 +340,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv return res.toArray(new IndexItem[0]); } - @NonNull - private String getWikivoyageFileName() { -// OsmandApplication app = getMyApplication(); -// File selectedTravelBook = app != null ? app.getTravelDbHelper().getSelectedTravelBook() : null; -// return selectedTravelBook == null ? WORLD_WIKIVOYAGE_FILE_NAME : selectedTravelBook.getName(); - return WORLD_WIKIVOYAGE_FILE_NAME; - } - private void removeDownloadUpdateCard() { if (adapter != null) { adapter.removeDownloadUpdateCard(); @@ -379,7 +369,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv ProcessIndexItemsTask(ExploreTabFragment fragment) { app = fragment.getMyApplication(); weakFragment = new WeakReference<>(fragment); - fileName = fragment.getWikivoyageFileName(); + fileName = app.getTravelHelper().getWikivoyageFileName(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index 45047e2e1c..a3522a8329 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -61,6 +61,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv protected List> fragments = new ArrayList<>(); private LockableViewPager viewPager; + private boolean finishDownloading = false; @Override public void onCreate(Bundle savedInstanceState) { @@ -313,10 +314,12 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv public void populateData() { switchProgressBarVisibility(true); + finishDownloading = false; new LoadWikivoyageData(this).execute(); } private void onDataLoaded() { + finishDownloading = true; switchProgressBarVisibility(false); updateSearchBarVisibility(); updateFragments(); @@ -353,7 +356,9 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv } public void onTabFragmentResume(Fragment fragment) { - updateFragments(); + if(finishDownloading) { + updateFragments(); + } } @Override