From 3f538336e9055610de86fa4336017f769f27849c Mon Sep 17 00:00:00 2001 From: w446108264 <446108264@qq.com> Date: Mon, 13 Jun 2016 13:56:26 +0800 Subject: [PATCH] update compile 'com.github.w446108264:AndroidEmoji:1.3-withsource' for simple2 --- Simple2/app/build.gradle | 3 ++- .../main/java/com/simple2/MainActivity.java | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Simple2/app/build.gradle b/Simple2/app/build.gradle index 4f3843b..f880361 100644 --- a/Simple2/app/build.gradle +++ b/Simple2/app/build.gradle @@ -25,5 +25,6 @@ dependencies { compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.github.w446108264:XhsEmoticonsKeyboard:2.0.3' - compile 'com.github.w446108264:AndroidEmoji:1.0.0' + compile 'com.github.w446108264:AndroidEmoji:1.3-withsource' + } diff --git a/Simple2/app/src/main/java/com/simple2/MainActivity.java b/Simple2/app/src/main/java/com/simple2/MainActivity.java index e2a7c90..1c1c2f2 100644 --- a/Simple2/app/src/main/java/com/simple2/MainActivity.java +++ b/Simple2/app/src/main/java/com/simple2/MainActivity.java @@ -1,5 +1,6 @@ package com.simple2; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.text.Editable; @@ -41,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) { // source data ArrayList emojiArray = new ArrayList<>(); - Collections.addAll(emojiArray, DefEmoticons.sEmojiArray); + Collections.addAll(emojiArray, DefEmoticons.getDefEmojiArray()); // emoticon click final EmoticonClickListener emoticonClickListener = new EmoticonClickListener() { @@ -142,7 +143,22 @@ public void filter(EditText editText, CharSequence text, int start, int lengthBe if (m != null) { while (m.find()) { String emojiHex = Integer.toHexString(Character.codePointAt(m.group(), 0)); - EmojiDisplay.emojiDisplay(editText.getContext(), editText.getText(), emojiHex, emojiSize, start + m.start(), start + m.end()); + Drawable drawable = getDrawable(editText.getContext(), EmojiDisplay.HEAD_NAME + emojiHex); + if(drawable != null) { + int itemHeight; + int itemWidth; + if(emojiSize == EmojiDisplay.WRAP_DRAWABLE) { + itemHeight = drawable.getIntrinsicHeight(); + itemWidth = drawable.getIntrinsicWidth(); + } else { + itemHeight = emojiSize; + itemWidth = emojiSize; + } + + drawable.setBounds(0, 0, itemHeight, itemWidth); + EmojiSpan imageSpan = new EmojiSpan(drawable); + editText.getText().setSpan(imageSpan, start + m.start(), start + m.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + } } } }