use of com.waz.zclient.ui.colorpicker.EmojiAdapter in project wire-android by wireapp.
the class EmojiKeyboardLayout method init.
private void init() {
currentEmojiSize = EmojiSize.MEDIUM;
categoryPositions = new int[CATEGORY_COUNT];
emojiAdapter = new EmojiAdapter(getContext());
layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT, LinearLayoutManager.HORIZONTAL, false);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return spaces.contains(position) ? SPAN_COUNT : 1;
}
});
layoutManager.setSpanCount(SPAN_COUNT);
recyclerView.addOnScrollListener(new EmojiScrollListener());
tapIndicatorLayout.setShowDivider(false);
tapIndicatorLayout.setGlyphLabels(Emojis.EMOJI_KEYBOARD_TAB_LABELS);
tapIndicatorLayout.setTextColor(ContextCompat.getColorStateList(getContext(), R.color.wire__text_color_dark_selector));
tapIndicatorLayout.setPrimaryColor(ContextCompat.getColor(getContext(), R.color.text__primary_dark));
tapIndicatorLayout.setLabelHeight(getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_label_size));
tapIndicatorLayout.setCallback(new TabIndicatorLayout.Callback() {
@Override
public void onItemSelected(int pos) {
if (ViewCompat.getLayoutDirection(EmojiKeyboardLayout.this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
// Revert tab position for RTL layout
pos = (TAB_COUNT - 1) - pos;
}
if (pos == TAB_COUNT - 1) {
Threading.Background().execute(new Runnable() {
@Override
public void run() {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DEL);
}
});
} else {
tapIndicatorLayout.setSelected(pos);
layoutManager.scrollToPositionWithOffset(getCategoryByTabPosition(pos), 0);
}
}
});
recyclerView.setAdapter(emojiAdapter);
recyclerView.setLayoutManager(layoutManager);
setRecyclerViewPadding(recyclerView);
emojiAdapter.setOnEmojiClickListener(new EmojiAdapter.OnEmojiClickListener() {
@Override
public void onEmojiClick(String emoji, EmojiSize emojiSize) {
if (callback != null) {
callback.onEmojiSelected(emoji);
}
}
});
}
Aggregations