org.telegram.ui.Cells.StickerEmojiCell Java Examples

The following examples show how to use org.telegram.ui.Cells.StickerEmojiCell. 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: StickerPreviewViewer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void reset() {
    if (openStickerPreviewRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(openStickerPreviewRunnable);
        openStickerPreviewRunnable = null;
    }
    if (currentStickerPreviewCell != null) {
        if (currentStickerPreviewCell instanceof StickerEmojiCell) {
            ((StickerEmojiCell) currentStickerPreviewCell).setScaled(false);
        } else if (currentStickerPreviewCell instanceof StickerCell) {
            ((StickerCell) currentStickerPreviewCell).setScaled(false);
        } else if (currentStickerPreviewCell instanceof ContextLinkCell) {
            ((ContextLinkCell) currentStickerPreviewCell).setScaled(false);
        }
        currentStickerPreviewCell = null;
    }
}
 
Example #2
Source File: StickerMasksAlert.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.stickersDidLoad) {
        if ((Integer) args[0] == currentType) {
            updateStickerTabs();
            reloadStickersAdapter();
            checkPanels();
        }
    } else if (id == NotificationCenter.recentDocumentsDidLoad) {
        boolean isGif = (Boolean) args[0];
        int type = (Integer) args[1];
        if (!isGif && (type == currentType || type == MediaDataController.TYPE_FAVE)) {
            checkDocuments(false);
        }
    } else if (id == NotificationCenter.emojiDidLoad) {
        if (gridView != null) {
            int count = gridView.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = gridView.getChildAt(a);
                if (child instanceof StickerSetNameCell || child instanceof StickerEmojiCell) {
                    child.invalidate();
                }
            }
        }
    }
}
 
Example #3
Source File: TrendingStickersLayout.java    From Telegram with GNU General Public License v2.0 6 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, positionsToSets.get(position), false);
            break;
        case 1:
            ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            break;
        case 2:
        case 5:
            bindStickerSetCell(holder.itemView, position, false);
            break;
        case 4:
            ((GraySectionCell) holder.itemView).setText(LocaleController.getString("OtherStickers", R.string.OtherStickers));
            break;
    }
}
 
Example #4
Source File: StickerMasksView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TLRPC.Document sticker = cache.get(position);
            ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
            break;
        case 1:
            if (position == totalItems) {
                int row = (position - 1) / stickersPerRow;
                TLRPC.TL_messages_stickerSet pack = rowStartPack.get(row);
                if (pack == null) {
                    ((EmptyCell) holder.itemView).setHeight(1);
                } else {
                    int height = stickersGridView.getMeasuredHeight() - (int) Math.ceil(pack.documents.size() / (float) stickersPerRow) * AndroidUtilities.dp(82);
                    ((EmptyCell) holder.itemView).setHeight(height > 0 ? height : 1);
                }
            } else {
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            }
            break;
    }
}
 
Example #5
Source File: StickerPreviewViewer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void reset() {
    if (openStickerPreviewRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(openStickerPreviewRunnable);
        openStickerPreviewRunnable = null;
    }
    if (currentStickerPreviewCell != null) {
        if (currentStickerPreviewCell instanceof StickerEmojiCell) {
            ((StickerEmojiCell) currentStickerPreviewCell).setScaled(false);
        } else if (currentStickerPreviewCell instanceof StickerCell) {
            ((StickerCell) currentStickerPreviewCell).setScaled(false);
        } else if (currentStickerPreviewCell instanceof ContextLinkCell) {
            ((ContextLinkCell) currentStickerPreviewCell).setScaled(false);
        }
        currentStickerPreviewCell = null;
    }
}
 
Example #6
Source File: ContentPreviewViewer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void reset() {
    if (openPreviewRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(openPreviewRunnable);
        openPreviewRunnable = null;
    }
    if (currentPreviewCell != null) {
        if (currentPreviewCell instanceof StickerEmojiCell) {
            ((StickerEmojiCell) currentPreviewCell).setScaled(false);
        } else if (currentPreviewCell instanceof StickerCell) {
            ((StickerCell) currentPreviewCell).setScaled(false);
        } else if (currentPreviewCell instanceof ContextLinkCell) {
            ((ContextLinkCell) currentPreviewCell).setScaled(false);
        }
        currentPreviewCell = null;
    }
}
 
