mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
Make Notification pk nullable. Fixes austinhuang0131/barinsta#1450
This commit is contained in:
parent
effb276aa8
commit
00945d79e7
@ -11,6 +11,7 @@ import androidx.recyclerview.widget.ListAdapter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import awais.instagrabber.adapters.viewholder.NotificationViewHolder;
|
import awais.instagrabber.adapters.viewholder.NotificationViewHolder;
|
||||||
@ -24,12 +25,12 @@ public final class NotificationsAdapter extends ListAdapter<Notification, Notifi
|
|||||||
private static final DiffUtil.ItemCallback<Notification> DIFF_CALLBACK = new DiffUtil.ItemCallback<Notification>() {
|
private static final DiffUtil.ItemCallback<Notification> DIFF_CALLBACK = new DiffUtil.ItemCallback<Notification>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean areItemsTheSame(final Notification oldItem, final Notification newItem) {
|
public boolean areItemsTheSame(final Notification oldItem, final Notification newItem) {
|
||||||
return oldItem.getPk().equals(newItem.getPk());
|
return Objects.requireNonNull(oldItem.getPk()).equals(newItem.getPk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areContentsTheSame(@NonNull final Notification oldItem, @NonNull final Notification newItem) {
|
public boolean areContentsTheSame(@NonNull final Notification oldItem, @NonNull final Notification newItem) {
|
||||||
return oldItem.getPk().equals(newItem.getPk()) && oldItem.getType() == newItem.getType();
|
return Objects.requireNonNull(oldItem.getPk()).equals(newItem.getPk()) && Objects.equals(oldItem.getType(), newItem.getType());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,8 +73,8 @@ public final class NotificationsAdapter extends ListAdapter<Notification, Notifi
|
|||||||
|
|
||||||
private List<Notification> sort(final List<Notification> list) {
|
private List<Notification> sort(final List<Notification> list) {
|
||||||
final List<Notification> listCopy = new ArrayList<>(list).stream()
|
final List<Notification> listCopy = new ArrayList<>(list).stream()
|
||||||
.filter(i -> i.getType() != null)
|
.filter(i -> i.getType() != null)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Collections.sort(listCopy, (o1, o2) -> {
|
Collections.sort(listCopy, (o1, o2) -> {
|
||||||
// keep requests at top
|
// keep requests at top
|
||||||
if (o1.getType() == o2.getType()
|
if (o1.getType() == o2.getType()
|
||||||
|
@ -5,7 +5,7 @@ import awais.instagrabber.models.enums.NotificationType.Companion.valueOfType
|
|||||||
|
|
||||||
class Notification(val args: NotificationArgs,
|
class Notification(val args: NotificationArgs,
|
||||||
private val storyType: Int,
|
private val storyType: Int,
|
||||||
val pk: String) {
|
val pk: String?) {
|
||||||
val type: NotificationType?
|
val type: NotificationType?
|
||||||
get() = valueOfType(storyType)
|
get() = valueOfType(storyType)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user