From 51bf9f51cc33873cde594c96d1324f293b1c7daf Mon Sep 17 00:00:00 2001 From: crimean Date: Wed, 17 Jul 2019 11:11:11 +0300 Subject: [PATCH] Fix travel UI --- .../src/main/java/net/osmand/util/Algorithms.java | 9 +-------- .../src/net/osmand/plus/wikipedia/WikiArticleHelper.java | 6 +++--- .../article/WikivoyageArticleDialogFragment.java | 2 +- .../net/osmand/plus/wikivoyage/data/TravelDbHelper.java | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java index 4bb04c4d56..3e6caffafa 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java @@ -461,14 +461,7 @@ public class Algorithms { public static String gzipToString(byte[] gzip) throws IOException { GZIPInputStream gzipIs = new GZIPInputStream(new ByteArrayInputStream(gzip)); - BufferedReader br = new BufferedReader(new InputStreamReader(gzipIs, "UTF-8")); - StringBuilder sb = new StringBuilder(); - String s; - while ((s = br.readLine()) != null) { - sb.append(s); - } - br.close(); - return sb.toString(); + return readFromInputStream(gzipIs).toString(); } public static boolean removeAllFiles(File f) { diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java index 28bbdc8c06..d85decda64 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java @@ -286,11 +286,11 @@ public class WikiArticleHelper { } @Nullable - public static String getPartialContent(String content) { - if (content == null) { + public static String getPartialContent(String source) { + if (source == null) { return null; } - + String content = source.replaceAll("\\n", ""); int firstParagraphStart = content.indexOf(P_OPENED); int firstParagraphEnd = content.indexOf(P_CLOSED); firstParagraphEnd = firstParagraphEnd < firstParagraphStart ? content.indexOf(P_CLOSED, firstParagraphStart) : firstParagraphEnd; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 6ac32656dc..44ae21063c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -425,7 +425,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme for (int i = backStackEntryCount - 1; i >= 0; i--) { BackStackEntry entry = fragmentManager.getBackStackEntryAt(i); if (!TAG.equals(entry.getName())) { - pop = i; + pop = entry.getId(); break; } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index e4becd523d..f001dd90d9 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -600,7 +600,7 @@ public class TravelDbHelper { res.title = cursor.getString(0); try { - res.content = Algorithms.gzipToString(cursor.getBlob(1)); + res.content = Algorithms.gzipToString(cursor.getBlob(1)).trim(); } catch (IOException e) { LOG.error(e.getMessage(), e); }