Search in sources :

Example 1 with FeaturedStickerSetInfoCell

use of org.telegram.ui.Cells.FeaturedStickerSetInfoCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class EmojiView method updateVisibleTrendingSets.

private void updateVisibleTrendingSets() {
    if (stickersGridView == null) {
        return;
    }
    try {
        int count = stickersGridView.getChildCount();
        for (int a = 0; a < count; a++) {
            View child = stickersGridView.getChildAt(a);
            if (child instanceof FeaturedStickerSetInfoCell) {
                RecyclerListView.Holder holder = (RecyclerListView.Holder) stickersGridView.getChildViewHolder(child);
                if (holder == null) {
                    continue;
                }
                FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) child;
                ArrayList<Long> unreadStickers = MediaDataController.getInstance(currentAccount).getUnreadStickerSets();
                TLRPC.StickerSetCovered stickerSetCovered = cell.getStickerSet();
                boolean unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
                boolean forceInstalled = false;
                for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
                    if (primaryInstallingStickerSets[i] != null && primaryInstallingStickerSets[i].set.id == stickerSetCovered.set.id) {
                        forceInstalled = true;
                        break;
                    }
                }
                cell.setStickerSet(stickerSetCovered, unread, true, 0, 0, forceInstalled);
                if (unread) {
                    MediaDataController.getInstance(currentAccount).markFaturedStickersByIdAsRead(stickerSetCovered.set.id);
                }
                boolean installing = installingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0;
                boolean removing = removingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0;
                if (installing || removing) {
                    if (installing && cell.isInstalled()) {
                        installingStickerSets.remove(stickerSetCovered.set.id);
                        installing = false;
                    } else if (removing && !cell.isInstalled()) {
                        removingStickerSets.remove(stickerSetCovered.set.id);
                        removing = false;
                    }
                }
                cell.setAddDrawProgress(!forceInstalled && installing, true);
            }
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
Also used : FeaturedStickerSetInfoCell(org.telegram.ui.Cells.FeaturedStickerSetInfoCell) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) TLRPC(org.telegram.tgnet.TLRPC)

Example 2 with FeaturedStickerSetInfoCell

use of org.telegram.ui.Cells.FeaturedStickerSetInfoCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class StickersSearchAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = null;
    switch(viewType) {
        case 0:
            StickerEmojiCell stickerEmojiCell = new StickerEmojiCell(context, false) {

                public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                    super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(82), MeasureSpec.EXACTLY));
                }
            };
            view = stickerEmojiCell;
            stickerEmojiCell.getImageView().setLayerNum(3);
            break;
        case 1:
            view = new EmptyCell(context);
            break;
        case 2:
            view = new StickerSetNameCell(context, false, true, resourcesProvider);
            break;
        case 3:
            view = new FeaturedStickerSetInfoCell(context, 17, true, true, resourcesProvider);
            ((FeaturedStickerSetInfoCell) view).setAddOnClickListener(v -> {
                final FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) v.getParent();
                TLRPC.StickerSetCovered pack = cell.getStickerSet();
                if (pack == null || installingStickerSets.indexOfKey(pack.set.id) >= 0 || removingStickerSets.indexOfKey(pack.set.id) >= 0) {
                    return;
                }
                if (cell.isInstalled()) {
                    removingStickerSets.put(pack.set.id, pack);
                    delegate.onStickerSetRemove(cell.getStickerSet());
                } else {
                    installStickerSet(pack, cell);
                }
            });
            break;
        case 4:
            view = new View(context);
            break;
        case 5:
            LinearLayout layout = new LinearLayout(context);
            layout.setOrientation(LinearLayout.VERTICAL);
            layout.setGravity(Gravity.CENTER);
            emptyImageView = new ImageView(context);
            emptyImageView.setScaleType(ImageView.ScaleType.CENTER);
            emptyImageView.setImageResource(R.drawable.stickers_empty);
            emptyImageView.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_emojiPanelEmptyText), PorterDuff.Mode.MULTIPLY));
            layout.addView(emptyImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
            layout.addView(new Space(context), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 15));
            emptyTextView = new TextView(context);
            emptyTextView.setText(LocaleController.getString("NoStickersFound", R.string.NoStickersFound));
            emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
            emptyTextView.setTextColor(getThemedColor(Theme.key_chat_emojiPanelEmptyText));
            layout.addView(emptyTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
            view = layout;
            view.setMinimumHeight(AndroidUtilities.dp(112));
            view.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
            break;
    }
    return new RecyclerListView.Holder(view);
}
Also used : Space(android.widget.Space) EmptyCell(org.telegram.ui.Cells.EmptyCell) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) StickerSetNameCell(org.telegram.ui.Cells.StickerSetNameCell) TLRPC(org.telegram.tgnet.TLRPC) FeaturedStickerSetInfoCell(org.telegram.ui.Cells.FeaturedStickerSetInfoCell) StickerEmojiCell(org.telegram.ui.Cells.StickerEmojiCell) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Aggregations

View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 TLRPC (org.telegram.tgnet.TLRPC)2 FeaturedStickerSetInfoCell (org.telegram.ui.Cells.FeaturedStickerSetInfoCell)2 SuppressLint (android.annotation.SuppressLint)1 Paint (android.graphics.Paint)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 LinearLayout (android.widget.LinearLayout)1 Space (android.widget.Space)1 EmptyCell (org.telegram.ui.Cells.EmptyCell)1 StickerEmojiCell (org.telegram.ui.Cells.StickerEmojiCell)1 StickerSetNameCell (org.telegram.ui.Cells.StickerSetNameCell)1 RecyclerListView (org.telegram.ui.Components.RecyclerListView)1