display unread announcements first

closes sk22#274
This commit is contained in:
sk 2023-01-16 19:46:44 +01:00 committed by LucasGGamerM
parent 5a547015e6
commit 7fa52247e8
1 changed files with 8 additions and 7 deletions

View File

@ -1,5 +1,7 @@
package org.joinmastodon.android.fragments;
import static java.util.stream.Collectors.toList;
import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
@ -34,6 +36,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import me.grishka.appkit.Nav;
import me.grishka.appkit.api.PaginatedList;
@ -87,19 +90,17 @@ public class AnnouncementsFragment extends BaseStatusListFragment<Announcement>
public void onItemClick(String id) {
}
@Override
protected void onDataLoaded(List<Announcement> d, boolean more) {
unreadIDs = d.stream().filter(a -> !a.read).map(a -> a.id).collect(Collectors.toList());
super.onDataLoaded(d, more);
}
@Override
protected void doLoadData(int offset, int count){
currentRequest=new GetAnnouncements(true)
.setCallback(new SimpleCallback<>(this){
@Override
public void onSuccess(List<Announcement> result){
onDataLoaded(result, false);
List<Announcement> unread = result.stream().filter(a -> !a.read).collect(toList());
List<Announcement> read = result.stream().filter(a -> a.read).collect(toList());
onDataLoaded(unread, true);
onDataLoaded(read, false);
unreadIDs = unread.stream().map(a -> a.id).collect(toList());
}
})
.exec(accountID);