diff options
author | Andrew Dolgov <[email protected]> | 2015-09-06 19:46:07 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-09-06 19:46:07 +0300 |
commit | d61997e20e011b8fa7599b3687372bf35fd411b4 (patch) | |
tree | 5bff453100fa9ccb771eacdf5f77a89d2399e8ab /org.fox.ttrss/src/main/java | |
parent | 62de61c5a0cbe3130ebce0ed81bce81928e9be8b (diff) |
add a catch block against possible crashes with excerpt handling
Diffstat (limited to 'org.fox.ttrss/src/main/java')
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 1355cd2f..b2d3748f 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -1045,17 +1045,22 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, } else { String excerpt; - 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) + "…"; - } + 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) + "…"; + } + } catch (Exception e) { + e.printStackTrace(); + excerpt = ""; + } holder.excerptView.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize); holder.excerptView.setText(excerpt); |