Java Code Examples for android.support.v4.view.ViewPager#SCROLL_STATE_DRAGGING
The following examples show how to use
android.support.v4.view.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: CustomBanner.java From WanAndroid with Apache License 2.0 | 6 votes |
@Override public void onPageScrollStateChanged(int state) { if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(state); } //当currentItem为0的时候,会被重置为3 //当currentItem为4的时候,会被重置为1 switch (state) { case ViewPager.SCROLL_STATE_IDLE://无操作 viewPager.setCurrentItem(getRealCurrentPosition(currentItem), false); break; case ViewPager.SCROLL_STATE_DRAGGING://开始滑动 viewPager.setCurrentItem(getRealCurrentPosition(currentItem), false); break; case ViewPager.SCROLL_STATE_SETTLING://停止滑动 break; } }
Example 2
Source File: ParallaxContainer.java From ParallaxSplash with Apache License 2.0 | 6 votes |
@Override public void onPageScrollStateChanged(int state) { final AnimationDrawable animationDrawable = (AnimationDrawable) iv.getBackground(); switch (state) { case ViewPager.SCROLL_STATE_IDLE: animationDrawable.stop(); break; case ViewPager.SCROLL_STATE_DRAGGING: animationDrawable.start(); break; default: break; } }
Example 3
Source File: ParallaxOnPageChangeListener.java From ParallaxViewPagers with Apache License 2.0 | 6 votes |
@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 4
Source File: UnderlinePageIndicator.java From InfiniteViewPager with MIT License | 6 votes |
@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 5
Source File: UnderlinePageIndicator.java From BigApp_WordPress_Android with Apache License 2.0 | 6 votes |
@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 6
Source File: UnderlinePageIndicator.java From zhangshangwuda with Apache License 2.0 | 6 votes |
@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 7
Source File: FlashView.java From Social with Apache License 2.0 | 6 votes |
@Override public void onPageScrollStateChanged(int arg0) { // TODO Auto-generated method stub switch (arg0) { case ViewPager.SCROLL_STATE_DRAGGING: mhandler.sendEmptyMessage(ImageHandler.MSG_KEEP_SILENT); break; case ViewPager.SCROLL_STATE_IDLE: mhandler.sendEmptyMessageDelayed(ImageHandler.MSG_UPDATE_IMAGE,ImageHandler.MSG_DELAY); break; // case ViewPager.SCROLL_STATE_SETTLING: // System.out.println("GGGGGGGGG"); // mhandler.sendEmptyMessageDelayed(ImageHandler.MSG_UPDATE_IMAGE,ImageHandler.MSG_DELAY); // break; default: break; } }
Example 8
Source File: CarouselView.java From carouselview with Apache License 2.0 | 6 votes |
@Override public void onPageScrollStateChanged(int state) { //User initiated scroll if (previousState == ViewPager.SCROLL_STATE_DRAGGING && state == ViewPager.SCROLL_STATE_SETTLING) { if (disableAutoPlayOnUserInteraction) { pauseCarousel(); } else { playCarousel(); } } else if (previousState == ViewPager.SCROLL_STATE_SETTLING && state == ViewPager.SCROLL_STATE_IDLE) { } previousState = state; }
Example 9
Source File: UnderlinePageIndicator.java From android-open-project-demo with Apache License 2.0 | 6 votes |
@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 10
Source File: UnderlinePageIndicator.java From iMoney with Apache License 2.0 | 6 votes |
@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 11
Source File: UnderlinePageIndicator.java From narrate-android with Apache License 2.0 | 6 votes |
@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 12
Source File: UnderlinePageIndicator.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@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 13
Source File: UnderlinePageIndicator.java From android-open-project-demo with Apache License 2.0 | 6 votes |
@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 14
Source File: ExploreListAdapter.java From C9MJ with Apache License 2.0 | 5 votes |
@Override public void onPageScrollStateChanged(int state) { switch (state) { case ViewPager.SCROLL_STATE_DRAGGING: isAutoScrolled = false; break; case ViewPager.SCROLL_STATE_SETTLING: isAutoScrolled = false; break; case ViewPager.SCROLL_STATE_IDLE: isAutoScrolled = true; break; } }
Example 15
Source File: BallTabLayout.java From nono-android with GNU General Public License v3.0 | 5 votes |
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { final BallTabLayout tabLayout = mTabLayoutRef.get(); if (tabLayout != null) { // 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 16
Source File: GiftPanelControl.java From LiveGiftLayout with Apache License 2.0 | 5 votes |
@Override public void onPageScrollStateChanged(int state) { //ViewPager.SCROLL_STATE_IDLE 空闲状态 0;CustormViewPager.SCROLL_STATE_DRAGGING 正在滑动 1 //ViewPager.SCROLL_STATE_SETTLING 滑动完毕 2;页面开始滑动时,状态变化(1,2,0) if (state == ViewPager.SCROLL_STATE_DRAGGING) { isScrolling = true; } else { isScrolling = false; } if (state == ViewPager.SCROLL_STATE_SETTLING) { // Log.i("CustormViewPager", "----------------right =>" + right + "; left =>" + left + "----------------------------"); right = left = false; // lastValue = -1; } }
Example 17
Source File: ViewPagerIdlingResource.java From Equate with GNU General Public License v3.0 | 5 votes |
@Override public void onPageScrollStateChanged(int state) { mIdle = (state == ViewPager.SCROLL_STATE_IDLE // Treat dragging as idle, or Espresso will block itself when swiping. || state == ViewPager.SCROLL_STATE_DRAGGING); if (mIdle && mResourceCallback != null) { mResourceCallback.onTransitionToIdle(); } }
Example 18
Source File: ViewerActivity.java From GankMeizhi with Apache License 2.0 | 4 votes |
@OnPageChange(value = R.id.pager, callback = OnPageChange.Callback.PAGE_SCROLL_STATE_CHANGED) void onPageChange(int state) { if (state == ViewPager.SCROLL_STATE_DRAGGING) { hideSystemUi(); } }
Example 19
Source File: DialtactsActivity.java From coursera-android with MIT License | 4 votes |
@Override public void onPageScrollStateChanged(int state) { switch (state) { case ViewPager.SCROLL_STATE_IDLE: { if (mNextPosition == -1) { // This happens when the user drags the screen just after launching the // application, and settle down the same screen without actually swiping it. // At that moment mNextPosition is apparently -1 yet, and we expect it // being updated by onPageSelected(), which is *not* called if the user // settle down the exact same tab after the dragging. if (DEBUG) { Log.d(TAG, "Next position is not specified correctly. Use current tab (" + mViewPager.getCurrentItem() + ")"); } mNextPosition = mViewPager.getCurrentItem(); } if (DEBUG) { Log.d(TAG, "onPageScrollStateChanged() with SCROLL_STATE_IDLE. " + "mCurrentPosition: " + mCurrentPosition + ", mNextPosition: " + mNextPosition); } // Interpret IDLE as the end of migration (both swipe and tab click) mDuringSwipe = false; mUserTabClick = false; updateFakeMenuButtonsVisibility(mNextPosition == TAB_INDEX_DIALER); sendFragmentVisibilityChange(mCurrentPosition, false); sendFragmentVisibilityChange(mNextPosition, true); invalidateOptionsMenu(); mCurrentPosition = mNextPosition; break; } case ViewPager.SCROLL_STATE_DRAGGING: { if (DEBUG) Log.d(TAG, "onPageScrollStateChanged() with SCROLL_STATE_DRAGGING"); mDuringSwipe = true; mUserTabClick = false; break; } case ViewPager.SCROLL_STATE_SETTLING: { if (DEBUG) Log.d(TAG, "onPageScrollStateChanged() with SCROLL_STATE_SETTLING"); mDuringSwipe = true; mUserTabClick = false; break; } default: break; } }
Example 20
Source File: ViewerActivity.java From GankApp with GNU General Public License v2.0 | 4 votes |
@Override public void onPageScrollStateChanged(int state) { if (state == ViewPager.SCROLL_STATE_DRAGGING) { hideSystemUi(); } }