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

The following examples show how to use android.support.v4.view.ViewPager#SCROLL_STATE_SETTLING . 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: CommentsTimeLineFragment.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    super.onPageScrollStateChanged(state);
    switch (state) {
        case ViewPager.SCROLL_STATE_SETTLING:
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    LongClickableLinkMovementMethod.getInstance().setLongClickable(true);

                }
            }, ViewConfiguration.getLongPressTimeout());
            break;
        default:
            LongClickableLinkMovementMethod.getInstance().setLongClickable(false);
            break;
    }
}
 
Example 2
Source File: Codecs.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onPageScrollStateChanged(int state) {
    switch (state) {
        case ViewPager.SCROLL_STATE_IDLE: {
            invalidateOptionsMenu();

            mCurrentPosition = mNextPosition;
            break;
        }
        case ViewPager.SCROLL_STATE_DRAGGING:
        case ViewPager.SCROLL_STATE_SETTLING:
        default:
            break;
    }
}
 
Example 3
Source File: SipHome.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    switch (state) {
        case ViewPager.SCROLL_STATE_IDLE: {
            if (mCurrentPosition >= 0) {
                sendFragmentVisibilityChange(mCurrentPosition, false);
            }
            if (mNextPosition >= 0) {
                sendFragmentVisibilityChange(mNextPosition, true);
            }
            supportInvalidateOptionsMenu();

            mCurrentPosition = mNextPosition;
            break;
        }
        case ViewPager.SCROLL_STATE_DRAGGING:
            clearDetails();
            hasClearedDetails = true;
            break;
        case ViewPager.SCROLL_STATE_SETTLING:
            hasClearedDetails = false;
            break;
        default:
            break;
    }
}
 
Example 4
Source File: WXSlider.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {

  /**
   * @[email protected]
   *
   *  add scrollstart & scrollend event
   *
   */
  switch (state) {
    case ViewPager.SCROLL_STATE_IDLE:
      lastPositionOffset = 99f;
      target.fireEvent("scrollend");
      break;
    case ViewPager.SCROLL_STATE_DRAGGING:
      target.fireEvent("scrollstart");
      break;
    case ViewPager.SCROLL_STATE_SETTLING:
      break;

  }
}
 
Example 5
Source File: CarouselView.java    From carouselview with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: CommentsTimeLineFragment.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    super.onPageScrollStateChanged(state);
    switch (state) {
        case ViewPager.SCROLL_STATE_SETTLING:
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    LongClickableLinkMovementMethod.getInstance().setLongClickable(true);

                }
            }, ViewConfiguration.getLongPressTimeout());
            break;
        default:
            LongClickableLinkMovementMethod.getInstance().setLongClickable(false);
            break;
    }
}
 
Example 7
Source File: ExploreListAdapter.java    From C9MJ with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: ViewPagerFragment.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    super.onPageScrollStateChanged(state);
    DevLog.printLog("SimpleOnPageChangeListener onPageScrollStateChanged", "" + state);
    switch (state) {
        case ViewPager.SCROLL_STATE_SETTLING:
            break;
        default:
            break;
    }
}
 
Example 9
Source File: CalibrationLinearityActivity.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if(state == ViewPager.SCROLL_STATE_SETTLING) {
        initSelectedGraph();
    } else if(state == ViewPager.SCROLL_STATE_IDLE) {
        updateSelectedGraph();
    }
}
 
Example 10
Source File: ViewPagerFragment.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    super.onPageScrollStateChanged(state);
    DevLog.printLog("SimpleOnPageChangeListener onPageScrollStateChanged", "" + state);
    switch (state) {
        case ViewPager.SCROLL_STATE_SETTLING:
            break;
        default:
            break;
    }
}
 
Example 11
Source File: OnPageChangeListenerAdapter.java    From android-transition with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    switch (state) {
        case ViewPager.SCROLL_STATE_IDLE:
            stopTransition();
            break;
        case ViewPager.SCROLL_STATE_DRAGGING:
        case ViewPager.SCROLL_STATE_SETTLING:
            getAdapterState().setTransiting(true);
            break;
    }
}
 
Example 12
Source File: MaterialViewPager.java    From MaterialViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (currentPagerState != ViewPager.SCROLL_STATE_SETTLING) {
        if (positionOffset >= 0.5) {
            onPageSelected(position + 1);
        } else if (positionOffset <= -0.5) {
            onPageSelected(position - 1);
        } else {
            onPageSelected(position);
        }
    }
}
 
Example 13
Source File: ViewPagerIdlingResource.java    From aws-device-farm-sample-app-for-android with Apache License 2.0 5 votes vote down vote up
/**
 * Checks to see if not in a scrolling state
 *
 * @param state the viewpager's state
 */
@Override
public void onPageScrollStateChanged(int state) {
    this.isIdle = state != ViewPager.SCROLL_STATE_SETTLING;

    if (this.isIdle)
        this.resourceCallback.onTransitionToIdle();
}
 
Example 14
Source File: BaseAction.java    From FlowHelper with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {

    /**
     * 这里的处理是因为外部调用了 setCurrentItem ,此时 item 之间的差值也大于1;
     * 但因为没有回调 onItemClick,所以 draw 、动画等效果没法实现,因此,可以先通过
     * Viewpager 拿到 setCurrentItem(position) 中的position,赋值给当前的 mCurrentIndex;
     * 且两者之间大于1时,直接使用draw和动画效果;不再让 onPageScrolled 去执行动画,避免卡顿
     */
    if (state == ViewPager.SCROLL_STATE_SETTLING){
        if (!isTabClick && mViewPager != null){
            mLastIndex = mCurrentIndex;
            mCurrentIndex = mViewPager.getCurrentItem();
            if (Math.abs(mCurrentIndex - mLastIndex) > 1){
                isClickMore = true;
                clearColorText();
                doAnim(mLastIndex, mCurrentIndex,mAnimTime);
                autoScaleView();
            }
        }
    }

    if (state == ViewPager.SCROLL_STATE_IDLE){
        isClickMore = false;
        isTabClick = false;
    }


}
 
Example 15
Source File: BallTabLayout.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
@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 vote down vote up
@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: ReuseLayoutHook.java    From android_viewtracker with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    if (this.state == ViewPager.SCROLL_STATE_SETTLING && state == ViewPager.SCROLL_STATE_IDLE) {
        ExposureManager.getInstance().triggerViewCalculate(TrackerInternalConstants.TRIGGER_VIEW_CHANGED, mRootLayout, mCommonInfo, mRootLayout.getLastVisibleViewMap());
    }
    this.state = state;
}
 
Example 18
Source File: SlidingTabLayout.java    From android-common-utils with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrollStateChanged(int state) {
    ignore = state == ViewPager.SCROLL_STATE_SETTLING;
}
 
Example 19
Source File: ReuseLayoutHook.java    From android_viewtracker with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageSelected(int position) {
    if (state != ViewPager.SCROLL_STATE_SETTLING) {
        ExposureManager.getInstance().triggerViewCalculate(TrackerInternalConstants.TRIGGER_VIEW_CHANGED, mRootLayout, mCommonInfo, mRootLayout.getLastVisibleViewMap());
    }
}
 
Example 20
Source File: DialtactsActivity.java    From coursera-android with MIT License 4 votes vote down vote up
@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;
    }
}