当前位置: 首页>>代码示例>>Java>>正文


Java ViewConfiguration.getScaledPagingTouchSlop方法代码示例

本文整理汇总了Java中android.view.ViewConfiguration.getScaledPagingTouchSlop方法的典型用法代码示例。如果您正苦于以下问题:Java ViewConfiguration.getScaledPagingTouchSlop方法的具体用法?Java ViewConfiguration.getScaledPagingTouchSlop怎么用?Java ViewConfiguration.getScaledPagingTouchSlop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewConfiguration的用法示例。


在下文中一共展示了ViewConfiguration.getScaledPagingTouchSlop方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.view.ViewConfiguration; //导入方法依赖的package包/类
/**
 * Initializes various states for this workspace.
 */
protected void init() {
    mScroller = new LauncherScroller(getContext());
    setDefaultInterpolator(new ScrollInterpolator());
    mCurrentPage = 0;

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    float density = getResources().getDisplayMetrics().density;
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * density);
    mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * density);
    setOnHierarchyChangeListener(this);
    setWillNotDraw(false);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:20,代码来源:PagedView.java

示例2: StackLayout

import android.view.ViewConfiguration; //导入方法依赖的package包/类
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost,
        EventFilter eventFilter) {
    super(context, updateHost, renderHost, eventFilter);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:28,代码来源:StackLayout.java

示例3: initViewPager

import android.view.ViewConfiguration; //导入方法依赖的package包/类
void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the ViewPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the ViewPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since ViewPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:BaseViewPager.java

示例4: handleTouchEvent

import android.view.ViewConfiguration; //导入方法依赖的package包/类
/**
 * Handles the touch event and determines whether to show the fast scroller (or updates it if
 * it is already showing).
 */
void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY) {
    ViewConfiguration config = ViewConfiguration.get(mRv.getContext());

    int action = ev.getAction();
    int y = (int) ev.getY();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (isNearThumb(downX, downY)) {
                mTouchOffsetY = downY - mThumbOffsetY;
            } else if (mRv.supportsFastScrolling()
                    && isNearScrollBar(downX)) {
                calcTouchOffsetAndPrepToFastScroll(downY, lastY);
                updateFastScrollSectionNameAndThumbOffset(lastY, y);
            }
            break;
        case MotionEvent.ACTION_MOVE:
            // Check if we should start scrolling, but ignore this fastscroll gesture if we have
            // exceeded some fixed movement
            mIgnoreDragGesture |= Math.abs(y - downY) > config.getScaledPagingTouchSlop();
            if (!mIsDragging && !mIgnoreDragGesture && mRv.supportsFastScrolling() &&
                    isNearThumb(downX, lastY) &&
                    Math.abs(y - downY) > config.getScaledTouchSlop()) {
                calcTouchOffsetAndPrepToFastScroll(downY, lastY);
            }
            if (mIsDragging) {
                updateFastScrollSectionNameAndThumbOffset(lastY, y);
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mTouchOffsetY = 0;
            mLastTouchY = 0;
            mIgnoreDragGesture = false;
            if (mIsDragging) {
                mIsDragging = false;
                animatePopupVisibility(false);
                showActiveScrollbar(false);
            }
            break;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:46,代码来源:BaseRecyclerViewFastScrollBar.java

示例5: initViewPager

import android.view.ViewConfiguration; //导入方法依赖的package包/类
void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new YViewPager.MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the ViewPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the ViewPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since ViewPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
开发者ID:youngkaaa,项目名称:YViewPagerDemo,代码行数:79,代码来源:YViewPager.java

示例6: initViewPager

import android.view.ViewConfiguration; //导入方法依赖的package包/类
void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new YViewPagerNew.MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the ViewPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the ViewPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since ViewPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
开发者ID:youngkaaa,项目名称:YViewPagerDemo,代码行数:79,代码来源:YViewPagerNew.java

示例7: initViewPager

import android.view.ViewConfiguration; //导入方法依赖的package包/类
void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new YViewPagerOrigin.MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the ViewPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the ViewPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since ViewPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
开发者ID:youngkaaa,项目名称:YViewPagerDemo,代码行数:79,代码来源:YViewPagerOrigin.java

示例8: handleTouchEvent

import android.view.ViewConfiguration; //导入方法依赖的package包/类
/**
 * Handles the touch event and determines whether to show the fast scroller (or updates it if
 * it is already showing).
 */
protected void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY) {
  ViewConfiguration config = ViewConfiguration.get(recyclerView.getContext());

  int action = ev.getAction();
  int y = (int) ev.getY();
  switch (action) {
    case MotionEvent.ACTION_DOWN:
      if (isNearThumb(downX, downY)) {
        touchOffset = downY - thumbOffset.y;
      }
      break;
    case MotionEvent.ACTION_MOVE:
      // Check if we should start scrolling, but ignore this fastscroll gesture if we have
      // exceeded some fixed movement
      ignoreDragGesture |= Math.abs(y - downY) > config.getScaledPagingTouchSlop();
      if (!isDragging && !ignoreDragGesture && isNearThumb(downX, lastY) &&
          Math.abs(y - downY) > config.getScaledTouchSlop()) {
        recyclerView.getParent().requestDisallowInterceptTouchEvent(true);
        isDragging = true;
        if (canThumbDetach) {
          isThumbDetached = true;
        }
        touchOffset += (lastY - downY);
        fastScrollPopup.animateVisibility(true);
        animateScrollbar(true);
      }
      if (isDragging) {
        // Update the fastscroller section name at this touch position
        int top = recyclerView.getBackgroundPadding().top;
        int bottom = recyclerView.getHeight() - recyclerView.getBackgroundPadding().bottom - thumbHeight;
        float boundedY = (float) Math.max(top, Math.min(bottom, y - touchOffset));
        String sectionName = recyclerView.scrollToPositionAtProgress((boundedY - top) / (bottom - top));
        fastScrollPopup.setSectionName(sectionName);
        fastScrollPopup.animateVisibility(!sectionName.isEmpty());
        recyclerView.invalidate(fastScrollPopup.updateFastScrollerBounds(recyclerView, lastY));
        lastTouchY = boundedY;
      }
      break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
      touchOffset = 0;
      lastTouchY = 0;
      ignoreDragGesture = false;
      if (isDragging) {
        isDragging = false;
        fastScrollPopup.animateVisibility(false);
        recyclerView.hideScrollBar();
      }
      break;
  }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:56,代码来源:FastScrollBar.java

示例9: initViewPager

import android.view.ViewConfiguration; //导入方法依赖的package包/类
void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new ViewPager.MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the ViewPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the ViewPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since ViewPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
开发者ID:SimonCherryGZ,项目名称:JewelryUI,代码行数:77,代码来源:ViewPager.java

示例10: initViewPager

import android.view.ViewConfiguration; //导入方法依赖的package包/类
void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = configuration.getScaledPagingTouchSlop();
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                private final Rect mTempRect = new Rect();

                @Override
                public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                              final WindowInsetsCompat originalInsets) {
                    // First let the ViewPager itself try and consume them...
                    final WindowInsetsCompat applied =
                            ViewCompat.onApplyWindowInsets(v, originalInsets);
                    if (applied.isConsumed()) {
                        // If the ViewPager consumed all insets, return now
                        return applied;
                    }

                    // Now we'll manually dispatch the insets to our children. Since ViewPager
                    // children are always full-height, we do not want to use the standard
                    // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
                    // the rest of the children will not receive any insets. To workaround this
                    // we manually dispatch the applied insets, not allowing children to
                    // consume them from each other. We do however keep track of any insets
                    // which are consumed, returning the union of our children's consumption
                    final Rect res = mTempRect;
                    res.left = applied.getSystemWindowInsetLeft();
                    res.top = applied.getSystemWindowInsetTop();
                    res.right = applied.getSystemWindowInsetRight();
                    res.bottom = applied.getSystemWindowInsetBottom();

                    for (int i = 0, count = getChildCount(); i < count; i++) {
                        final WindowInsetsCompat childInsets = ViewCompat
                                .dispatchApplyWindowInsets(getChildAt(i), applied);
                        // Now keep track of any consumed by tracking each dimension's min
                        // value
                        res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
                                res.left);
                        res.top = Math.min(childInsets.getSystemWindowInsetTop(),
                                res.top);
                        res.right = Math.min(childInsets.getSystemWindowInsetRight(),
                                res.right);
                        res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
                                res.bottom);
                    }

                    // Now return a new WindowInsets, using the consumed window insets
                    return applied.replaceSystemWindowInsets(
                            res.left, res.top, res.right, res.bottom);
                }
            });
}
 
