org.telegram.ui.Cells.FeaturedStickerSetInfoCell Java Examples

The following examples show how to use org.telegram.ui.Cells.FeaturedStickerSetInfoCell. 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
@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 #2
Source File: StickersAlert.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors() {
    if (stickerSetCovereds != null) {
        for (int i = 0, size = gridView.getChildCount(); i < size; i++) {
            final View child = gridView.getChildAt(i);
            if (child instanceof FeaturedStickerSetInfoCell) {
                ((FeaturedStickerSetInfoCell) child).updateColors();
            }
        }
    }
}
 
Example #3
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 #4
Source File: TrendingStickersLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors(RecyclerListView listView) {
    for (int i = 0, size = listView.getChildCount(); i < size; i++) {
        final View child = listView.getChildAt(i);
        if (child instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) child).updateColors();
        } else if (child instanceof FeaturedStickerSetCell2) {
            ((FeaturedStickerSetCell2) child).updateColors();
        }
    }
}
 
Example #5
Source File: StickersSearchAdapter.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors(RecyclerListView listView) {
    for (int i = 0, size = listView.getChildCount(); i < size; i++) {
        final View child = listView.getChildAt(i);
        if (child instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) child).updateColors();
        } else if (child instanceof StickerSetNameCell) {
            ((StickerSetNameCell) child).updateColors();
        }
    }
}
 
Example #6
Source File: StickersSearchAdapter.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void installStickerSet(TLRPC.StickerSetCovered pack, FeaturedStickerSetInfoCell cell) {
    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;
                break;
            }
            if (primaryInstallingStickerSets[i].set.id == pack.set.id) {
                return;
            }
        }
    }

    boolean primary = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] == null) {
            primaryInstallingStickerSets[i] = pack;
            primary = true;
            break;
        }
    }
    if (!primary && cell != null) {
        cell.setAddDrawProgress(true, true);
    }
    installingStickerSets.put(pack.set.id, pack);
    if (cell != null) {
        delegate.onStickerSetAdd(cell.getStickerSet(), primary);
    } else {
        for (int i = 0, size = positionsToSets.size(); i < size; i++) {
            final TLRPC.StickerSetCovered item = positionsToSets.get(i);
            if (item != null && item.set.id == pack.set.id) {
                notifyItemChanged(i, PAYLOAD_ANIMATED);
                break;
            }
        }
    }
}
 
Example #7
Source File: StickersSearchAdapter.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
    if (payloads.contains(PAYLOAD_ANIMATED)) {
        if (holder.getItemViewType() == 3) {
            bindFeaturedStickerSetInfoCell((FeaturedStickerSetInfoCell) holder.itemView, position, true);
        }
    } else {
        super.onBindViewHolder(holder, position, payloads);
    }
}
 
Example #8
Source File: StickersAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors() {
    if (stickerSetCovereds != null) {
        for (int i = 0, size = gridView.getChildCount(); i < size; i++) {
            final View child = gridView.getChildAt(i);
            if (child instanceof FeaturedStickerSetInfoCell) {
                ((FeaturedStickerSetInfoCell) child).updateColors();
            }
        }
    }
}
 
Example #9
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 #10
Source File: TrendingStickersLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors(RecyclerListView listView) {
    for (int i = 0, size = listView.getChildCount(); i < size; i++) {
        final View child = listView.getChildAt(i);
        if (child instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) child).updateColors();
        } else if (child instanceof FeaturedStickerSetCell2) {
            ((FeaturedStickerSetCell2) child).updateColors();
        }
    }
}
 
Example #11
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 #12
Source File: StickersSearchAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors(RecyclerListView listView) {
    for (int i = 0, size = listView.getChildCount(); i < size; i++) {
        final View child = listView.getChildAt(i);
        if (child instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) child).updateColors();
        } else if (child instanceof StickerSetNameCell) {
            ((StickerSetNameCell) child).updateColors();
        }
    }
}
 
Example #13
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 #14
Source File: StickersSearchAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void installStickerSet(TLRPC.StickerSetCovered pack, FeaturedStickerSetInfoCell cell) {
    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;
                break;
            }
            if (primaryInstallingStickerSets[i].set.id == pack.set.id) {
                return;
            }
        }
    }

    boolean primary = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] == null) {
            primaryInstallingStickerSets[i] = pack;
            primary = true;
            break;
        }
    }
    if (!primary && cell != null) {
        cell.setAddDrawProgress(true, true);
    }
    installingStickerSets.put(pack.set.id, pack);
    if (cell != null) {
        delegate.onStickerSetAdd(cell.getStickerSet(), primary);
    } else {
        for (int i = 0, size = positionsToSets.size(); i < size; i++) {
            final TLRPC.StickerSetCovered item = positionsToSets.get(i);
            if (item != null && item.set.id == pack.set.id) {
                notifyItemChanged(i, PAYLOAD_ANIMATED);
                break;
            }
        }
    }
}
 
Example #15
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 #16
Source File: StickersSearchAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
    if (payloads.contains(PAYLOAD_ANIMATED)) {
        if (holder.getItemViewType() == 3) {
            bindFeaturedStickerSetInfoCell((FeaturedStickerSetInfoCell) holder.itemView, position, true);
        }
    } else {
        super.onBindViewHolder(holder, position, payloads);
    }
}
 
