Search in sources :

Example 1 with EmoticonsKeyboardBuilder

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();
}
Also used : EmoticonsKeyboardBuilder(cn.hadcn.keyboard.emoticon.util.EmoticonsKeyboardBuilder) EmoticonDBHelper(cn.hadcn.keyboard.emoticon.db.EmoticonDBHelper) EmoticonSetBean(cn.hadcn.keyboard.emoticon.EmoticonSetBean)

Example 2 with EmoticonsKeyboardBuilder

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;
}
Also used : KeyEvent(android.view.KeyEvent) EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) EmoticonsKeyboardBuilder(cn.hadcn.keyboard.emoticon.util.EmoticonsKeyboardBuilder) Editable(android.text.Editable) EmoticonLayout(cn.hadcn.keyboard.emoticon.view.EmoticonLayout) LinearLayout(android.widget.LinearLayout)

Aggregations

EmoticonsKeyboardBuilder (cn.hadcn.keyboard.emoticon.util.EmoticonsKeyboardBuilder)2 Editable (android.text.Editable)1 KeyEvent (android.view.KeyEvent)1 LinearLayout (android.widget.LinearLayout)1 EmoticonBean (cn.hadcn.keyboard.emoticon.EmoticonBean)1 EmoticonSetBean (cn.hadcn.keyboard.emoticon.EmoticonSetBean)1 EmoticonDBHelper (cn.hadcn.keyboard.emoticon.db.EmoticonDBHelper)1 EmoticonLayout (cn.hadcn.keyboard.emoticon.view.EmoticonLayout)1