From 5f054e1d5f9d4592033c87fa4eba1c70442783b6 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Thu, 13 Jul 2017 21:39:17 -0400 Subject: [PATCH] Re-does commit 340a6fad29afd1154d12bac542376bea7f03bb3b because those changes were stomped by merging in commit b499e514376c98faf2f202a04d6db649c776eecb. --- .../tusky/fragment/NotificationsFragment.java | 7 +++---- .../keylesspalace/tusky/fragment/TimelineFragment.java | 9 +++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index 4bd6db9f..1471403b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -40,7 +40,6 @@ import com.keylesspalace.tusky.adapter.NotificationsAdapter; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.entity.Status; -import com.keylesspalace.tusky.interfaces.AdapterItemRemover; import com.keylesspalace.tusky.interfaces.StatusActionListener; import com.keylesspalace.tusky.receiver.TimelineReceiver; 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.StatusViewData; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import retrofit2.Call; @@ -440,8 +439,8 @@ public class NotificationsFragment extends SFragment implements topId = uptoId; } if (notifications.isEmpty()) { - // This construction removes duplicates. - notifications.addAll(new HashSet<>(newNotifications)); + // This construction removes duplicates while preserving order. + notifications.addAll(new LinkedHashSet<>(newNotifications)); } else { int index = notifications.indexOf(newNotifications.get(newNotifications.size() - 1)); for (int i = 0; i < index; i++) { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index 6aa44560..b1415da7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -43,14 +43,15 @@ import com.keylesspalace.tusky.interfaces.StatusActionListener; import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.receiver.TimelineReceiver; import com.keylesspalace.tusky.util.HttpHeaderLink; +import com.keylesspalace.tusky.util.ListUtils; import com.keylesspalace.tusky.util.PairedList; import com.keylesspalace.tusky.util.ThemeUtils; import com.keylesspalace.tusky.util.ViewDataUtils; import com.keylesspalace.tusky.view.EndlessOnScrollListener; import com.keylesspalace.tusky.viewdata.StatusViewData; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; @@ -589,7 +590,7 @@ public class TimelineFragment extends SFragment implements private void updateStatuses(List newStatuses, @Nullable String fromId, @Nullable String toId) { - if (newStatuses == null || newStatuses.isEmpty()) { + if (ListUtils.isEmpty(newStatuses)) { return; } if (fromId != null) { @@ -599,8 +600,8 @@ public class TimelineFragment extends SFragment implements upToId = toId; } if (statuses.isEmpty()) { - // This construction removes duplicates. - statuses.addAll(new HashSet<>(newStatuses)); + // This construction removes duplicates while preserving order. + statuses.addAll(new LinkedHashSet<>(newStatuses)); } else { Status lastOfNew = newStatuses.get(newStatuses.size() - 1); int index = statuses.indexOf(lastOfNew);