mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-29 18:38:29 +00:00
parent
065cbcf0f9
commit
e006306036
@ -9,6 +9,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.widget.NestedScrollView;
|
import androidx.core.widget.NestedScrollView;
|
||||||
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
import androidx.recyclerview.widget.ListAdapter;
|
import androidx.recyclerview.widget.ListAdapter;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ final class ReactWithAnyEmojiAdapter extends ListAdapter<ReactWithAnyEmojiPage,
|
|||||||
@NonNull EmojiPageViewGridAdapter.VariationSelectorListener variationSelectorListener,
|
@NonNull EmojiPageViewGridAdapter.VariationSelectorListener variationSelectorListener,
|
||||||
@NonNull Callbacks callbacks)
|
@NonNull Callbacks callbacks)
|
||||||
{
|
{
|
||||||
super(new AlwaysChangedDiffUtil<>());
|
super(new PageChangedCallback());
|
||||||
|
|
||||||
this.emojiEventListener = emojiEventListener;
|
this.emojiEventListener = emojiEventListener;
|
||||||
this.variationSelectorListener = variationSelectorListener;
|
this.variationSelectorListener = variationSelectorListener;
|
||||||
@ -169,4 +170,17 @@ final class ReactWithAnyEmojiAdapter extends ListAdapter<ReactWithAnyEmojiPage,
|
|||||||
interface ScrollableChild {
|
interface ScrollableChild {
|
||||||
void setNestedScrollingEnabled(boolean isEnabled);
|
void setNestedScrollingEnabled(boolean isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class PageChangedCallback extends DiffUtil.ItemCallback<ReactWithAnyEmojiPage> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(@NonNull ReactWithAnyEmojiPage oldItem, @NonNull ReactWithAnyEmojiPage newItem) {
|
||||||
|
return oldItem.getLabel() == newItem.getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(@NonNull ReactWithAnyEmojiPage oldItem, @NonNull ReactWithAnyEmojiPage newItem) {
|
||||||
|
return oldItem.equals(newItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import androidx.annotation.StringRes;
|
|||||||
import org.whispersystems.libsignal.util.guava.Preconditions;
|
import org.whispersystems.libsignal.util.guava.Preconditions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a swipeable page in the ReactWithAnyEmoji dialog fragment, encapsulating any
|
* Represents a swipeable page in the ReactWithAnyEmoji dialog fragment, encapsulating any
|
||||||
@ -41,4 +42,17 @@ class ReactWithAnyEmojiPage {
|
|||||||
public @AttrRes int getIconAttr() {
|
public @AttrRes int getIconAttr() {
|
||||||
return pageBlocks.get(0).getPageModel().getIconAttr();
|
return pageBlocks.get(0).getPageModel().getIconAttr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
ReactWithAnyEmojiPage that = (ReactWithAnyEmojiPage) o;
|
||||||
|
return pageBlocks.equals(that.pageBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(pageBlocks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import androidx.annotation.StringRes;
|
|||||||
|
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiPageModel;
|
import org.thoughtcrime.securesms.components.emoji.EmojiPageModel;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a single "class" of Emojis, be it a predefined category, recents, etc. and provides
|
* Wraps a single "class" of Emojis, be it a predefined category, recents, etc. and provides
|
||||||
* a label for that "class".
|
* a label for that "class".
|
||||||
@ -26,4 +28,19 @@ class ReactWithAnyEmojiPageBlock {
|
|||||||
public EmojiPageModel getPageModel() {
|
public EmojiPageModel getPageModel() {
|
||||||
return pageModel;
|
return pageModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
ReactWithAnyEmojiPageBlock that = (ReactWithAnyEmojiPageBlock) o;
|
||||||
|
return label == that.label &&
|
||||||
|
pageModel.getIconAttr() == that.pageModel.getIconAttr() &&
|
||||||
|
Objects.equals(pageModel.getEmoji(), that.pageModel.getEmoji());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(label, pageModel.getEmoji());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user