Search in sources :

Example 1 with EmojiHeader

use of org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiHeader in project Signal-Android by signalapp.

the class EmojiPageView method initialize.

public void initialize(@NonNull EmojiEventListener emojiSelectionListener, @NonNull VariationSelectorListener variationSelectorListener, boolean allowVariations, @NonNull LinearLayoutManager layoutManager, @LayoutRes int displayEmojiLayoutResId, @LayoutRes int displayEmoticonLayoutResId) {
    this.variationSelectorListener = variationSelectorListener;
    this.layoutManager = layoutManager;
    this.scrollDisabler = new ScrollDisabler();
    this.popup = new EmojiVariationSelectorPopup(getContext(), emojiSelectionListener);
    this.adapterFactory = () -> new EmojiPageViewGridAdapter(popup, emojiSelectionListener, this, allowVariations, displayEmojiLayoutResId, displayEmoticonLayoutResId);
    if (this.layoutManager instanceof GridLayoutManager) {
        GridLayoutManager gridLayout = (GridLayoutManager) this.layoutManager;
        gridLayout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                if (getAdapter() != null) {
                    Optional<MappingModel<?>> model = getAdapter().getModel(position);
                    if (model.isPresent() && (model.get() instanceof EmojiHeader || model.get() instanceof EmojiNoResultsModel)) {
                        return gridLayout.getSpanCount();
                    }
                }
                return 1;
            }
        });
    }
    setLayoutManager(layoutManager);
    Drawable drawable = DrawableUtil.tint(ContextUtil.requireDrawable(getContext(), R.drawable.triangle_bottom_right_corner), ContextCompat.getColor(getContext(), R.color.signal_button_secondary_text_disabled));
    addItemDecoration(new EmojiItemDecoration(allowVariations, drawable));
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Optional(java.util.Optional) EmojiNoResultsModel(org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiNoResultsModel) Drawable(android.graphics.drawable.Drawable) EmojiHeader(org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiHeader)

Example 2 with EmojiHeader

use of org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiHeader in project Signal-Android by WhisperSystems.

the class EmojiPageView method initialize.

public void initialize(@NonNull EmojiEventListener emojiSelectionListener, @NonNull VariationSelectorListener variationSelectorListener, boolean allowVariations, @NonNull LinearLayoutManager layoutManager, @LayoutRes int displayEmojiLayoutResId, @LayoutRes int displayEmoticonLayoutResId) {
    this.variationSelectorListener = variationSelectorListener;
    this.layoutManager = layoutManager;
    this.scrollDisabler = new ScrollDisabler();
    this.popup = new EmojiVariationSelectorPopup(getContext(), emojiSelectionListener);
    this.adapterFactory = () -> new EmojiPageViewGridAdapter(popup, emojiSelectionListener, this, allowVariations, displayEmojiLayoutResId, displayEmoticonLayoutResId);
    if (this.layoutManager instanceof GridLayoutManager) {
        GridLayoutManager gridLayout = (GridLayoutManager) this.layoutManager;
        gridLayout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                if (getAdapter() != null) {
                    Optional<MappingModel<?>> model = getAdapter().getModel(position);
                    if (model.isPresent() && (model.get() instanceof EmojiHeader || model.get() instanceof EmojiNoResultsModel)) {
                        return gridLayout.getSpanCount();
                    }
                }
                return 1;
            }
        });
    }
    setLayoutManager(layoutManager);
    Drawable drawable = DrawableUtil.tint(ContextUtil.requireDrawable(getContext(), R.drawable.triangle_bottom_right_corner), ContextCompat.getColor(getContext(), R.color.signal_button_secondary_text_disabled));
    addItemDecoration(new EmojiItemDecoration(allowVariations, drawable));
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Optional(java.util.Optional) EmojiNoResultsModel(org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiNoResultsModel) Drawable(android.graphics.drawable.Drawable) EmojiHeader(org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiHeader)

Aggregations

Drawable (android.graphics.drawable.Drawable)2 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)2 Optional (java.util.Optional)2 EmojiHeader (org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiHeader)2 EmojiNoResultsModel (org.thoughtcrime.securesms.components.emoji.EmojiPageViewGridAdapter.EmojiNoResultsModel)2