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

The following examples show how to use org.telegram.ui.Cells.FeaturedStickerSetInfoCell#setNeedDivider() . 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: 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 2
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 3
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 4
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)));
}