Java Code Examples for android.support.v4.view.ViewCompat#offsetLeftAndRight()

The following examples show how to use android.support.v4.view.ViewCompat#offsetLeftAndRight() . 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: ViewDragHelper.java    From letv with Apache License 2.0 6 votes vote down vote up
private void dragTo(int left, int top, int dx, int dy) {
    int clampedX = left;
    int clampedY = top;
    int oldLeft = this.mCapturedView.getLeft();
    int oldTop = this.mCapturedView.getTop();
    if (dx != 0) {
        clampedX = this.mCallback.clampViewPositionHorizontal(this.mCapturedView, left, dx);
        ViewCompat.offsetLeftAndRight(this.mCapturedView, clampedX - oldLeft);
    }
    if (dy != 0) {
        clampedY = this.mCallback.clampViewPositionVertical(this.mCapturedView, top, dy);
        ViewCompat.offsetTopAndBottom(this.mCapturedView, clampedY - oldTop);
    }
    if (dx != 0 || dy != 0) {
        this.mCallback.onViewPositionChanged(this.mCapturedView, clampedX, clampedY, clampedX - oldLeft, clampedY - oldTop);
    }
}
 
Example 2
Source File: ViewDragHelper.java    From SwipeBack with Apache License 2.0 6 votes vote down vote up
private void dragTo(int left, int top, int dx, int dy) {
    int clampedX = left;
    int clampedY = top;
    final int oldLeft = mCapturedView.getLeft();
    final int oldTop = mCapturedView.getTop();
    if (dx != 0) {
        clampedX = mCallback.clampViewPositionHorizontal(mCapturedView, left, dx);
        ViewCompat.offsetLeftAndRight(mCapturedView, clampedX - oldLeft);
    }
    if (dy != 0) {
        clampedY = mCallback.clampViewPositionVertical(mCapturedView, top, dy);
        ViewCompat.offsetTopAndBottom(mCapturedView, clampedY - oldTop);
    }

    if (dx != 0 || dy != 0) {
        final int clampedDx = clampedX - oldLeft;
        final int clampedDy = clampedY - oldTop;
        mCallback.onViewPositionChanged(mCapturedView, clampedX, clampedY,
                clampedDx, clampedDy);
    }
}
 
Example 3
Source File: ViewOffsetHelper.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 4
Source File: ViewOffsetHelper.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 5
Source File: ViewOffsetHelper.java    From AppCompat-Extension-Library with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 6
Source File: ViewDragHelper.java    From SwipeBack with Apache License 2.0 5 votes vote down vote up
/**
 * Move the captured settling view by the appropriate amount for the current time.
 * If <code>continueSettling</code> returns true, the caller should call it again
 * on the next frame to continue.
 *
 * @param deferCallbacks true if state callbacks should be deferred via posted message.
 *                       Set this to true if you are calling this method from
 *                       {@link android.view.View#computeScroll()} or similar methods
 *                       invoked as part of layout or drawing.
 * @return true if settle is still in progress
 */
public boolean continueSettling(boolean deferCallbacks) {
    if (mDragState == STATE_SETTLING) {
        boolean keepGoing = mScroller.computeScrollOffset();
        final int x = mScroller.getCurrX();
        final int y = mScroller.getCurrY();
        final int dx = x - mCapturedView.getLeft();
        final int dy = y - mCapturedView.getTop();

        if (dx != 0) {
            ViewCompat.offsetLeftAndRight(mCapturedView, dx);
        }
        if (dy != 0) {
            ViewCompat.offsetTopAndBottom(mCapturedView, dy);
        }

        if (dx != 0 || dy != 0) {
            mCallback.onViewPositionChanged(mCapturedView, x, y, dx, dy);
        }

        if (keepGoing && x == mScroller.getFinalX() && y == mScroller.getFinalY()) {
            // Close enough. The interpolator/scroller might think we're still moving
            // but the user sure doesn't.
            mScroller.abortAnimation();
            keepGoing = false;
        }

        if (!keepGoing) {
            if (deferCallbacks) {
                mParentView.post(mSetIdleRunnable);
            } else {
                setDragState(STATE_IDLE);
            }
        }
    }

    return mDragState == STATE_SETTLING;
}
 
Example 7
Source File: ViewOffsetHelper.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 8
Source File: ViewOffsetHelper.java    From SpringHeader with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 9
Source File: ViewOffsetHelper.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 10
Source File: ViewOffsetHelper.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 11
Source File: ViewOffsetHelper.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
private void updateOffsets(boolean isTopAndBottom) {
    if (isTopAndBottom) {
        ViewCompat.offsetTopAndBottom(mTarget, mOffsetTop - mTarget.getTop());
    }else {
        ViewCompat.offsetLeftAndRight(mTarget, mOffsetLeft - mTarget.getLeft());
    }
}
 
Example 12
Source File: ViewOffsetHelper.java    From UcMainPagerDemo with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 13
Source File: ViewDragHelper.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean continueSettling(boolean deferCallbacks) {
    if (this.mDragState == 2) {
        boolean keepGoing = this.mScroller.computeScrollOffset();
        int x = this.mScroller.getCurrX();
        int y = this.mScroller.getCurrY();
        int dx = x - this.mCapturedView.getLeft();
        int dy = y - this.mCapturedView.getTop();
        if (dx != 0) {
            ViewCompat.offsetLeftAndRight(this.mCapturedView, dx);
        }
        if (dy != 0) {
            ViewCompat.offsetTopAndBottom(this.mCapturedView, dy);
        }
        if (!(dx == 0 && dy == 0)) {
            this.mCallback.onViewPositionChanged(this.mCapturedView, x, y, dx, dy);
        }
        if (keepGoing && x == this.mScroller.getFinalX() && y == this.mScroller.getFinalY()) {
            this.mScroller.abortAnimation();
            keepGoing = false;
        }
        if (!keepGoing) {
            if (deferCallbacks) {
                this.mParentView.post(this.mSetIdleRunnable);
            } else {
                setDragState(0);
            }
        }
    }
    return this.mDragState == 2;
}
 
Example 14
Source File: HTHorizontalLeftRecyclerViewImpl.java    From ht-refreshrecyclerview with MIT License 4 votes vote down vote up
public void performUpdateViewPosition(int offset) {
    ViewCompat.offsetLeftAndRight(mRefreshContainerView, -offset);
    ViewCompat.offsetLeftAndRight(mRecyclerView, -offset);
    invalidate();
}
 
Example 15
Source File: HTHorizontalRightRecyclerViewImpl.java    From ht-refreshrecyclerview with MIT License 4 votes vote down vote up
public void performUpdateViewPosition(int offset) {
    ViewCompat.offsetLeftAndRight(mRefreshContainerView,offset);
    ViewCompat.offsetLeftAndRight(mRecyclerView,offset);
    invalidate();
}
 
Example 16
Source File: ViewOffsetHelper.java    From android-proguards with Apache License 2.0 4 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
Example 17
Source File: ViewOffsetHelper.java    From GpCollapsingToolbar with Apache License 2.0 4 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
Example 18
Source File: ViewOffsetHelper.java    From BehaviorDemo with Apache License 2.0 4 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}
 
Example 19
Source File: ViewOffsetHelper.java    From UCMainViewForBehavior with Apache License 2.0 4 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
}