add a catch block against possible crashes with excerpt handling

This commit is contained in:
Andrew Dolgov 2015-09-06 19:46:07 +03:00
parent 62de61c5a0
commit d61997e20e
2 changed files with 17 additions and 12 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss"
android:versionCode="375"
android:versionName="1.147" >
android:versionCode="376"
android:versionName="1.148" >
<uses-sdk
android:minSdkVersion="15"

View File

@ -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("&hellip;", "");
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("&hellip;", "");
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);