From 27bb3662564ff20b098b866c0a6c5edb8431f360 Mon Sep 17 00:00:00 2001 From: Paul Fechner Date: Wed, 7 Dec 2016 13:35:31 -0600 Subject: [PATCH] Footnote parsing should no longer hang. --- app/app/src/main/java/adapters/ReadingPagerAdapter.java | 1 - app/app/src/main/java/model/parsers/USFMParser.java | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/app/src/main/java/adapters/ReadingPagerAdapter.java b/app/app/src/main/java/adapters/ReadingPagerAdapter.java index ca74d50..4adf8ee 100644 --- a/app/app/src/main/java/adapters/ReadingPagerAdapter.java +++ b/app/app/src/main/java/adapters/ReadingPagerAdapter.java @@ -96,7 +96,6 @@ public Object instantiateItem(final ViewGroup container, final int position) { view = getNextBookView(inflater); } else{ - view = inflater.inflate(R.layout.reading_pager_layout, container, false); view.setEnabled(false); WebView textWebView = (WebView) view.findViewById(R.id.chapterWebView); diff --git a/app/app/src/main/java/model/parsers/USFMParser.java b/app/app/src/main/java/model/parsers/USFMParser.java index 1ebb898..9c43b73 100644 --- a/app/app/src/main/java/model/parsers/USFMParser.java +++ b/app/app/src/main/java/model/parsers/USFMParser.java @@ -41,7 +41,7 @@ public class USFMParser { private static final Pattern SP_REGEX = Pattern.compile("\\\\sp.*"); private static final Pattern ADD_REGEX = Pattern.compile("\\\\add.*\\\\add\\*", Pattern.DOTALL); - private static final Pattern FOOTNOTE_REGEX = Pattern.compile("(\\\\f)(\\s+)((.*)(\\n*)){1,5}(\\\\f[*])"); + private static final Pattern FOOTNOTE_REGEX = Pattern.compile("\\\\f\\s+.*\\n*\\\\f[*]"); private static final Pattern FOOTNOTE_TEXT_REGEX = Pattern.compile("\\\\f.*\\\\f\\*", Pattern.DOTALL); private static final Pattern FOOTNOTE_VERSE_REGEX = Pattern.compile("\\\\fqa.*\\\\f[*]"); @@ -276,16 +276,16 @@ private String replaceQs(String text) { return text; } - private String findFootnotes(String text){ + private String findFootnotes(String text) { Matcher verseMatcher = FOOTNOTE_REGEX.matcher(text); - ArrayList verseText = new ArrayList(); + ArrayList verseText = new ArrayList<>(); while (verseMatcher.find()) { verseText.add(verseMatcher.group(0)); } - if(verseText.size() > 0){ + if(verseText.size() > 0) { for(String footnote : verseText){ String footnoteText = findFootnoteText(footnote); String footnoteNumberText = "" + Integer.toString(this.footnoteNumber) + "";