Search in sources :

Example 1 with SoftKeyboardStateHelper

use of org.kymjs.emoji.helper.SoftKeyboardStateHelper in project KJFrameForAndroid by kymjs.

the class KJEmojiFragment method initWidget.

private void initWidget(View rootView) {
    // title
    mEmojiTitle = rootView.findViewById(R.id.emoji_title);
    mEt = (EditText) mEmojiTitle.findViewById(R.id.emoji_titile_input);
    mCBox = (CheckBox) mEmojiTitle.findViewById(R.id.emoji_title_menu);
    mCBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showEmojiKeyBoard();
                hideSoftKeyboard();
            } else {
                hideEmojiKeyBoard();
                showSoftKeyboard();
            }
        }
    });
    // bottom
    mEmojiBottom = (RadioGroup) rootView.findViewById(R.id.emoji_bottom);
    // 减一是因为有一个删除按钮
    EMOJI_TAB_CONTENT = mEmojiBottom.getChildCount() - 1;
    mEmojiTabs = new View[EMOJI_TAB_CONTENT];
    if (EMOJI_TAB_CONTENT <= 1) {
        // 只有一个分类的时候就不显示了
        mEmojiBottom.setVisibility(View.GONE);
    }
    for (int i = 0; i < EMOJI_TAB_CONTENT; i++) {
        mEmojiTabs[i] = mEmojiBottom.getChildAt(i);
        mEmojiTabs[i].setOnClickListener(getBottomBarClickListener(i));
    }
    mEmojiBottom.findViewById(R.id.emoji_bottom_del).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            InputHelper.backspace(mEt);
        }
    });
    // content必须放在bottom下面初始化
    mEmojiContent = (LinearLayout) rootView.findViewById(R.id.emoji_content);
    LayoutParams params = (LayoutParams) mEmojiContent.getLayoutParams();
    params.height = EMOJI_TAB_CONTENT > 1 ? KJEmojiConfig.MORE_TYPE_HEIGHT : KJEmojiConfig.SINGLE_TYPE_HEIGHT;
    mEmojiContent.setLayoutParams(params);
    mEmojiPager = (ViewPager) mEmojiContent.findViewById(R.id.emoji_pager);
    adapter = new EmojiPagerAdapter(getFragmentManager());
    mEmojiPager.setAdapter(adapter);
    mKeyboardHelper = new SoftKeyboardStateHelper(getActivity().getWindow().getDecorView());
    mKeyboardHelper.addSoftKeyboardStateListener(this);
    if (getActivity() instanceof OnSendClickListener) {
        listener = (OnSendClickListener) getActivity();
        mEmojiTitle.findViewById(R.id.emoji_title_send).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                listener.onClickSendButton(mEt.getText());
            }
        });
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) LayoutParams(android.widget.LinearLayout.LayoutParams) OnClickListener(android.view.View.OnClickListener) View(android.view.View) SoftKeyboardStateHelper(org.kymjs.emoji.helper.SoftKeyboardStateHelper) CompoundButton(android.widget.CompoundButton) EmojiPagerAdapter(org.kymjs.emoji.adapter.EmojiPagerAdapter)

Aggregations

View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 CompoundButton (android.widget.CompoundButton)1 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)1 LayoutParams (android.widget.LinearLayout.LayoutParams)1 EmojiPagerAdapter (org.kymjs.emoji.adapter.EmojiPagerAdapter)1 SoftKeyboardStateHelper (org.kymjs.emoji.helper.SoftKeyboardStateHelper)1