mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-02-04 11:57:34 +01:00
Remove unnecessary emoji class
This commit is contained in:
parent
276270fa63
commit
c3bd3f787e
@ -6,11 +6,10 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.media.emoji.Emoji
|
||||
import kotlinx.android.synthetic.main.item_emoji.view.*
|
||||
|
||||
class EmojisAdapter(
|
||||
val context: Context, var items: List<Emoji>, val itemClick: (emoji: Emoji) -> Unit
|
||||
val context: Context, var items: List<String>, val itemClick: (emoji: String) -> Unit
|
||||
) : RecyclerView.Adapter<EmojisAdapter.ViewHolder>() {
|
||||
|
||||
private val layoutInflater = LayoutInflater.from(context)
|
||||
@ -32,17 +31,17 @@ class EmojisAdapter(
|
||||
return items.size
|
||||
}
|
||||
|
||||
private fun setupEmoji(view: View, emoji: Emoji) {
|
||||
view.emoji_value.text = emoji.value
|
||||
private fun setupEmoji(view: View, emoji: String) {
|
||||
view.emoji_value.text = emoji
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
fun bindView(any: Emoji, callback: (itemView: View) -> Unit): View {
|
||||
fun bindView(emoji: String, callback: (itemView: View) -> Unit): View {
|
||||
return itemView.apply {
|
||||
callback(this)
|
||||
|
||||
setOnClickListener {
|
||||
itemClick.invoke(any)
|
||||
itemClick.invoke(emoji)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.simplemobiletools.keyboard.media.emoji
|
||||
package com.simplemobiletools.keyboard.helpers
|
||||
|
||||
import android.content.Context
|
||||
|
||||
private var cachedEmojiData: MutableList<Emoji>? = null
|
||||
private var cachedEmojiData: MutableList<String>? = null
|
||||
|
||||
/**
|
||||
* Reads the emoji list at the given [path] and returns an parsed [MutableList]. If the
|
||||
@ -13,10 +13,10 @@ private var cachedEmojiData: MutableList<Emoji>? = null
|
||||
*/
|
||||
fun parseRawEmojiSpecsFile(
|
||||
context: Context, path: String
|
||||
): MutableList<Emoji> {
|
||||
): MutableList<String> {
|
||||
cachedEmojiData?.let { return it }
|
||||
val emojis = mutableListOf<Emoji>()
|
||||
var emojiEditorList: MutableList<Emoji>? = null
|
||||
val emojis = mutableListOf<String>()
|
||||
var emojiEditorList: MutableList<String>? = null
|
||||
|
||||
fun commitEmojiEditorList() {
|
||||
emojiEditorList?.let {
|
||||
@ -42,11 +42,7 @@ fun parseRawEmojiSpecsFile(
|
||||
// Assume it is a data line
|
||||
val data = line.split(";")
|
||||
if (data.size == 3) {
|
||||
val emoji = Emoji(
|
||||
value = data[0].trim(),
|
||||
name = data[1].trim(),
|
||||
keywords = data[2].split("|").map { it.trim() }
|
||||
)
|
||||
val emoji = data[0].trim()
|
||||
if (emojiEditorList != null) {
|
||||
emojiEditorList!!.add(emoji)
|
||||
} else {
|
@ -1,8 +0,0 @@
|
||||
package com.simplemobiletools.keyboard.media.emoji
|
||||
|
||||
|
||||
data class Emoji(val value: String, val name: String, val keywords: List<String>) {
|
||||
override fun toString(): String {
|
||||
return "Emoji { value=$value, name=$name, keywords=$keywords }"
|
||||
}
|
||||
}
|
@ -43,8 +43,6 @@ import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_MODE_
|
||||
import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SHIFT
|
||||
import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SPACE
|
||||
import com.simplemobiletools.keyboard.interfaces.RefreshClipsListener
|
||||
import com.simplemobiletools.keyboard.media.emoji.Emoji
|
||||
import com.simplemobiletools.keyboard.media.emoji.parseRawEmojiSpecsFile
|
||||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import com.simplemobiletools.keyboard.models.ClipsSectionLabel
|
||||
import com.simplemobiletools.keyboard.models.ListItem
|
||||
@ -1444,7 +1442,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
typeface = Typeface.DEFAULT
|
||||
}
|
||||
val emojis = fullEmojiList.filter { emoji ->
|
||||
systemFontPaint.hasGlyph(emoji.value)
|
||||
systemFontPaint.hasGlyph(emoji)
|
||||
}
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
setupEmojiAdapter(emojis)
|
||||
@ -1452,14 +1450,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupEmojiAdapter(emojis: List<Emoji>) {
|
||||
private fun setupEmojiAdapter(emojis: List<String>) {
|
||||
val emojiItemWidth = context.resources.getDimensionPixelSize(R.dimen.emoji_item_size)
|
||||
val emojiTopBarElevation = context.resources.getDimensionPixelSize(R.dimen.emoji_top_bar_elevation).toFloat()
|
||||
|
||||
mEmojiPaletteHolder!!.emojis_list.apply {
|
||||
layoutManager = AutoGridLayoutManager(context, emojiItemWidth)
|
||||
adapter = EmojisAdapter(context = context, items = emojis) { emoji ->
|
||||
mOnKeyboardActionListener!!.onText(emoji.value)
|
||||
mOnKeyboardActionListener!!.onText(emoji)
|
||||
vibrateIfNeeded()
|
||||
}
|
||||
onScroll {
|
||||
|
Loading…
x
Reference in New Issue
Block a user