on API 3, sort feeds and categories using order configured in tt-rss
properly unmark Uncategorized on closeCategory()
This commit is contained in:
parent
1945fa6317
commit
14769a4019
@ -11,6 +11,7 @@ public class Feed implements Comparable<Feed>, Parcelable {
|
||||
boolean has_icon;
|
||||
int cat_id;
|
||||
int last_updated;
|
||||
int order_id;
|
||||
boolean is_cat;
|
||||
|
||||
public Feed(int id, String title, boolean is_cat) {
|
||||
@ -46,6 +47,7 @@ public class Feed implements Comparable<Feed>, Parcelable {
|
||||
out.writeInt(cat_id);
|
||||
out.writeInt(last_updated);
|
||||
out.writeInt(is_cat ? 1 : 0);
|
||||
out.writeInt(order_id);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
@ -57,6 +59,7 @@ public class Feed implements Comparable<Feed>, Parcelable {
|
||||
cat_id = in.readInt();
|
||||
last_updated = in.readInt();
|
||||
is_cat = in.readInt() == 1;
|
||||
order_id = in.readInt();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
@ -63,7 +63,22 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class CatOrderComparator implements Comparator<FeedCategory> {
|
||||
|
||||
@Override
|
||||
public int compare(FeedCategory a, FeedCategory b) {
|
||||
if (a.id >= 0 && b.id >= 0)
|
||||
if (a.order_id != 0 && b.order_id != 0)
|
||||
return a.order_id - b.order_id;
|
||||
else
|
||||
return a.title.compareTo(b.title);
|
||||
else
|
||||
return a.id - b.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
@ -234,7 +249,11 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
||||
if (m_prefs.getBoolean("sort_feeds_by_unread", false)) {
|
||||
cmp = new CatUnreadComparator();
|
||||
} else {
|
||||
cmp = new CatTitleComparator();
|
||||
if (m_onlineServices.getApiLevel() >= 3) {
|
||||
cmp = new CatOrderComparator();
|
||||
} else {
|
||||
cmp = new CatTitleComparator();
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(m_cats, cmp);
|
||||
|
@ -7,6 +7,7 @@ public class FeedCategory implements Parcelable {
|
||||
int id;
|
||||
String title;
|
||||
int unread;
|
||||
int order_id;
|
||||
|
||||
public FeedCategory(Parcel in) {
|
||||
readFromParcel(in);
|
||||
@ -16,6 +17,7 @@ public class FeedCategory implements Parcelable {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.unread = unread;
|
||||
this.order_id = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -28,12 +30,14 @@ public class FeedCategory implements Parcelable {
|
||||
out.writeInt(id);
|
||||
out.writeString(title);
|
||||
out.writeInt(unread);
|
||||
out.writeInt(order_id);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
id = in.readInt();
|
||||
title = in.readString();
|
||||
unread = in.readInt();
|
||||
order_id = in.readInt();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
@ -92,7 +92,22 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class FeedOrderComparator implements Comparator<Feed> {
|
||||
|
||||
@Override
|
||||
public int compare(Feed a, Feed b) {
|
||||
if (a.id >= 0 && b.id >= 0)
|
||||
if (a.order_id != 0 && b.order_id != 0)
|
||||
return a.order_id - b.order_id;
|
||||
else
|
||||
return a.title.compareTo(b.title);
|
||||
else
|
||||
return a.id - b.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
@ -424,7 +439,11 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
||||
if (m_prefs.getBoolean("sort_feeds_by_unread", false)) {
|
||||
cmp = new FeedUnreadComparator();
|
||||
} else {
|
||||
cmp = new FeedTitleComparator();
|
||||
if (m_onlineServices.getApiLevel() >= 3) {
|
||||
cmp = new FeedOrderComparator();
|
||||
} else {
|
||||
cmp = new FeedTitleComparator();
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(m_feeds, cmp);
|
||||
|
@ -759,7 +759,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
.findFragmentById(R.id.cats_fragment);
|
||||
|
||||
if (cf != null) {
|
||||
cf.setSelectedCategoryId(0);
|
||||
// should be nonexistant feed_id (0 is Uncategorized)
|
||||
cf.setSelectedCategoryId(-10000);
|
||||
}
|
||||
|
||||
initMainMenu();
|
||||
|
Loading…
Reference in New Issue
Block a user