use of org.kymjs.emoji.adapter.EmojiPagerAdapter 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());
}
});
}
}
Aggregations