Java Code Examples for org.telegram.ui.Cells.FeaturedStickerSetInfoCell#setStickerSet()

The following examples show how to use org.telegram.ui.Cells.FeaturedStickerSetInfoCell#setStickerSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void updateVisibleTrendingSets() {
    if (trendingGridAdapter == null || trendingGridAdapter == null) {
        return;
    }
    try {
        int count = trendingGridView.getChildCount();
        for (int a = 0; a < count; a++) {
            View child = trendingGridView.getChildAt(a);
            if (child instanceof FeaturedStickerSetInfoCell) {
                RecyclerListView.Holder holder = (RecyclerListView.Holder) trendingGridView.getChildViewHolder(child);
                if (holder == null) {
                    continue;
                }
                FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) child;
                ArrayList<Long> unreadStickers = DataQuery.getInstance(currentAccount).getUnreadStickerSets();
                TLRPC.StickerSetCovered stickerSetCovered = cell.getStickerSet();
                boolean unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
                cell.setStickerSet(stickerSetCovered, unread);
                if (unread) {
                    DataQuery.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.setDrawProgress(installing || removing);
            }
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example 2
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TLRPC.Document sticker = (TLRPC.Document) cache.get(position);
            ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
            break;
        case 1:
            ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            break;
        case 2:
            ArrayList<Long> unreadStickers = DataQuery.getInstance(currentAccount).getUnreadStickerSets();
            TLRPC.StickerSetCovered stickerSetCovered = sets.get((Integer) cache.get(position));
            boolean unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
            FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) holder.itemView;
            cell.setStickerSet(stickerSetCovered, unread);
            if (unread) {
                DataQuery.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.setDrawProgress(installing || removing);
            break;
    }
}
 
Example 3
Source File: StickersAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (stickerSetCovereds != null) {
        switch (holder.getItemViewType()) {
            case 0:
                TLRPC.Document sticker = (TLRPC.Document) cache.get(position);
                ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
                break;
            case 1:
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
                break;
            case 2:
                TLRPC.StickerSetCovered stickerSetCovered = stickerSetCovereds.get((Integer) cache.get(position));
                FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) holder.itemView;
                cell.setStickerSet(stickerSetCovered, false);
                /*boolean installing = installingStickerSets.containsKey(stickerSetCovered.set.id);
                boolean removing = removingStickerSets.containsKey(stickerSetCovered.set.id);
                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.setDrawProgress(installing || removing);*/
                break;
        }
    } else {
        ((StickerEmojiCell) holder.itemView).setSticker(stickerSet.documents.get(position), showEmoji);
    }
}
 
Example 4
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void updateVisibleTrendingSets() {
    if (trendingGridAdapter == null || trendingGridAdapter == null) {
        return;
    }
    try {
        int count = trendingGridView.getChildCount();
        for (int a = 0; a < count; a++) {
            View child = trendingGridView.getChildAt(a);
            if (child instanceof FeaturedStickerSetInfoCell) {
                RecyclerListView.Holder holder = (RecyclerListView.Holder) trendingGridView.getChildViewHolder(child);
                if (holder == null) {
                    continue;
                }
                FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) child;
                ArrayList<Long> unreadStickers = DataQuery.getInstance(currentAccount).getUnreadStickerSets();
                TLRPC.StickerSetCovered stickerSetCovered = cell.getStickerSet();
                boolean unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
                cell.setStickerSet(stickerSetCovered, unread);
                if (unread) {
                    DataQuery.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.setDrawProgress(installing || removing);
            }
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example 5
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TLRPC.Document sticker = (TLRPC.Document) cache.get(position);
            ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
            break;
        case 1:
            ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            break;
        case 2:
            ArrayList<Long> unreadStickers = DataQuery.getInstance(currentAccount).getUnreadStickerSets();
            TLRPC.StickerSetCovered stickerSetCovered = sets.get((Integer) cache.get(position));
            boolean unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
            FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) holder.itemView;
            cell.setStickerSet(stickerSetCovered, unread);
            if (unread) {
                DataQuery.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.setDrawProgress(installing || removing);
            break;
    }
}
 
Example 6
Source File: StickersAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (stickerSetCovereds != null) {
        switch (holder.getItemViewType()) {
            case 0:
                TLRPC.Document sticker = (TLRPC.Document) cache.get(position);
                ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
                break;
            case 1:
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
                break;
            case 2:
                TLRPC.StickerSetCovered stickerSetCovered = stickerSetCovereds.get((Integer) cache.get(position));
                FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) holder.itemView;
                cell.setStickerSet(stickerSetCovered, false);
                /*boolean installing = installingStickerSets.containsKey(stickerSetCovered.set.id);
                boolean removing = removingStickerSets.containsKey(stickerSetCovered.set.id);
                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.setDrawProgress(installing || removing);*/
                break;
        }
    } else {
        ((StickerEmojiCell) holder.itemView).setSticker(stickerSet.documents.get(position), showEmoji);
    }
}
 
