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

The following examples show how to use androidx.viewpager.widget.ViewPager#SCROLL_STATE_IDLE . 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: PagerSlidingTabStrip.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        scrollToChild(pager.getCurrentItem(), 0);
    }
    //Full alpha for current item
    View currentTab = tabsContainer.getChildAt(pager.getCurrentItem());
    selected(currentTab);
    //Half transparent for prev item
    if (pager.getCurrentItem() - 1 >= 0) {
        View prevTab = tabsContainer.getChildAt(pager.getCurrentItem() - 1);
        notSelected(prevTab);
    }
    //Half transparent for next item
    if (pager.getCurrentItem() + 1 <= pager.getAdapter().getCount() - 1) {
        View nextTab = tabsContainer.getChildAt(pager.getCurrentItem() + 1);
        notSelected(nextTab);
    }

    if (delegatePageListener != null) {
        delegatePageListener.onPageScrollStateChanged(state);
    }
}
 
Example 2
Source File: TabStripHelper.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
private void onViewPagerAdapterChanged(@Nullable PagerAdapter oldAdapter,
                                       @Nullable PagerAdapter newAdapter) {
    if (mView instanceof TabStripView)
        ((TabStripView) mView).onViewPagerAdapterChanged(oldAdapter, newAdapter);
    else if (mView instanceof TabStripViewGroup)
        ((TabStripViewGroup) mView).onViewPagerAdapterChanged(oldAdapter, newAdapter);
    if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mPosition = 0;
        mOffset = 0;
        if (oldAdapter != null)
            oldAdapter.unregisterDataSetObserver(this);
        if (newAdapter != null)
            newAdapter.registerDataSetObserver(this);
        if (mPager != null)
            mPosition = mPager.getCurrentItem();
        updateView(true);
    }
}
 
Example 3
Source File: TabStripHelper.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
void bindViewPager(ViewPager pager) {
    if (mPager == pager)
        return;
    boolean update = false;
    if (mPager != null) {
        onDetachedFromViewPager(mPager);
        update = true;
    }
    mPager = pager;
    if (mPager != null) {
        onAttachedToViewPager(mPager);
        update = false;
    }
    if (update && mScrollState == ViewPager.SCROLL_STATE_IDLE)
        updateView(true);
}
 
Example 4
Source File: PagerSlidingTabStrip.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        scrollToChild(pager.getCurrentItem(), 0);
    }
    if (delegatePageListener != null) {
        delegatePageListener.onPageScrollStateChanged(state);
    }
}
 
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: TimesFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        int pos = mPager.getCurrentItem();
        if (pos != 0) {
            Times t = Times.getTimes(mAdapter.getItemId(pos));
            mImsakiyeFrag.setTimes(t);
        }
    }
}
 
Example 7
Source File: TabStripHelper.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
public void onChanged() {
    if (mView instanceof TabStripView)
        ((TabStripView) mView).onViewPagerAdapterDataChanged();
    else if (mView instanceof TabStripViewGroup)
        ((TabStripViewGroup) mView).onViewPagerAdapterDataChanged();
    if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mPosition = 0;
        mOffset = 0;
        if (mPager != null)
            mPosition = mPager.getCurrentItem();
        updateView(true);
    }
}
 
Example 8
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 9
Source File: PagerSlidingTabStrip.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        scrollToChild(pager.getCurrentItem(), 0);
    }

    if (delegatePageListener != null) {
        delegatePageListener.onPageScrollStateChanged(state);
    }
}
 
Example 10
Source File: SlidingTabLayout.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
  if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
    mTabStrip.onViewPagerPageChanged(position, 0f);
    scrollToTab(position, 0);
  }
  for (int i = 0; i < mTabStrip.getChildCount(); i++) {
    mTabStrip.getChildAt(i).setSelected(position == i);
  }
  if (mViewPagerPageChangeListener != null) {
    mViewPagerPageChangeListener.onPageSelected(position);
  }
}
 
Example 11
Source File: UnderlinePageIndicator.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mCurrentPage = position;
        mPositionOffset = 0;
        invalidate();
        mFadeRunnable.run();
    }
    if (mListener != null) {
        mListener.onPageSelected(position);
    }
}
 
Example 12
Source File: TabStripHelper.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (mView instanceof TabStripView)
        ((TabStripView) mView).onViewPagerScrollStateChanged(state);
    else if (mView instanceof TabStripViewGroup)
        ((TabStripViewGroup) mView).onViewPagerScrollStateChanged(state);
    mScrollState = state;
    if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        if (mPosition != mPager.getCurrentItem() || mOffset != 0) {
            mPosition = mPager.getCurrentItem();
            mOffset = 0;
            updateView(false);
        }
    }
}
 
Example 13
Source File: CircularViewPager.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        checkCurrentItem();
    }
    scrollState = state;
}
 
Example 14
Source File: CirclePageIndicator.java    From Kore with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (mSnap || mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mCurrentPage = position;
        mSnapPage = position;
        invalidate();
    }

    if (mListener != null) {
        mListener.onPageSelected(position);
    }
}
 
Example 15
Source File: SlidingTabLayout.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mTabStrip.onViewPagerPageChanged(position, 0f);
        scrollToTab(position, 0);
    }
    for (int i = 0; i < mTabStrip.getChildCount(); i++) {
        mTabStrip.getChildAt(i).setSelected(position == i);
    }
    if (mViewPagerPageChangeListener != null) {
        mViewPagerPageChangeListener.onPageSelected(position);
    }
}
 
Example 16
Source File: ViewPagerActions.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isIdleNow() {
  if (!mNeedsIdle) {
    return true;
  } else {
    return mCurrState == ViewPager.SCROLL_STATE_IDLE;
  }
}
 
Example 17
Source File: CirclePageIndicator.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (mSnap || mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mCurrentPage = position;
        mSnapPage = position;
        invalidate();
    }

    if (mListener != null) {
        mListener.onPageSelected(position);
    }
}
 
Example 18
Source File: TitlePageIndicator.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mCurrentPage = position;
        invalidate();
    }

    if (mListener != null) {
        mListener.onPageSelected(position);
    }
}
 
Example 19
Source File: GuideActivity.java    From AndroidProject with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        mCompleteView.setVisibility(mViewPager.getCurrentItem() == mPagerAdapter.getCount() - 1 ? View.VISIBLE : View.INVISIBLE);
    }
}
 
Example 20
Source File: DeviceDetailPagerAdapter.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
private void handleScrollState(final int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        setNextItemIfNeeded();
    }
}