Skip to content

Commit

Permalink
update compile 'com.github.w446108264:AndroidEmoji:1.3-withsource' fo…
Browse files Browse the repository at this point in the history
…r simple2
  • Loading branch information
w446108264 committed Jun 13, 2016
1 parent 1404bda commit 3f53833
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Simple2/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

}
20 changes: 18 additions & 2 deletions Simple2/app/src/main/java/com/simple2/MainActivity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {

// source data
ArrayList<EmojiBean> emojiArray = new ArrayList<>();
Collections.addAll(emojiArray, DefEmoticons.sEmojiArray);
Collections.addAll(emojiArray, DefEmoticons.getDefEmojiArray());

// emoticon click
final EmoticonClickListener emoticonClickListener = new EmoticonClickListener() {
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit 3f53833

Please sign in to comment.