Example #7
Source File: StickerMasksAlert.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.stickersDidLoad) {
        if ((Integer) args[0] == currentType) {
            updateStickerTabs();
            reloadStickersAdapter();
            checkPanels();
        }
    } else if (id == NotificationCenter.recentDocumentsDidLoad) {
        boolean isGif = (Boolean) args[0];
        int type = (Integer) args[1];
        if (!isGif && (type == currentType || type == MediaDataController.TYPE_FAVE)) {
            checkDocuments(false);
        }
    } else if (id == NotificationCenter.emojiDidLoad) {
        if (gridView != null) {
            int count = gridView.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = gridView.getChildAt(a);
                if (child instanceof StickerSetNameCell || child instanceof StickerEmojiCell) {
                    child.invalidate();
                }
            }
        }
    }
}
 
Example #8
Source File: StickerMasksView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TLRPC.Document sticker = cache.get(position);
            ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
            break;
        case 1:
            if (position == totalItems) {
                int row = (position - 1) / stickersPerRow;
                TLRPC.TL_messages_stickerSet pack = rowStartPack.get(row);
                if (pack == null) {
                    ((EmptyCell) holder.itemView).setHeight(1);
                } else {
                    int height = stickersGridView.getMeasuredHeight() - (int) Math.ceil(pack.documents.size() / (float) stickersPerRow) * AndroidUtilities.dp(82);
                    ((EmptyCell) holder.itemView).setHeight(height > 0 ? height : 1);
                }
            } else {
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            }
            break;
    }
}
 
Example #9
Source File: ContentPreviewViewer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void reset() {
    if (openPreviewRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(openPreviewRunnable);
        openPreviewRunnable = null;
    }
    if (currentPreviewCell != null) {
        if (currentPreviewCell instanceof StickerEmojiCell) {
            ((StickerEmojiCell) currentPreviewCell).setScaled(false);
        } else if (currentPreviewCell instanceof StickerCell) {
            ((StickerCell) currentPreviewCell).setScaled(false);
        } else if (currentPreviewCell instanceof ContextLinkCell) {
            ((ContextLinkCell) currentPreviewCell).setScaled(false);
        }
        currentPreviewCell = null;
    }
}
 
Example #10
Source File: TrendingStickersLayout.java    From Telegram-FOSS with GNU General Public License v2.0 6 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, positionsToSets.get(position), false);
            break;
        case 1:
            ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            break;
        case 2:
        case 5:
            bindStickerSetCell(holder.itemView, position, false);
            break;
        case 4:
            ((GraySectionCell) holder.itemView).setText(LocaleController.getString("OtherStickers", R.string.OtherStickers));
            break;
    }
}
 
