Java Code Examples for android.support.v4.view.ViewPager#SCROLL_STATE_IDLE

The following examples show how to use android.support.v4.view.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: ParallaxOnPageChangeListener.java    From ParallaxViewPagers with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state)
  {
  final ViewPager currentMaster=masterRef.get();
  if(currentMaster==viewPager2)
    return;
  switch(state)
    {
    case ViewPager.SCROLL_STATE_DRAGGING:
      if(currentMaster==null)
        masterRef.set(viewPager);
      break;
    case ViewPager.SCROLL_STATE_SETTLING:
      if(mLastPos!=viewPager2.getCurrentItem())
        viewPager2.setCurrentItem(viewPager.getCurrentItem(),false);
      break;
    case ViewPager.SCROLL_STATE_IDLE:
      masterRef.set(null);
      viewPager2.setCurrentItem(viewPager.getCurrentItem(),false);
      mLastPos=-1;
      break;
    }
  }
 
Example 2
Source File: SlidingTabLayout.java    From android-SlidingTabsBasic 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);
    }

    if (mViewPagerPageChangeListener != null) {
        mViewPagerPageChangeListener.onPageSelected(position);
    }
}
 
Example 3
Source File: PagerSlidingTabStripExtend.java    From mobile-manager-tool with MIT License 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 4
Source File: PagerSlidingTabStrip.java    From Conquer 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 5
Source File: TabsPagerTitleStrip.java    From TelePlus-Android 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 6
Source File: LoopViewPager.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (mAdapter != null) {
        int position = LoopViewPager.super.getCurrentItem();
        int realPosition = mAdapter.toRealPosition(position);
        if (state == ViewPager.SCROLL_STATE_IDLE
                && (position == 0 || position == mAdapter.getCount() - 1)) {
            setCurrentItem(realPosition, false);
        }
    }
    if (mOuterPageChangeListener != null) {
        mOuterPageChangeListener.onPageScrollStateChanged(state);
    }
}
 
Example 7
Source File: SlidingTabLayout.java    From android-tv-leanback 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);
    }

    if (mViewPagerPageChangeListener != null) {
        mViewPagerPageChangeListener.onPageSelected(position);
    }
}
 
Example 8
Source File: NavigationTabStrip.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(final MotionEvent event) {
    // Return if animation is running
    if (mAnimator.isRunning()) return true;
    // If is not idle state, return
    if (mScrollState != ViewPager.SCROLL_STATE_IDLE) return true;

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // Action down touch
            mIsActionDown = true;
            if (!mIsViewPagerMode) break;
            // Detect if we touch down on tab, later to move
            mIsTabActionDown = (int) (event.getX() / mTabSize) == mIndex;
            break;
        case MotionEvent.ACTION_MOVE:
            // If tab touched, so move
            if (mIsTabActionDown) {
                mViewPager.setCurrentItem((int) (event.getX() / mTabSize), true);
                break;
            }
            if (mIsActionDown) break;
        case MotionEvent.ACTION_UP:
            // Press up and set tab index relative to current coordinate
            if (mIsActionDown) setTabIndex((int) (event.getX() / mTabSize));
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_OUTSIDE:
        default:
            // Reset action touch variables
            mIsTabActionDown = false;
            mIsActionDown = false;
            break;
    }

    return true;
}
 
Example 9
Source File: CirclePageIndicator.java    From ZhihuDaily 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 10
Source File: PagerSlidingTabStrip.java    From 920-text-editor-v2 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 11
Source File: EasySlidingTabs.java    From EasySlidingTabs with Apache License 2.0 5 votes vote down vote up
@Override public void onPageScrollStateChanged(int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        scrollToChild(EasySlidingTabs.this.pager.getCurrentItem(), 0);
    }

    if (EasySlidingTabs.this.delegatePageListener != null) {
        EasySlidingTabs.this.delegatePageListener.onPageScrollStateChanged(state);
    }
}
 
Example 12
Source File: CirclePageIndicator.java    From AndroidLinkup with GNU General Public License v2.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 13
Source File: SlidingTabLayout.java    From OneTapVideoDownload with GNU General Public License v3.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 14
Source File: CustomViewPagerListener.java    From android-material-stepper with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    mCurrState = state;
    if (mCurrState == ViewPager.SCROLL_STATE_IDLE) {
        if (mCallback != null) {
            mCallback.onTransitionToIdle();
        }
    }
}
 
Example 15
Source File: CirclePageIndicator.java    From wakao-app with MIT License 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 16
Source File: PagerSlidingTabStrip.java    From MousePaint with MIT License 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 17
Source File: TitlePageIndicator.java    From InfiniteViewPager with MIT License 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 18
Source File: PagerSlidingTabStrip.java    From KitKatEmoji with MIT License 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 19
Source File: FixedIndicatorView.java    From SprintNBA with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
	if (state == ViewPager.SCROLL_STATE_IDLE) {
		onPageScrolled(getCurrentItem(), 0, 0);
	}
}
 
Example 20
Source File: ECardFlow.java    From ECardFlow with MIT License 4 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    isSwitching = state != ViewPager.SCROLL_STATE_IDLE;
}