properly calculate offsets for non-default view modes (closes #770)

This commit is contained in:
Andrew Dolgov 2013-09-01 14:08:11 +04:00
parent 0e751f5db2
commit d5cd47e6ee
2 changed files with 39 additions and 4 deletions

View File

@ -201,11 +201,28 @@ public class ArticlePager extends Fragment {
int skip = 0; int skip = 0;
if (append) { 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) { 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; final int fskip = skip;

View File

@ -430,11 +430,29 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
int skip = 0; int skip = 0;
if (append) { 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) { 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 { } else {
m_activity.setLoadingStatus(R.string.blank, true); m_activity.setLoadingStatus(R.string.blank, true);
} }