Inspired by XhsEmoticonsKeyboard, the framework was redesigned and the function of dynamically updating emoticons was added. Using EmoticonPacksAdapter, you can easily add or remove emoticons.
The new code is developed using Kotlin.
allprojects {
repositories {
jcenter()
}
}
and:
dependencies {
compile 'im.ll:emoticonsboard:1.0.0'
}
EmoticonsBoard displays emoticons by setting EmoticonPacksAdapter. EmoticonPacksAdapter contains a list of EmoticonPacks used to carry emoticon data. Each EmoticonPack represents an emoticon collection. PageFactory is used to create Views that display expressions, and expressions are displayed in the form of Pages. By customizing different PageFactory, you can display emoticons in different ways.
< github .ll.emotionboard.EmoticonsBoard xmlns : android = " http://schemas.android.com/apk/res/android "
xmlns : app = " http://schemas.android.com/apk/res-auto "
android : layout_width = " match_parent "
android : layout_height = " match_parent "
android : orientation = " vertical " >
< LinearLayout
android : layout_width = " match_parent "
android : layout_height = " match_parent "
android : orientation = " vertical " >
< ListView
android : layout_width = " match_parent "
android : layout_height = " match_parent " />
</ LinearLayout >
</ github .ll.emotionboard.EmoticonsBoard>
EmoticonsBoard can only have one child view
Java code:
EmoticonsBoard ekBar;
List<EmoticonPack> packs = new ArrayList<EmoticonPack>;
init packs...
EmoticonPacksAdapter adapter = new EmoticonPacksAdapter(packs);
ekBar.setAdapter(adapter);
For details refer to the demo source
Kotlin code:
private var adapter: EmoticonPacksAdapter? = null
private lateinit var mEmojiPack: EmoticonPack<Emoticon>
...
val emoticon = Emoticon()
emoticon.code = "new emoji"
emoticon.uri = "xxx"
mEmojiPack.emoticons.add(emoticon)
mEmojiPack.emoticons.add(emoticon)
mEmojiPack.isDataChanged = true
adapter?.notifyDataSetChanged()
Make modified emoticonPack's isDataChanged to true is very important