Example 7
Source File: StickersAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (stickerSetCovereds != null) {
        switch (holder.getItemViewType()) {
            case 0:
                TLRPC.Document sticker = (TLRPC.Document) cache.get(position);
                ((StickerEmojiCell) holder.itemView).setSticker(sticker, positionsToSets.get(position), false);
                break;
            case 1:
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
                break;
            case 2:
                TLRPC.StickerSetCovered stickerSetCovered = stickerSetCovereds.get((Integer) cache.get(position));
                FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) holder.itemView;
                cell.setStickerSet(stickerSetCovered, false);
                /*boolean installing = installingStickerSets.containsKey(stickerSetCovered.set.id);
                boolean removing = removingStickerSets.containsKey(stickerSetCovered.set.id);
                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.setDrawProgress(installing || removing);*/
                break;
        }
    } else {
        ((StickerEmojiCell) holder.itemView).setSticker(stickerSet.documents.get(position), stickerSet, showEmoji);
    }
}
 
Example 8
Source File: StickersAlert.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (stickerSetCovereds != null) {
        switch (holder.getItemViewType()) {
            case 0:
                TLRPC.Document sticker = (TLRPC.Document) cache.get(position);
                ((StickerEmojiCell) holder.itemView).setSticker(sticker, positionsToSets.get(position), false);
                break;
            case 1:
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
                break;
            case 2:
                TLRPC.StickerSetCovered stickerSetCovered = stickerSetCovereds.get((Integer) cache.get(position));
                FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) holder.itemView;
                cell.setStickerSet(stickerSetCovered, false);
                /*boolean installing = installingStickerSets.containsKey(stickerSetCovered.set.id);
                boolean removing = removingStickerSets.containsKey(stickerSetCovered.set.id);
                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.setDrawProgress(installing || removing);*/
                break;
        }
    } else {
        ((StickerEmojiCell) holder.itemView).setSticker(stickerSet.documents.get(position), stickerSet, showEmoji);
    }
}
 
Example 9
Source File: StickersSearchAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void bindFeaturedStickerSetInfoCell(FeaturedStickerSetInfoCell cell, int position, boolean animated) {
    final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
    ArrayList<Long> unreadStickers = mediaDataController.getUnreadStickerSets();
    TLRPC.StickerSetCovered stickerSetCovered = (TLRPC.StickerSetCovered) cache.get(position);
    boolean unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
    boolean forceInstalled = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] != null) {
            final TLRPC.TL_messages_stickerSet s = MediaDataController.getInstance(currentAccount).getStickerSetById(primaryInstallingStickerSets[i].set.id);
            if (s != null && !s.set.archived) {
                primaryInstallingStickerSets[i] = null;
                continue;
            }
            if (primaryInstallingStickerSets[i].set.id == stickerSetCovered.set.id) {
                forceInstalled = true;
                break;
            }
        }
    }

    int idx = TextUtils.isEmpty(searchQuery) ? -1 : AndroidUtilities.indexOfIgnoreCase(stickerSetCovered.set.title, searchQuery);
    if (idx >= 0) {
        cell.setStickerSet(stickerSetCovered, unread, animated, idx, searchQuery.length(), forceInstalled);
    } else {
        cell.setStickerSet(stickerSetCovered, unread, animated, 0, 0, forceInstalled);
        if (!TextUtils.isEmpty(searchQuery) && AndroidUtilities.indexOfIgnoreCase(stickerSetCovered.set.short_name, searchQuery) == 0) {
            cell.setUrl(stickerSetCovered.set.short_name, searchQuery.length());
        }
    }

    if (unread) {
        mediaDataController.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, animated);
    mediaDataController.preloadStickerSetThumb(stickerSetCovered);
    cell.setNeedDivider(position > 0);
}
 
