parent
065cbcf0f9
commit
e006306036
3 changed files with 46 additions and 1 deletions
|
@ -9,6 +9,7 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
@ -35,7 +36,7 @@ final class ReactWithAnyEmojiAdapter extends ListAdapter<ReactWithAnyEmojiPage,
|
|||
@NonNull EmojiPageViewGridAdapter.VariationSelectorListener variationSelectorListener,
|
||||
@NonNull Callbacks callbacks)
|
||||
{
|
||||
super(new AlwaysChangedDiffUtil<>());
|
||||
super(new PageChangedCallback());
|
||||
|
||||
this.emojiEventListener = emojiEventListener;
|
||||
this.variationSelectorListener = variationSelectorListener;
|
||||
|
@ -169,4 +170,17 @@ final class ReactWithAnyEmojiAdapter extends ListAdapter<ReactWithAnyEmojiPage,
|
|||
interface ScrollableChild {
|
||||
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 java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents a swipeable page in the ReactWithAnyEmoji dialog fragment, encapsulating any
|
||||
|
@ -41,4 +42,17 @@ class ReactWithAnyEmojiPage {
|
|||
public @AttrRes int 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 java.util.Objects;
|
||||
|
||||
/**
|
||||
* Wraps a single "class" of Emojis, be it a predefined category, recents, etc. and provides
|
||||
* a label for that "class".
|
||||
|
@ -26,4 +28,19 @@ class ReactWithAnyEmojiPageBlock {
|
|||
public EmojiPageModel getPageModel() {
|
||||
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…
Add table
Reference in a new issue