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 { try {
URL url = new URL(a.content_url.trim()); URL url = new URL(a.content_url.trim());
String strUrl = url.toString().trim();
if (a.content_type.indexOf("image") != -1) { if (a.content_type.indexOf("image") != -1 && !articleContent.contains(strUrl)) {
content += "<br/><img src=\"" + url.toString().trim().replace("\"", "\\\"") + "\">"; content += "<br/><img src=\"" + strUrl.replace("\"", "\\\"") + "\">";
} }
spinnerArray.add(a); spinnerArray.add(a);

View File

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

View File

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

View File

@ -7,5 +7,5 @@ public interface HeadlinesEventListener {
void onArticleListSelectionChange(ArticleList m_selectedArticles); void onArticleListSelectionChange(ArticleList m_selectedArticles);
void onArticleSelected(Article article); void onArticleSelected(Article article);
void onArticleSelected(Article article, boolean open); 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) { if (m_activity != null) {
m_refreshInProgress = true; 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) { HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext(), m_activity) {
protected void onPostExecute(JsonElement result) { protected void onPostExecute(JsonElement result) {
super.onPostExecute(result); super.onPostExecute(result);
m_refreshInProgress = false; m_refreshInProgress = false;
m_adapter.notifyDataSetChanged(); 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; int skip = 0;
if (!m_feed.equals(GlobalState.getInstance().m_activeFeed)) {
append = false;
}
if (append) { if (append) {
for (Article a : m_articles) { for (Article a : m_articles) {
if (a.unread) ++skip; if (a.unread) ++skip;