Example #11
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 #12
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 #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: 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 #15
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 #16
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 #17
Source File: ContentPreviewViewer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public boolean onInterceptTouchEvent(MotionEvent event, final RecyclerListView listView, final int height, ContentPreviewViewerDelegate contentPreviewViewerDelegate) {
    delegate = contentPreviewViewerDelegate;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        int x = (int) event.getX();
        int y = (int) event.getY();
        int count = listView.getChildCount();
        for (int a = 0; a < count; a++) {
            View view = null;
            if (listView instanceof RecyclerListView) {
                view = listView.getChildAt(a);
            }
            if (view == null) {
                return false;
            }
            int top = view.getTop();
            int bottom = view.getBottom();
            int left = view.getLeft();
            int right = view.getRight();
            if (top > y || bottom < y || left > x || right < x) {
                continue;
            }
            int contentType = CONTENT_TYPE_NONE;
            if (view instanceof StickerEmojiCell) {
                if (((StickerEmojiCell) view).showingBitmap()) {
                    contentType = CONTENT_TYPE_STICKER;
                    centerImage.setRoundRadius(0);
                }
            } else if (view instanceof StickerCell) {
                if (((StickerCell) view).showingBitmap()) {
                    contentType = CONTENT_TYPE_STICKER;
                    centerImage.setRoundRadius(0);
                }
            } else if (view instanceof ContextLinkCell) {
                ContextLinkCell cell = (ContextLinkCell) view;
                if (cell.showingBitmap()) {
                    if (cell.isSticker()) {
                        contentType = CONTENT_TYPE_STICKER;
                        centerImage.setRoundRadius(0);
                    } else if (cell.isGif()) {
                        contentType = CONTENT_TYPE_GIF;
                        centerImage.setRoundRadius(AndroidUtilities.dp(6));
                    }
                }
            }
            if (contentType == CONTENT_TYPE_NONE) {
                return false;
            }
            startX = x;
            startY = y;
            currentPreviewCell = view;
            int contentTypeFinal = contentType;
            openPreviewRunnable = () -> {
                if (openPreviewRunnable == null) {
                    return;
                }
                listView.setOnItemClickListener((RecyclerListView.OnItemClickListener) null);
                listView.requestDisallowInterceptTouchEvent(true);
                openPreviewRunnable = null;
                setParentActivity((Activity) listView.getContext());
                setKeyboardHeight(height);
                clearsInputField = false;
                if (currentPreviewCell instanceof StickerEmojiCell) {
                    StickerEmojiCell stickerEmojiCell = (StickerEmojiCell) currentPreviewCell;
                    open(stickerEmojiCell.getSticker(), null, contentTypeFinal, stickerEmojiCell.isRecent(), stickerEmojiCell.getParentObject());
                    stickerEmojiCell.setScaled(true);
                } else if (currentPreviewCell instanceof StickerCell) {
                    StickerCell stickerCell = (StickerCell) currentPreviewCell;
                    open(stickerCell.getSticker(), null, contentTypeFinal, false, stickerCell.getParentObject());
                    stickerCell.setScaled(true);
                    clearsInputField = stickerCell.isClearsInputField();
                } else if (currentPreviewCell instanceof ContextLinkCell) {
                    ContextLinkCell contextLinkCell = (ContextLinkCell) currentPreviewCell;
                    open(contextLinkCell.getDocument(), contextLinkCell.getBotInlineResult(), contentTypeFinal, false, contextLinkCell.getInlineBot());
                    if (contentTypeFinal != CONTENT_TYPE_GIF) {
                        contextLinkCell.setScaled(true);
                    }
                }
            };
            AndroidUtilities.runOnUIThread(openPreviewRunnable, 200);
            return true;
        }
    }
    return false;
}
 
Example #18
Source File: StickerPreviewViewer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean onInterceptTouchEvent(MotionEvent event, final View listView, final int height, StickerPreviewViewerDelegate stickerPreviewViewerDelegate) {
    delegate = stickerPreviewViewerDelegate;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        int x = (int) event.getX();
        int y = (int) event.getY();
        int count = 0;
        if (listView instanceof AbsListView) {
            count = ((AbsListView) listView).getChildCount();
        } else if (listView instanceof RecyclerListView) {
            count = ((RecyclerListView) listView).getChildCount();
        }
        for (int a = 0; a < count; a++) {
            View view = null;
            if (listView instanceof AbsListView) {
                view = ((AbsListView) listView).getChildAt(a);
            } else if (listView instanceof RecyclerListView) {
                view = ((RecyclerListView) listView).getChildAt(a);
            }
            if (view == null) {
                return false;
            }
            int top = view.getTop();
            int bottom = view.getBottom();
            int left = view.getLeft();
            int right = view.getRight();
            if (top > y || bottom < y || left > x || right < x) {
                continue;
            }
            boolean ok = false;
            if (view instanceof StickerEmojiCell) {
                ok = ((StickerEmojiCell) view).showingBitmap();
            } else if (view instanceof StickerCell) {
                ok = ((StickerCell) view).showingBitmap();
            } else if (view instanceof ContextLinkCell) {
                ContextLinkCell cell = (ContextLinkCell) view;
                ok = cell.isSticker() && cell.showingBitmap();
            }
            if (!ok) {
                return false;
            }
            startX = x;
            startY = y;
            currentStickerPreviewCell = view;
            openStickerPreviewRunnable = new Runnable() {
                @Override
                public void run() {
                    if (openStickerPreviewRunnable == null) {
                        return;
                    }
                    if (listView instanceof AbsListView) {
                        ((AbsListView) listView).setOnItemClickListener(null);
                        ((AbsListView) listView).requestDisallowInterceptTouchEvent(true);
                    } else if (listView instanceof RecyclerListView) {
                        ((RecyclerListView) listView).setOnItemClickListener((RecyclerListView.OnItemClickListener) null);
                        ((RecyclerListView) listView).requestDisallowInterceptTouchEvent(true);
                    }
                    openStickerPreviewRunnable = null;
                    setParentActivity((Activity) listView.getContext());
                    setKeyboardHeight(height);
                    if (currentStickerPreviewCell instanceof StickerEmojiCell) {
                        open(((StickerEmojiCell) currentStickerPreviewCell).getSticker(), ((StickerEmojiCell) currentStickerPreviewCell).isRecent());
                        ((StickerEmojiCell) currentStickerPreviewCell).setScaled(true);
                    } else if (currentStickerPreviewCell instanceof StickerCell) {
                        open(((StickerCell) currentStickerPreviewCell).getSticker(), false);
                        ((StickerCell) currentStickerPreviewCell).setScaled(true);
                    } else if (currentStickerPreviewCell instanceof ContextLinkCell) {
                        open(((ContextLinkCell) currentStickerPreviewCell).getDocument(), false);
                        ((ContextLinkCell) currentStickerPreviewCell).setScaled(true);
                    }
                }
            };
            AndroidUtilities.runOnUIThread(openStickerPreviewRunnable, 200);
            return true;
        }
    }
    return false;
}
 