Example 10
Source File: TrendingStickersLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void bindStickerSetCell(View view, int position, boolean animated) {
    final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
    boolean unread = false;
    final TLRPC.StickerSetCovered stickerSetCovered;
    if (position < totalItems) {
        stickerSetCovered = sets.get((Integer) cache.get(position));
        final ArrayList<Long> unreadStickers = mediaDataController.getUnreadStickerSets();
        unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
        if (unread) {
            mediaDataController.markFaturedStickersByIdAsRead(stickerSetCovered.set.id);
        }
    } else {
        stickerSetCovered = sets.get((Integer) cache.get(position));
    }
    mediaDataController.preloadStickerSetThumb(stickerSetCovered);
    boolean forceInstalled = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] != null) {
            final TLRPC.TL_messages_stickerSet s = MediaDataController.getInstance(currentAccount).getStickerSetById(primaryInstallingStickerSets[i].set.id);
            if (s != null && !s.set.archived) {
                primaryInstallingStickerSets[i] = null;
                continue;
            }
            if (primaryInstallingStickerSets[i].set.id == stickerSetCovered.set.id) {
                forceInstalled = true;
                break;
            }
        }
    }
    final boolean isSetInstalled = mediaDataController.isStickerPackInstalled(stickerSetCovered.set.id);
    boolean installing = installingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0;
    boolean removing = removingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0;
    if (installing && isSetInstalled) {
        installingStickerSets.remove(stickerSetCovered.set.id);
        installing = false;
    } else if (removing && !isSetInstalled) {
        removingStickerSets.remove(stickerSetCovered.set.id);
        removing = false;
    }
    final FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) view;
    cell.setStickerSet(stickerSetCovered, unread, animated, 0, 0, forceInstalled);
    cell.setAddDrawProgress(!forceInstalled && installing, animated);
    cell.setNeedDivider(position > 0 && (cache.get(position - 1) == null || !cache.get(position - 1).equals(ITEM_SECTION)));
}
 
Example 11
Source File: StickersSearchAdapter.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void bindFeaturedStickerSetInfoCell(FeaturedStickerSetInfoCell cell, int position, boolean animated) {
    final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
    ArrayList<Long> unreadStickers = mediaDataController.getUnreadStickerSets();
    TLRPC.StickerSetCovered stickerSetCovered = (TLRPC.StickerSetCovered) cache.get(position);
    boolean unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
    boolean forceInstalled = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] != null) {
            final TLRPC.TL_messages_stickerSet s = MediaDataController.getInstance(currentAccount).getStickerSetById(primaryInstallingStickerSets[i].set.id);
            if (s != null && !s.set.archived) {
                primaryInstallingStickerSets[i] = null;
                continue;
            }
            if (primaryInstallingStickerSets[i].set.id == stickerSetCovered.set.id) {
                forceInstalled = true;
                break;
            }
        }
    }

    int idx = TextUtils.isEmpty(searchQuery) ? -1 : AndroidUtilities.indexOfIgnoreCase(stickerSetCovered.set.title, searchQuery);
    if (idx >= 0) {
        cell.setStickerSet(stickerSetCovered, unread, animated, idx, searchQuery.length(), forceInstalled);
    } else {
        cell.setStickerSet(stickerSetCovered, unread, animated, 0, 0, forceInstalled);
        if (!TextUtils.isEmpty(searchQuery) && AndroidUtilities.indexOfIgnoreCase(stickerSetCovered.set.short_name, searchQuery) == 0) {
            cell.setUrl(stickerSetCovered.set.short_name, searchQuery.length());
        }
    }

    if (unread) {
        mediaDataController.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, animated);
    mediaDataController.preloadStickerSetThumb(stickerSetCovered);
    cell.setNeedDivider(position > 0);
}
 
Example 12
Source File: TrendingStickersLayout.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void bindStickerSetCell(View view, int position, boolean animated) {
    final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
    boolean unread = false;
    final TLRPC.StickerSetCovered stickerSetCovered;
    if (position < totalItems) {
        stickerSetCovered = sets.get((Integer) cache.get(position));
        final ArrayList<Long> unreadStickers = mediaDataController.getUnreadStickerSets();
        unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id);
        if (unread) {
            mediaDataController.markFaturedStickersByIdAsRead(stickerSetCovered.set.id);
        }
    } else {
        stickerSetCovered = sets.get((Integer) cache.get(position));
    }
    mediaDataController.preloadStickerSetThumb(stickerSetCovered);
    boolean forceInstalled = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] != null) {
            final TLRPC.TL_messages_stickerSet s = MediaDataController.getInstance(currentAccount).getStickerSetById(primaryInstallingStickerSets[i].set.id);
            if (s != null && !s.set.archived) {
                primaryInstallingStickerSets[i] = null;
                continue;
            }
            if (primaryInstallingStickerSets[i].set.id == stickerSetCovered.set.id) {
                forceInstalled = true;
                break;
            }
        }
    }
    final boolean isSetInstalled = mediaDataController.isStickerPackInstalled(stickerSetCovered.set.id);
    boolean installing = installingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0;
    boolean removing = removingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0;
    if (installing && isSetInstalled) {
        installingStickerSets.remove(stickerSetCovered.set.id);
        installing = false;
    } else if (removing && !isSetInstalled) {
        removingStickerSets.remove(stickerSetCovered.set.id);
        removing = false;
    }
    final FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) view;
    cell.setStickerSet(stickerSetCovered, unread, animated, 0, 0, forceInstalled);
    cell.setAddDrawProgress(!forceInstalled && installing, animated);
    cell.setNeedDivider(position > 0 && (cache.get(position - 1) == null || !cache.get(position - 1).equals(ITEM_SECTION)));
}