Java Code Examples for org.telegram.ui.Components.RecyclerListView#getChildCount()

The following examples show how to use org.telegram.ui.Components.RecyclerListView#getChildCount() . 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 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 2
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 3
Source File: DialogsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void updateVisibleRows(int mask)
{
    if (listView == null)
        return;

    int count = listView.getChildCount();
    for (int a = 0; a < count; a++)
    {
        View child = listView.getChildAt(a);
        if (child instanceof DialogCell)
        {
            if (listView.getAdapter() != dialogsSearchAdapter)
            {
                DialogCell cell = (DialogCell) child;
                if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0)
                {
                    cell.checkCurrentDialogIndex();
                    if (dialogsType == MessagesController.DialogType.All && AndroidUtilities.isTablet())
                    {
                        cell.setDialogSelected(cell.getDialogId() == openedDialogId);
                    }
                }
                else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0)
                {
                    if (dialogsType == MessagesController.DialogType.All && AndroidUtilities.isTablet())
                    {
                        cell.setDialogSelected(cell.getDialogId() == openedDialogId);
                    }
                }
                else
                {
                    cell.update(mask);
                }
            }
        }
        else if (child instanceof UserCell)
        {
            ((UserCell) child).update(mask);
        }
        else if (child instanceof ProfileSearchCell)
        {
            ((ProfileSearchCell) child).update(mask);
        }
        else if (child instanceof RecyclerListView)
        {
            RecyclerListView innerListView = (RecyclerListView) child;
            int count2 = innerListView.getChildCount();
            for (int b = 0; b < count2; b++)
            {
                View child2 = innerListView.getChildAt(b);
                if (child2 instanceof HintDialogCell)
                {
                    ((HintDialogCell) child2).checkUnreadCounter(mask);
                }
            }
        }
    }

    if (updateTabCounters)
    {
        updateTabsUnreadCount();
        updateTabCounters = false;
    }
}
 
Example 4
Source File: DialogsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void updateVisibleRows(int mask)
{
    if (listView == null)
        return;

    int count = listView.getChildCount();
    for (int a = 0; a < count; a++)
    {
        View child = listView.getChildAt(a);
        if (child instanceof DialogCell)
        {
            if (listView.getAdapter() != dialogsSearchAdapter)
            {
                DialogCell cell = (DialogCell) child;
                if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0)
                {
                    cell.checkCurrentDialogIndex();
                    if (dialogsType == MessagesController.DialogType.All && AndroidUtilities.isTablet())
                    {
                        cell.setDialogSelected(cell.getDialogId() == openedDialogId);
                    }
                }
                else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0)
                {
                    if (dialogsType == MessagesController.DialogType.All && AndroidUtilities.isTablet())
                    {
                        cell.setDialogSelected(cell.getDialogId() == openedDialogId);
                    }
                }
                else
                {
                    cell.update(mask);
                }
            }
        }
        else if (child instanceof UserCell)
        {
            ((UserCell) child).update(mask);
        }
        else if (child instanceof ProfileSearchCell)
        {
            ((ProfileSearchCell) child).update(mask);
        }
        else if (child instanceof RecyclerListView)
        {
            RecyclerListView innerListView = (RecyclerListView) child;
            int count2 = innerListView.getChildCount();
            for (int b = 0; b < count2; b++)
            {
                View child2 = innerListView.getChildAt(b);
                if (child2 instanceof HintDialogCell)
                {
                    ((HintDialogCell) child2).checkUnreadCounter(mask);
                }
            }
        }
    }

    if (updateTabCounters)
    {
        updateTabsUnreadCount();
        updateTabCounters = false;
    }
}
 
Example 5
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 6
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;
}