Skip to content

Commit 3f53833

Browse files
committed
update compile 'com.github.w446108264:AndroidEmoji:1.3-withsource' for simple2
1 parent 1404bda commit 3f53833

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Simple2/app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ dependencies {
2525
compile 'com.android.support:appcompat-v7:23.3.0'
2626

2727
compile 'com.github.w446108264:XhsEmoticonsKeyboard:2.0.3'
28-
compile 'com.github.w446108264:AndroidEmoji:1.0.0'
28+
compile 'com.github.w446108264:AndroidEmoji:1.3-withsource'
29+
2930
}

Simple2/app/src/main/java/com/simple2/MainActivity.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.simple2;
22

3+
import android.graphics.drawable.Drawable;
34
import android.os.Bundle;
45
import android.support.v7.app.AppCompatActivity;
56
import android.text.Editable;
@@ -41,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {
4142

4243
// source data
4344
ArrayList<EmojiBean> emojiArray = new ArrayList<>();
44-
Collections.addAll(emojiArray, DefEmoticons.sEmojiArray);
45+
Collections.addAll(emojiArray, DefEmoticons.getDefEmojiArray());
4546

4647
// emoticon click
4748
final EmoticonClickListener emoticonClickListener = new EmoticonClickListener() {
@@ -142,7 +143,22 @@ public void filter(EditText editText, CharSequence text, int start, int lengthBe
142143
if (m != null) {
143144
while (m.find()) {
144145
String emojiHex = Integer.toHexString(Character.codePointAt(m.group(), 0));
145-
EmojiDisplay.emojiDisplay(editText.getContext(), editText.getText(), emojiHex, emojiSize, start + m.start(), start + m.end());
146+
Drawable drawable = getDrawable(editText.getContext(), EmojiDisplay.HEAD_NAME + emojiHex);
147+
if(drawable != null) {
148+
int itemHeight;
149+
int itemWidth;
150+
if(emojiSize == EmojiDisplay.WRAP_DRAWABLE) {
151+
itemHeight = drawable.getIntrinsicHeight();
152+
itemWidth = drawable.getIntrinsicWidth();
153+
} else {
154+
itemHeight = emojiSize;
155+
itemWidth = emojiSize;
156+
}
157+
158+
drawable.setBounds(0, 0, itemHeight, itemWidth);
159+
EmojiSpan imageSpan = new EmojiSpan(drawable);
160+
editText.getText().setSpan(imageSpan, start + m.start(), start + m.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
161+
}
146162
}
147163
}
148164
}

0 commit comments

Comments
 (0)