Re-does commit 340a6fad29
because those changes were stomped by merging in commit b499e51437
.
This commit is contained in:
parent
8c5563b875
commit
5f054e1d5f
@ -40,7 +40,6 @@ import com.keylesspalace.tusky.adapter.NotificationsAdapter;
|
|||||||
import com.keylesspalace.tusky.R;
|
import com.keylesspalace.tusky.R;
|
||||||
import com.keylesspalace.tusky.entity.Notification;
|
import com.keylesspalace.tusky.entity.Notification;
|
||||||
import com.keylesspalace.tusky.entity.Status;
|
import com.keylesspalace.tusky.entity.Status;
|
||||||
import com.keylesspalace.tusky.interfaces.AdapterItemRemover;
|
|
||||||
import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
||||||
import com.keylesspalace.tusky.receiver.TimelineReceiver;
|
import com.keylesspalace.tusky.receiver.TimelineReceiver;
|
||||||
import com.keylesspalace.tusky.util.HttpHeaderLink;
|
import com.keylesspalace.tusky.util.HttpHeaderLink;
|
||||||
@ -51,8 +50,8 @@ import com.keylesspalace.tusky.view.EndlessOnScrollListener;
|
|||||||
import com.keylesspalace.tusky.viewdata.NotificationViewData;
|
import com.keylesspalace.tusky.viewdata.NotificationViewData;
|
||||||
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@ -440,8 +439,8 @@ public class NotificationsFragment extends SFragment implements
|
|||||||
topId = uptoId;
|
topId = uptoId;
|
||||||
}
|
}
|
||||||
if (notifications.isEmpty()) {
|
if (notifications.isEmpty()) {
|
||||||
// This construction removes duplicates.
|
// This construction removes duplicates while preserving order.
|
||||||
notifications.addAll(new HashSet<>(newNotifications));
|
notifications.addAll(new LinkedHashSet<>(newNotifications));
|
||||||
} else {
|
} else {
|
||||||
int index = notifications.indexOf(newNotifications.get(newNotifications.size() - 1));
|
int index = notifications.indexOf(newNotifications.get(newNotifications.size() - 1));
|
||||||
for (int i = 0; i < index; i++) {
|
for (int i = 0; i < index; i++) {
|
||||||
|
@ -43,14 +43,15 @@ import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
|||||||
import com.keylesspalace.tusky.network.MastodonApi;
|
import com.keylesspalace.tusky.network.MastodonApi;
|
||||||
import com.keylesspalace.tusky.receiver.TimelineReceiver;
|
import com.keylesspalace.tusky.receiver.TimelineReceiver;
|
||||||
import com.keylesspalace.tusky.util.HttpHeaderLink;
|
import com.keylesspalace.tusky.util.HttpHeaderLink;
|
||||||
|
import com.keylesspalace.tusky.util.ListUtils;
|
||||||
import com.keylesspalace.tusky.util.PairedList;
|
import com.keylesspalace.tusky.util.PairedList;
|
||||||
import com.keylesspalace.tusky.util.ThemeUtils;
|
import com.keylesspalace.tusky.util.ThemeUtils;
|
||||||
import com.keylesspalace.tusky.util.ViewDataUtils;
|
import com.keylesspalace.tusky.util.ViewDataUtils;
|
||||||
import com.keylesspalace.tusky.view.EndlessOnScrollListener;
|
import com.keylesspalace.tusky.view.EndlessOnScrollListener;
|
||||||
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -589,7 +590,7 @@ public class TimelineFragment extends SFragment implements
|
|||||||
|
|
||||||
private void updateStatuses(List<Status> newStatuses, @Nullable String fromId,
|
private void updateStatuses(List<Status> newStatuses, @Nullable String fromId,
|
||||||
@Nullable String toId) {
|
@Nullable String toId) {
|
||||||
if (newStatuses == null || newStatuses.isEmpty()) {
|
if (ListUtils.isEmpty(newStatuses)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fromId != null) {
|
if (fromId != null) {
|
||||||
@ -599,8 +600,8 @@ public class TimelineFragment extends SFragment implements
|
|||||||
upToId = toId;
|
upToId = toId;
|
||||||
}
|
}
|
||||||
if (statuses.isEmpty()) {
|
if (statuses.isEmpty()) {
|
||||||
// This construction removes duplicates.
|
// This construction removes duplicates while preserving order.
|
||||||
statuses.addAll(new HashSet<>(newStatuses));
|
statuses.addAll(new LinkedHashSet<>(newStatuses));
|
||||||
} else {
|
} else {
|
||||||
Status lastOfNew = newStatuses.get(newStatuses.size() - 1);
|
Status lastOfNew = newStatuses.get(newStatuses.size() - 1);
|
||||||
int index = statuses.indexOf(lastOfNew);
|
int index = statuses.indexOf(lastOfNew);
|
||||||
|
Loading…
Reference in New Issue
Block a user