|
1 | 1 | package com.simple2; |
2 | 2 |
|
| 3 | +import android.graphics.drawable.Drawable; |
3 | 4 | import android.os.Bundle; |
4 | 5 | import android.support.v7.app.AppCompatActivity; |
5 | 6 | import android.text.Editable; |
@@ -41,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) { |
41 | 42 |
|
42 | 43 | // source data |
43 | 44 | ArrayList<EmojiBean> emojiArray = new ArrayList<>(); |
44 | | - Collections.addAll(emojiArray, DefEmoticons.sEmojiArray); |
| 45 | + Collections.addAll(emojiArray, DefEmoticons.getDefEmojiArray()); |
45 | 46 |
|
46 | 47 | // emoticon click |
47 | 48 | final EmoticonClickListener emoticonClickListener = new EmoticonClickListener() { |
@@ -142,7 +143,22 @@ public void filter(EditText editText, CharSequence text, int start, int lengthBe |
142 | 143 | if (m != null) { |
143 | 144 | while (m.find()) { |
144 | 145 | 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 | + } |
146 | 162 | } |
147 | 163 | } |
148 | 164 | } |
|
0 commit comments