move excerpt cleanup to Article class

This commit is contained in:
Andrew Dolgov 2015-12-02 13:19:46 +03:00
parent 614612a8e1
commit 7c0b223f6d
3 changed files with 11 additions and 5 deletions

View File

@ -1094,11 +1094,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
String excerpt;
try {
if (m_activity.getApiLevel() >= 11) {
excerpt = article.excerpt != null ? article.excerpt : "";
excerpt = excerpt.replace("…", "");
excerpt = excerpt.replace("]]>", "");
excerpt = Jsoup.parse(excerpt).text();
if (article.excerpt != null) {
excerpt = article.excerpt;
} else {
excerpt = article.articleDoc.text();

View File

@ -58,6 +58,14 @@ public class Article implements Parcelable {
}
public void cleanupExcerpt() {
if (excerpt != null) {
excerpt = excerpt.replace("…", "");
excerpt = excerpt.replace("]]>", "");
excerpt = Jsoup.parse(excerpt).text();
}
}
public void collectMediaInfo() {
articleDoc = Jsoup.parse(content);

View File

@ -95,6 +95,7 @@ public class HeadlinesRequest extends ApiRequest {
for (Article f : articles)
if (!m_articles.containsId(f.id)) {
f.collectMediaInfo();
f.cleanupExcerpt();
m_articles.add(f);
}