enable nested categories API

This commit is contained in:
Andrew Dolgov 2012-09-18 10:03:16 +04:00
parent 3da48391d6
commit 1a7edb4254
3 changed files with 29 additions and 5 deletions

View File

@ -224,6 +224,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
{ {
put("op", "getCategories"); put("op", "getCategories");
put("sid", sessionId); put("sid", sessionId);
put("enable_nested", "true");
if (unreadOnly) { if (unreadOnly) {
put("unread_only", String.valueOf(unreadOnly)); put("unread_only", String.valueOf(unreadOnly));
} }

View File

@ -99,10 +99,16 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
@Override @Override
public int compare(Feed a, Feed b) { public int compare(Feed a, Feed b) {
if (a.id >= 0 && b.id >= 0) if (a.is_cat && b.is_cat)
return a.title.compareTo(b.title);
else if (a.is_cat && !b.is_cat)
return -1;
else if (!a.is_cat && b.is_cat)
return 1;
else if (a.id >= 0 && b.id >= 0)
return a.title.compareTo(b.title); return a.title.compareTo(b.title);
else else
return a.id - b.id; return a.id - b.id;
} }
} }
@ -110,9 +116,15 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
class FeedOrderComparator implements Comparator<Feed> { class FeedOrderComparator implements Comparator<Feed> {
@Override @Override
public int compare(Feed a, Feed b) { public int compare(Feed a, Feed b) {
if (a.id >= 0 && b.id >= 0) if (a.id >= 0 && b.id >= 0)
if (a.order_id != 0 && b.order_id != 0) if (a.is_cat && b.is_cat)
return a.title.compareTo(b.title);
else if (a.is_cat && !b.is_cat)
return -1;
else if (!a.is_cat && b.is_cat)
return 1;
else if (a.order_id != 0 && b.order_id != 0)
return a.order_id - b.order_id; return a.order_id - b.order_id;
else else
return a.title.compareTo(b.title); return a.title.compareTo(b.title);
@ -223,7 +235,16 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
if (list != null) { if (list != null) {
Feed feed = (Feed)list.getItemAtPosition(position); Feed feed = (Feed)list.getItemAtPosition(position);
m_activity.onFeedSelected(feed);
if (feed.is_cat) {
FeedCategory cat = new FeedCategory();
cat.id = feed.id;
cat.title = feed.title;
m_activity.onCatSelected(cat);
} else {
m_activity.onFeedSelected(feed);
}
if (!m_activity.isSmallScreen()) if (!m_activity.isSmallScreen())
m_selectedFeed = feed; m_selectedFeed = feed;
@ -256,6 +277,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
{ {
put("op", "getFeeds"); put("op", "getFeeds");
put("sid", sessionId); put("sid", sessionId);
put("include_nested", "true");
put("cat_id", String.valueOf(catId)); put("cat_id", String.valueOf(catId));
if (unreadOnly) { if (unreadOnly) {
put("unread_only", String.valueOf(unreadOnly)); put("unread_only", String.valueOf(unreadOnly));

View File

@ -394,6 +394,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
put("offset", String.valueOf(0)); put("offset", String.valueOf(0));
put("view_mode", showUnread ? "adaptive" : "all_articles"); put("view_mode", showUnread ? "adaptive" : "all_articles");
put("skip", String.valueOf(fskip)); put("skip", String.valueOf(fskip));
put("include_nested", "true");
if (isCat) put("is_cat", "true"); if (isCat) put("is_cat", "true");