开发者ID:simplezhli,项目名称:ChangeTabLayout,代码行数:77,代码来源:VerticalViewPager.java

示例11: getScaledPagingTouchSlop

import android.view.ViewConfiguration; //导入方法依赖的package包/类
public static int getScaledPagingTouchSlop(ViewConfiguration config) {
    return config.getScaledPagingTouchSlop();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ViewConfigurationCompatFroyo.java

示例12: handleTouchEvent

import android.view.ViewConfiguration; //导入方法依赖的package包/类
/**
 * Handles the touch event and determines whether to show the fast scroller (or updates it if
 * it is already showing).
 */
public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY) {
    ViewConfiguration config = ViewConfiguration.get(mRv.getContext());

    int action = ev.getAction();
    int y = (int) ev.getY();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (isNearThumb(downX, downY)) {
                mTouchOffset = downY - mThumbOffset.y;
            }
            break;
        case MotionEvent.ACTION_MOVE:
            // Check if we should start scrolling, but ignore this fastscroll gesture if we have
            // exceeded some fixed movement
            mIgnoreDragGesture |= Math.abs(y - downY) > config.getScaledPagingTouchSlop();
            if (!mIsDragging && !mIgnoreDragGesture && mRv.supportsFastScrolling() &&
                    isNearThumb(downX, lastY) &&
                    Math.abs(y - downY) > config.getScaledTouchSlop()) {
                mRv.getParent().requestDisallowInterceptTouchEvent(true);
                mIsDragging = true;
                if (mCanThumbDetach) {
                    mIsThumbDetached = true;
                }
                mTouchOffset += (lastY - downY);
                mPopup.animateVisibility(true);
                showActiveScrollbar(true);
            }
            if (mIsDragging) {
                // Update the fastscroller section name at this touch position
                int top = mRv.getBackgroundPadding().top;
                int bottom = top + mRv.getVisibleHeight() - mThumbHeight;
                float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffset));
                String sectionName = mRv.scrollToPositionAtProgress((boundedY - top) /
                        (bottom - top));
                mPopup.setSectionName(sectionName);
                mPopup.animateVisibility(!sectionName.isEmpty());
                mRv.invalidate(mPopup.updateFastScrollerBounds(lastY));
                mLastTouchY = boundedY;
                setThumbOffset(mRv.getScrollBarX(), (int) mLastTouchY);
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mTouchOffset = 0;
            mLastTouchY = 0;
            mIgnoreDragGesture = false;
            if (mIsDragging) {
                mIsDragging = false;
                mPopup.animateVisibility(false);
                showActiveScrollbar(false);
            }
            break;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:59,代码来源:BaseRecyclerViewFastScrollBar.java

示例13: MotionIndicator

import android.view.ViewConfiguration; //导入方法依赖的package包/类
public MotionIndicator(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    touchSlop = configuration.getScaledPagingTouchSlop();
}
 
开发者ID:shuhart,项目名称:BubblePagerIndicator,代码行数:6,代码来源:MotionIndicator.java


注:本文中的android.view.ViewConfiguration.getScaledPagingTouchSlop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。