From d61997e20e011b8fa7599b3687372bf35fd411b4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 6 Sep 2015 19:46:07 +0300 Subject: [PATCH] add a catch block against possible crashes with excerpt handling --- org.fox.ttrss/src/main/AndroidManifest.xml | 4 +-- .../java/org/fox/ttrss/HeadlinesFragment.java | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/org.fox.ttrss/src/main/AndroidManifest.xml b/org.fox.ttrss/src/main/AndroidManifest.xml index f68bff2b..532e4b7e 100755 --- a/org.fox.ttrss/src/main/AndroidManifest.xml +++ b/org.fox.ttrss/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="376" + android:versionName="1.148" > = 11) { - excerpt = article.excerpt != null ? article.excerpt : ""; - excerpt = excerpt.replace("…", "…"); - excerpt = excerpt.replace("]]>", ""); - excerpt = Jsoup.parse(excerpt).text(); - } else { - excerpt = article.articleDoc.text(); + try { + if (m_activity.getApiLevel() >= 11) { + excerpt = article.excerpt != null ? article.excerpt : ""; + excerpt = excerpt.replace("…", "…"); + excerpt = excerpt.replace("]]>", ""); + excerpt = Jsoup.parse(excerpt).text(); + } else { + excerpt = article.articleDoc.text(); - if (excerpt.length() > CommonActivity.EXCERPT_MAX_LENGTH) - excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + "…"; - } + if (excerpt.length() > CommonActivity.EXCERPT_MAX_LENGTH) + excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_LENGTH) + "…"; + } + } catch (Exception e) { + e.printStackTrace(); + excerpt = ""; + } holder.excerptView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize); holder.excerptView.setText(excerpt);