Example #17
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 #18
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 #19
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 #20
Source File: StickersAlert.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void getThemeDescriptions(List<ThemeDescription> descriptions, ThemeDescription.ThemeDescriptionDelegate delegate) {
    if (stickerSetCovereds != null) {
        FeaturedStickerSetInfoCell.createThemeDescriptions(descriptions, gridView, delegate);
    }
}
 
Example #21
Source File: TrendingStickersLayout.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void getThemeDescriptions(List<ThemeDescription> descriptions, RecyclerListView listView, ThemeDescription.ThemeDescriptionDelegate delegate) {
    FeaturedStickerSetInfoCell.createThemeDescriptions(descriptions, listView, delegate);
    FeaturedStickerSetCell2.createThemeDescriptions(descriptions, listView, delegate);
    GraySectionCell.createThemeDescriptions(descriptions, listView);
}
 
Example #22
Source File: TrendingStickersLayout.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void installStickerSet(TLRPC.StickerSetCovered pack, View view) {
    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;
                break;
            }
            if (primaryInstallingStickerSets[i].set.id == pack.set.id) {
                return;
            }
        }
    }

    boolean primary = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] == null) {
            primaryInstallingStickerSets[i] = pack;
            primary = true;
            break;
        }
    }
    if (!primary && view != null) {
        if (view instanceof FeaturedStickerSetCell2) {
            ((FeaturedStickerSetCell2) view).setDrawProgress(true, true);
        } else if (view instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) view).setAddDrawProgress(true, true);
        }
    }
    installingStickerSets.put(pack.set.id, pack);
    if (view != null) {
        delegate.onStickerSetAdd(pack, primary);
    } else {
        for (int i = 0, size = positionsToSets.size(); i < size; i++) {
            final TLRPC.StickerSetCovered item = positionsToSets.get(i);
            if (item != null && item.set.id == pack.set.id) {
                notifyItemChanged(i, PAYLOAD_ANIMATED);
                break;
            }
        }
    }
}
 
Example #23
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)));
}
 
Example #24
Source File: StickersSearchAdapter.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void getThemeDescriptions(List<ThemeDescription> descriptions, RecyclerListView listView, ThemeDescription.ThemeDescriptionDelegate delegate) {
    FeaturedStickerSetInfoCell.createThemeDescriptions(descriptions, listView, delegate);
    StickerSetNameCell.createThemeDescriptions(descriptions, listView, delegate);
    descriptions.add(new ThemeDescription(emptyImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_emojiPanelEmptyText));
    descriptions.add(new ThemeDescription(emptyTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_emojiPanelEmptyText));
}
 
Example #25
Source File: StickersSearchAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void getThemeDescriptions(List<ThemeDescription> descriptions, RecyclerListView listView, ThemeDescription.ThemeDescriptionDelegate delegate) {
    FeaturedStickerSetInfoCell.createThemeDescriptions(descriptions, listView, delegate);
    StickerSetNameCell.createThemeDescriptions(descriptions, listView, delegate);
    descriptions.add(new ThemeDescription(emptyImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_emojiPanelEmptyText));
    descriptions.add(new ThemeDescription(emptyTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_emojiPanelEmptyText));
}
 
Example #26
Source File: StickersAlert.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void getThemeDescriptions(List<ThemeDescription> descriptions, ThemeDescription.ThemeDescriptionDelegate delegate) {
    if (stickerSetCovereds != null) {
        FeaturedStickerSetInfoCell.createThemeDescriptions(descriptions, gridView, delegate);
    }
}
 
Example #27
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 #28
Source File: TrendingStickersLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void getThemeDescriptions(List<ThemeDescription> descriptions, RecyclerListView listView, ThemeDescription.ThemeDescriptionDelegate delegate) {
    FeaturedStickerSetInfoCell.createThemeDescriptions(descriptions, listView, delegate);
    FeaturedStickerSetCell2.createThemeDescriptions(descriptions, listView, delegate);
    GraySectionCell.createThemeDescriptions(descriptions, listView);
}
 
Example #29
Source File: TrendingStickersLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void installStickerSet(TLRPC.StickerSetCovered pack, View view) {
    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;
                break;
            }
            if (primaryInstallingStickerSets[i].set.id == pack.set.id) {
                return;
            }
        }
    }

    boolean primary = false;
    for (int i = 0; i < primaryInstallingStickerSets.length; i++) {
        if (primaryInstallingStickerSets[i] == null) {
            primaryInstallingStickerSets[i] = pack;
            primary = true;
            break;
        }
    }
    if (!primary && view != null) {
        if (view instanceof FeaturedStickerSetCell2) {
            ((FeaturedStickerSetCell2) view).setDrawProgress(true, true);
        } else if (view instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) view).setAddDrawProgress(true, true);
        }
    }
    installingStickerSets.put(pack.set.id, pack);
    if (view != null) {
        delegate.onStickerSetAdd(pack, primary);
    } else {
        for (int i = 0, size = positionsToSets.size(); i < size; i++) {
            final TLRPC.StickerSetCovered item = positionsToSets.get(i);
            if (item != null && item.set.id == pack.set.id) {
                notifyItemChanged(i, PAYLOAD_ANIMATED);
                break;
            }
        }
    }
}
 
Example #30
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)));
}