parent
23f4b63195
commit
f3e1fa4b2b
|
@ -94,12 +94,15 @@ public class AnnouncementsFragment extends BaseStatusListFragment<Announcement>
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Announcement> result){
|
public void onSuccess(List<Announcement> result){
|
||||||
if (getActivity() == null) return;
|
if (getActivity() == null) return;
|
||||||
List<Announcement> unread = result.stream().filter(a -> !a.read).collect(toList());
|
|
||||||
List<Announcement> read = result.stream().filter(a -> a.read).collect(toList());
|
// get unread items first
|
||||||
onDataLoaded(unread, true);
|
List<Announcement> data = result.stream().filter(a -> !a.read).collect(toList());
|
||||||
onDataLoaded(read, false);
|
if (data.isEmpty()) setResult(true, null);
|
||||||
if (unread.isEmpty()) setResult(true, null);
|
else unreadIDs = data.stream().map(a -> a.id).collect(toList());
|
||||||
else unreadIDs = unread.stream().map(a -> a.id).collect(toList());
|
|
||||||
|
// append read items at the end
|
||||||
|
data.addAll(result.stream().filter(a -> a.read).collect(toList()));
|
||||||
|
onDataLoaded(data, false);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.exec(accountID);
|
.exec(accountID);
|
||||||
|
|
Loading…
Reference in New Issue