Java Code Examples for androidx.viewpager.widget.ViewPager#SCROLL_STATE_DRAGGING

The following examples show how to use androidx.viewpager.widget.ViewPager#SCROLL_STATE_DRAGGING . 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: UnderlinePageIndicator.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    mCurrentPage = position;
    mPositionOffset = positionOffset;
    if (mFades) {
        if (positionOffsetPixels > 0) {
            removeCallbacks(mFadeRunnable);
            mPaint.setAlpha(0xFF);
        } else if (mScrollState != ViewPager.SCROLL_STATE_DRAGGING) {
            postDelayed(mFadeRunnable, mFadeDelay);
        }
    }
    invalidate();

    if (mListener != null) {
        mListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
    }
}
 
Example 2
Source File: DeviceDetailPagerAdapter.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(final int state) {
    handleScrollState(state);
    mScrollState = state;

    int nextIndex = mCurrentPosition + 1 == getCount() ? 0 : mCurrentPosition + 1;
    int prevIndex = mCurrentPosition - 1 < 0 ? getCount() - 1 : mCurrentPosition - 1;

    final ArcusProductFragment fragment = (ArcusProductFragment) instantiateItem(mViewPager, mCurrentSelectedPosition);
    final ArcusProductFragment next = (ArcusProductFragment) instantiateItem(mViewPager, nextIndex);
    final ArcusProductFragment prev = (ArcusProductFragment) instantiateItem(mViewPager, prevIndex);

    switch (state) {
        case ViewPager.SCROLL_STATE_DRAGGING:
            fragment.setNavThumbsVisible(false);
            next.setNavThumbsVisible(false);
            prev.setNavThumbsVisible(false);
            break;
        case ViewPager.SCROLL_STATE_IDLE:
            fragment.setNavThumbsVisible(true);
            next.setNavThumbsVisible(true);
            prev.setNavThumbsVisible(true);
            break;
        case ViewPager.SCROLL_STATE_SETTLING:
            fragment.setNavThumbsVisible(false);
            next.setNavThumbsVisible(false);
            prev.setNavThumbsVisible(false);
            break;
        default:
            fragment.setNavThumbsVisible(true);
            next.setNavThumbsVisible(true);
            prev.setNavThumbsVisible(true);
            break;
    }
}
 
Example 3
Source File: MainActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (appBar.getY() <= -appBar.getMeasuredHeight()) {
        switch (state) {
            case ViewPager.SCROLL_STATE_DRAGGING:
                indicator.setDisplayState(true);
                break;

            case ViewPager.SCROLL_STATE_IDLE:
                indicator.setDisplayState(false);
                break;
        }
    }
}
 
Example 4
Source File: SearchActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (appBar.getY() <= -appBar.getMeasuredHeight()) {
        switch (state) {
            case ViewPager.SCROLL_STATE_DRAGGING:
                indicator.setDisplayState(true);
                break;

            case ViewPager.SCROLL_STATE_IDLE:
                indicator.setDisplayState(false);
                break;
        }
    }
}
 
Example 5
Source File: UserActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (appBar.getY() <= -appBar.getMeasuredHeight()) {
        switch (state) {
            case ViewPager.SCROLL_STATE_DRAGGING:
                indicator.setDisplayState(true);
                break;

            case ViewPager.SCROLL_STATE_IDLE:
                indicator.setDisplayState(false);
                break;
        }
    }
}
 
Example 6
Source File: MeActivity.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (appBar.getY() <= -appBar.getMeasuredHeight()) {
        switch (state) {
            case ViewPager.SCROLL_STATE_DRAGGING:
                indicator.setDisplayState(true);
                break;

            case ViewPager.SCROLL_STATE_IDLE:
                indicator.setDisplayState(false);
                break;
        }
    }
}
 
Example 7
Source File: TabLayoutHelper.java    From android-tablayouthelper with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset,
                           int positionOffsetPixels) {
    final TabLayout tabLayout = mTabLayoutRef.get();
    if (tabLayout != null) {
        if (shouldUpdateScrollPosition()) {
            // Update the scroll position, only update the text selection if we're being
            // dragged (or we're settling after a drag)
            final boolean updateText = (mScrollState == ViewPager.SCROLL_STATE_DRAGGING)
                    || (mScrollState == ViewPager.SCROLL_STATE_SETTLING
                    && mPreviousScrollState == ViewPager.SCROLL_STATE_DRAGGING);
            tabLayout.setScrollPosition(position, positionOffset, updateText);
        }
    }
}
 
Example 8
Source File: TabIndicatorView.java    From material with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    switch (state){
        case ViewPager.SCROLL_STATE_IDLE:
            notifyTabScrollStateChanged(SCROLL_STATE_IDLE);
            break;
        case ViewPager.SCROLL_STATE_DRAGGING:
            notifyTabScrollStateChanged(SCROLL_STATE_DRAGGING);
            break;
        case ViewPager.SCROLL_STATE_SETTLING:
            notifyTabScrollStateChanged(SCROLL_STATE_SETTLING);
            break;
    }
}
 
Example 9
Source File: IntoViewPagerListener.java    From GestureViews with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    preventExit = state == ViewPager.SCROLL_STATE_DRAGGING && !getAnimator().isLeaving();

    if (state == ViewPager.SCROLL_STATE_IDLE && getAnimator().getRequestedId() != null) {
        switchToCurrentPage();
    }
}
 
Example 10
Source File: TabLayoutHelper.java    From android-tablayouthelper with Apache License 2.0 4 votes vote down vote up
private boolean shouldUpdateScrollPosition() {
    return (mScrollState == ViewPager.SCROLL_STATE_DRAGGING) ||
            ((mScrollState == ViewPager.SCROLL_STATE_SETTLING) && (mPreviousScrollState == ViewPager.SCROLL_STATE_DRAGGING));
}
 
Example 11
Source File: CircularViewPager.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (position == getCurrentItem() && positionOffset == 0f && scrollState == ViewPager.SCROLL_STATE_DRAGGING) {
        checkCurrentItem();
    }
}
 
Example 12
Source File: CircularViewPager.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (position == getCurrentItem() && positionOffset == 0f && scrollState == ViewPager.SCROLL_STATE_DRAGGING) {
        checkCurrentItem();
    }
}