Example #19
Source File: ContentPreviewViewer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public boolean onInterceptTouchEvent(MotionEvent event, final RecyclerListView listView, final int height, ContentPreviewViewerDelegate contentPreviewViewerDelegate) {
    delegate = contentPreviewViewerDelegate;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        int x = (int) event.getX();
        int y = (int) event.getY();
        int count = listView.getChildCount();
        for (int a = 0; a < count; a++) {
            View view = null;
            if (listView instanceof RecyclerListView) {
                view = listView.getChildAt(a);
            }
            if (view == null) {
                return false;
            }
            int top = view.getTop();
            int bottom = view.getBottom();
            int left = view.getLeft();
            int right = view.getRight();
            if (top > y || bottom < y || left > x || right < x) {
                continue;
            }
            int contentType = CONTENT_TYPE_NONE;
            if (view instanceof StickerEmojiCell) {
                if (((StickerEmojiCell) view).showingBitmap()) {
                    contentType = CONTENT_TYPE_STICKER;
                    centerImage.setRoundRadius(0);
                }
            } else if (view instanceof StickerCell) {
                if (((StickerCell) view).showingBitmap()) {
                    contentType = CONTENT_TYPE_STICKER;
                    centerImage.setRoundRadius(0);
                }
            } else if (view instanceof ContextLinkCell) {
                ContextLinkCell cell = (ContextLinkCell) view;
                if (cell.showingBitmap()) {
                    if (cell.isSticker()) {
                        contentType = CONTENT_TYPE_STICKER;
                        centerImage.setRoundRadius(0);
                    } else if (cell.isGif()) {
                        contentType = CONTENT_TYPE_GIF;
                        centerImage.setRoundRadius(AndroidUtilities.dp(6));
                    }
                }
            }
            if (contentType == CONTENT_TYPE_NONE) {
                return false;
            }
            startX = x;
            startY = y;
            currentPreviewCell = view;
            int contentTypeFinal = contentType;
            openPreviewRunnable = () -> {
                if (openPreviewRunnable == null) {
                    return;
                }
                listView.setOnItemClickListener((RecyclerListView.OnItemClickListener) null);
                listView.requestDisallowInterceptTouchEvent(true);
                openPreviewRunnable = null;
                setParentActivity((Activity) listView.getContext());
                setKeyboardHeight(height);
                clearsInputField = false;
                if (currentPreviewCell instanceof StickerEmojiCell) {
                    StickerEmojiCell stickerEmojiCell = (StickerEmojiCell) currentPreviewCell;
                    open(stickerEmojiCell.getSticker(), null, contentTypeFinal, stickerEmojiCell.isRecent(), stickerEmojiCell.getParentObject());
                    stickerEmojiCell.setScaled(true);
                } else if (currentPreviewCell instanceof StickerCell) {
                    StickerCell stickerCell = (StickerCell) currentPreviewCell;
                    open(stickerCell.getSticker(), null, contentTypeFinal, false, stickerCell.getParentObject());
                    stickerCell.setScaled(true);
                    clearsInputField = stickerCell.isClearsInputField();
                } else if (currentPreviewCell instanceof ContextLinkCell) {
                    ContextLinkCell contextLinkCell = (ContextLinkCell) currentPreviewCell;
                    open(contextLinkCell.getDocument(), contextLinkCell.getBotInlineResult(), contentTypeFinal, false, contextLinkCell.getInlineBot());
                    if (contentTypeFinal != CONTENT_TYPE_GIF) {
                        contextLinkCell.setScaled(true);
                    }
                }
            };
            AndroidUtilities.runOnUIThread(openPreviewRunnable, 200);
            return true;
        }
    }
    return false;
}
 
