From d5cd47e6eec7be01dca3c4d388e21ff21dd2b1f3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 1 Sep 2013 14:08:11 +0400 Subject: [PATCH] properly calculate offsets for non-default view modes (closes #770) --- src/org/fox/ttrss/ArticlePager.java | 21 +++++++++++++++++++-- src/org/fox/ttrss/HeadlinesFragment.java | 22 ++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/org/fox/ttrss/ArticlePager.java b/src/org/fox/ttrss/ArticlePager.java index 9b968cea..f7e5a13f 100644 --- a/src/org/fox/ttrss/ArticlePager.java +++ b/src/org/fox/ttrss/ArticlePager.java @@ -201,11 +201,28 @@ public class ArticlePager extends Fragment { int skip = 0; if (append) { + // adaptive, all_articles, marked, published, unread + String viewMode = m_activity.getViewMode(); + int numUnread = 0; + int numAll = m_articles.size(); + for (Article a : m_articles) { - if (a.unread) ++skip; + if (a.unread) ++numUnread; } - if (skip == 0) skip = m_articles.size(); + if ("marked".equals(viewMode)) { + skip = numAll; + } else if ("published".equals(viewMode)) { + skip = numAll; + } else if ("unread".equals(viewMode)) { + skip = numUnread; + } else if (m_searchQuery != null && m_searchQuery.length() > 0) { + skip = numAll; + } else if ("adaptive".equals(viewMode)) { + skip = numUnread > 0 ? numUnread : numAll; + } else { + skip = numAll; + } } final int fskip = skip; diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 1014e836..aacd2833 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -430,11 +430,29 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, int skip = 0; if (append) { + // adaptive, all_articles, marked, published, unread + String viewMode = m_activity.getViewMode(); + int numUnread = 0; + int numAll = m_articles.size(); + for (Article a : m_articles) { - if (a.unread) ++skip; + if (a.unread) ++numUnread; + } + + if ("marked".equals(viewMode)) { + skip = numAll; + } else if ("published".equals(viewMode)) { + skip = numAll; + } else if ("unread".equals(viewMode)) { + skip = numUnread; + } else if (m_searchQuery != null && m_searchQuery.length() > 0) { + skip = numAll; + } else if ("adaptive".equals(viewMode)) { + skip = numUnread > 0 ? numUnread : numAll; + } else { + skip = numAll; } - if (skip == 0) skip = m_articles.size(); } else { m_activity.setLoadingStatus(R.string.blank, true); }