Search in sources :

Example 1 with SectionHeaderViewHolder

use of org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder in project AndroidChromium by JackyAndroid.

the class NewTabPageRecyclerView method findFirstHeader.

/**
     * Finds the view holder for the first header.
     * @return The {@code ViewHolder} of the header, or null if it is not present.
     */
private SectionHeaderViewHolder findFirstHeader() {
    int firstHeaderPosition = getNewTabPageAdapter().getFirstHeaderPosition();
    if (firstHeaderPosition == RecyclerView.NO_POSITION)
        return null;
    ViewHolder viewHolder = findViewHolderForAdapterPosition(firstHeaderPosition);
    if (!(viewHolder instanceof SectionHeaderViewHolder))
        return null;
    return (SectionHeaderViewHolder) viewHolder;
}
Also used : SectionHeaderViewHolder(org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder) SectionHeaderViewHolder(org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder)

Example 2 with SectionHeaderViewHolder

use of org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder in project AndroidChromium by JackyAndroid.

the class NewTabPageRecyclerView method updatePeekingCard.

/**
     * Updates the peeking state of the provided card. Relies on the dimensions of the header to
     * be correct, prefer {@link #updatePeekingCardAndHeader} that updates both together.
     */
public void updatePeekingCard(CardViewHolder peekingCard) {
    SectionHeaderViewHolder header = findFirstHeader();
    if (header == null) {
        // No header, we must have scrolled quite far. Fallback to a non animated (full bleed)
        // card.
        peekingCard.updatePeek(0, /* shouldAnimate */
        false);
        return;
    }
    // If we have the card offset field trial enabled, don't peek at all.
    if (CardsVariationParameters.getFirstCardOffsetDp() != 0) {
        peekingCard.updatePeek(0, /* shouldAnimate */
        false);
        return;
    }
    // Here we consider that if the header is animating (is not completely expanded), the card
    // should as well. In that case, the space below the header is what we have available.
    boolean shouldAnimate = header.itemView.getHeight() < mMaxHeaderHeight;
    peekingCard.updatePeek(getHeight() - header.itemView.getBottom(), shouldAnimate);
}
Also used : SectionHeaderViewHolder(org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder)

Example 3 with SectionHeaderViewHolder

use of org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder in project AndroidChromium by JackyAndroid.

the class NewTabPageRecyclerView method updatePeekingCardAndHeader.

public void updatePeekingCardAndHeader() {
    NewTabPageLayout aboveTheFoldView = findAboveTheFoldView();
    if (aboveTheFoldView == null)
        return;
    SectionHeaderViewHolder header = findFirstHeader();
    if (header == null)
        return;
    header.updateDisplay(computeVerticalScrollOffset(), mHasSpaceForPeekingCard);
    CardViewHolder firstCard = findFirstCard();
    if (firstCard != null)
        updatePeekingCard(firstCard);
    // Update the space at the bottom, which needs to know about the height of the header.
    refreshBottomSpacing();
}
Also used : SectionHeaderViewHolder(org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder) NewTabPageLayout(org.chromium.chrome.browser.ntp.NewTabPageLayout)

Aggregations

SectionHeaderViewHolder (org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder)3 NewTabPageLayout (org.chromium.chrome.browser.ntp.NewTabPageLayout)1