Example #20
Source File: StickerPreviewViewer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean onInterceptTouchEvent(MotionEvent event, final View listView, final int height, StickerPreviewViewerDelegate stickerPreviewViewerDelegate) {
    delegate = stickerPreviewViewerDelegate;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        int x = (int) event.getX();
        int y = (int) event.getY();
        int count = 0;
        if (listView instanceof AbsListView) {
            count = ((AbsListView) listView).getChildCount();
        } else if (listView instanceof RecyclerListView) {
            count = ((RecyclerListView) listView).getChildCount();
        }
        for (int a = 0; a < count; a++) {
            View view = null;
            if (listView instanceof AbsListView) {
                view = ((AbsListView) listView).getChildAt(a);
            } else if (listView instanceof RecyclerListView) {
                view = ((RecyclerListView) listView).getChildAt(a);
            }
            if (view == null) {
                return false;
            }
            int top = view.getTop();
            int bottom = view.getBottom();
            int left = view.getLeft();
            int right = view.getRight();
            if (top > y || bottom < y || left > x || right < x) {
                continue;
            }
            boolean ok = false;
            if (view instanceof StickerEmojiCell) {
                ok = ((StickerEmojiCell) view).showingBitmap();
            } else if (view instanceof StickerCell) {
                ok = ((StickerCell) view).showingBitmap();
            } else if (view instanceof ContextLinkCell) {
                ContextLinkCell cell = (ContextLinkCell) view;
                ok = cell.isSticker() && cell.showingBitmap();
            }
            if (!ok) {
                return false;
            }
            startX = x;
            startY = y;
            currentStickerPreviewCell = view;
            openStickerPreviewRunnable = new Runnable() {
                @Override
                public void run() {
                    if (openStickerPreviewRunnable == null) {
                        return;
                    }
                    if (listView instanceof AbsListView) {
                        ((AbsListView) listView).setOnItemClickListener(null);
                        ((AbsListView) listView).requestDisallowInterceptTouchEvent(true);
                    } else if (listView instanceof RecyclerListView) {
                        ((RecyclerListView) listView).setOnItemClickListener((RecyclerListView.OnItemClickListener) null);
                        ((RecyclerListView) listView).requestDisallowInterceptTouchEvent(true);
                    }
                    openStickerPreviewRunnable = null;
                    setParentActivity((Activity) listView.getContext());
                    setKeyboardHeight(height);
                    if (currentStickerPreviewCell instanceof StickerEmojiCell) {
                        open(((StickerEmojiCell) currentStickerPreviewCell).getSticker(), ((StickerEmojiCell) currentStickerPreviewCell).isRecent());
                        ((StickerEmojiCell) currentStickerPreviewCell).setScaled(true);
                    } else if (currentStickerPreviewCell instanceof StickerCell) {
                        open(((StickerCell) currentStickerPreviewCell).getSticker(), false);
                        ((StickerCell) currentStickerPreviewCell).setScaled(true);
                    } else if (currentStickerPreviewCell instanceof ContextLinkCell) {
                        open(((ContextLinkCell) currentStickerPreviewCell).getDocument(), false);
                        ((ContextLinkCell) currentStickerPreviewCell).setScaled(true);
                    }
                }
            };
            AndroidUtilities.runOnUIThread(openStickerPreviewRunnable, 200);
            return true;
        }
    }
    return false;
}