use of cn.hadcn.keyboard.emoticon.util.EmoticonsKeyboardBuilder in project ChatKeyboard by CPPAlien.
the class ChatKeyboardLayout method getBuilder.
private EmoticonsKeyboardBuilder getBuilder(Context context) {
if (context == null) {
throw new RuntimeException("Context is null, cannot create db helper");
}
EmoticonDBHelper emoticonDbHelper = new EmoticonDBHelper(context);
ArrayList<EmoticonSetBean> mEmoticonSetBeanList = emoticonDbHelper.queryAllEmoticonSet();
emoticonDbHelper.cleanup();
return new EmoticonsKeyboardBuilder.Builder().setEmoticonSetBeanList(mEmoticonSetBeanList).build();
}
use of cn.hadcn.keyboard.emoticon.util.EmoticonsKeyboardBuilder in project ChatKeyboard by CPPAlien.
the class ChatKeyboardLayout method showEmoticons.
public void showEmoticons() {
btnEmoticon.setVisibility(VISIBLE);
EmoticonsKeyboardBuilder builder = getBuilder(mContext);
EmoticonLayout layout = new EmoticonLayout(mContext);
layout.setContents(builder, new EmoticonLayout.OnEmoticonListener() {
@Override
public void onEmoticonItemClicked(EmoticonBean bean) {
if (etInputArea != null) {
setEditableState(true);
if (bean.getEventType() == EmoticonBean.FACE_TYPE_DEL) {
int action = KeyEvent.ACTION_DOWN;
int code = KeyEvent.KEYCODE_DEL;
KeyEvent event = new KeyEvent(action, code);
etInputArea.onKeyDown(KeyEvent.KEYCODE_DEL, event);
return;
} else if (bean.getEventType() == EmoticonBean.FACE_TYPE_STICKER) {
if (mOnChatKeyBoardListener != null) {
mOnChatKeyBoardListener.onUserDefEmoticonClicked(bean.getTag(), bean.getIconUri());
}
return;
}
int index = etInputArea.getSelectionStart();
Editable editable = etInputArea.getEditableText();
if (index < 0) {
editable.append(bean.getTag());
} else {
editable.insert(index, bean.getTag());
}
}
}
});
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
lyBottomLayout.addView(layout, params);
FUNC_EMOTICON_POS = FUNC_ORDER_COUNT;
++FUNC_ORDER_COUNT;
}
Aggregations