From b483a0bf250c9f897489b8cbf68cb2aa192dd018 Mon Sep 17 00:00:00 2001 From: Levi Bard Date: Sun, 4 Nov 2018 10:51:31 +0100 Subject: [PATCH] Filter emoji where "visible_in_picker" is set to false. (#907) Addresses #770 --- .../main/java/com/keylesspalace/tusky/ComposeActivity.java | 1 - .../java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt | 7 ++++++- app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index c582d22d..ddee3f37 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -125,7 +125,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.Iterator; import java.util.List; diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt index 61e131b4..8d31ae6f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt @@ -23,7 +23,12 @@ import com.keylesspalace.tusky.R import com.keylesspalace.tusky.entity.Emoji import com.squareup.picasso.Picasso -class EmojiAdapter(private val emojiList: List, private val onEmojiSelectedListener: OnEmojiSelectedListener) : RecyclerView.Adapter() { +class EmojiAdapter(emojiList: List, private val onEmojiSelectedListener: OnEmojiSelectedListener) : RecyclerView.Adapter() { + private val emojiList : List + + init { + this.emojiList = emojiList.filter { emoji -> emoji.visibleInPicker == null || emoji.visibleInPicker } + } override fun getItemCount(): Int { return emojiList.size diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt index 1c0cb4dc..baee54bc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt @@ -16,10 +16,12 @@ package com.keylesspalace.tusky.entity import android.os.Parcelable +import com.google.gson.annotations.SerializedName import kotlinx.android.parcel.Parcelize @Parcelize data class Emoji( val shortcode: String, - val url: String + val url: String, + @SerializedName("visible_in_picker") val visibleInPicker: Boolean? ) : Parcelable \ No newline at end of file