misc optimization, do not embed duplicate enclosure images in

ArticleFragment
This commit is contained in:
Andrew Dolgov 2012-09-18 23:50:50 +04:00
parent c9c3aa3d36
commit dcea7f0e85
5 changed files with 30 additions and 28 deletions

View File

@ -211,9 +211,10 @@ public class ArticleFragment extends Fragment {
try {
URL url = new URL(a.content_url.trim());
String strUrl = url.toString().trim();
if (a.content_type.indexOf("image") != -1) {
content += "<br/><img src=\"" + url.toString().trim().replace("\"", "\\\"") + "\">";
if (a.content_type.indexOf("image") != -1 && !articleContent.contains(strUrl)) {
content += "<br/><img src=\"" + strUrl.replace("\"", "\\\"") + "\">";
}
spinnerArray.add(a);

View File

@ -288,7 +288,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
}
@Override
public void onHeadlinesLoaded() {
public void onHeadlinesLoaded(boolean appended) {
// TODO Auto-generated method stub
}

View File

@ -148,14 +148,9 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
af.setActiveArticle(article);
hf.notifyUpdated();
ft.commit();
} else {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
@ -169,22 +164,26 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
}
@Override
public void onHeadlinesLoaded() {
public void onHeadlinesLoaded(boolean appended) {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (hf != null) {
Article article = hf.getAllArticles().get(0);
if (hf != null && !appended) {
Article article = hf.getActiveArticle();
hf.setActiveArticle(article);
if (article == null) {
article = hf.getAllArticles().get(0);
ArticlePager af = new ArticlePager(article);
hf.setActiveArticle(article);
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
ArticlePager af = new ArticlePager(article);
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
ft.commit();
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
ft.commit();
}
}
}
}

View File

@ -7,5 +7,5 @@ public interface HeadlinesEventListener {
void onArticleListSelectionChange(ArticleList m_selectedArticles);
void onArticleSelected(Article article);
void onArticleSelected(Article article, boolean open);
void onHeadlinesLoaded();
void onHeadlinesLoaded(boolean appended);
}

View File

@ -353,24 +353,26 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (m_activity != null) {
m_refreshInProgress = true;
if (!m_feed.equals(GlobalState.getInstance().m_activeFeed)) {
append = false;
}
final boolean fappend = append;
final String sessionId = m_activity.getSessionId();
final boolean showUnread = m_activity.getUnreadArticlesOnly();
final boolean isCat = m_feed.is_cat;
HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext(), m_activity) {
protected void onPostExecute(JsonElement result) {
super.onPostExecute(result);
m_refreshInProgress = false;
m_adapter.notifyDataSetChanged();
m_listener.onHeadlinesLoaded();
m_listener.onHeadlinesLoaded(fappend);
}
};
final String sessionId = m_activity.getSessionId();
final boolean showUnread = m_activity.getUnreadArticlesOnly();
final boolean isCat = m_feed.is_cat;
int skip = 0;
if (!m_feed.equals(GlobalState.getInstance().m_activeFeed)) {
append = false;
}
if (append) {
for (Article a : m_articles) {
if (a.unread) ++skip;