Java Code Examples for android.view.View.offsetLeftAndRight()

The following are Jave code examples for showing how to use offsetLeftAndRight() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: RX_Demo   File: ResideLayout.java   Source Code and License Vote up 6 votes
private void parallaxOtherViews(float slideOffset) {
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset &&
            (slideLp.leftMargin) <= 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View v = getChildAt(i);
        if (v == mSlideableView) continue;

        final int oldOffset = (int) ((1 - mParallaxOffset) * mParallaxBy);
        mParallaxOffset = slideOffset;
        final int newOffset = (int) ((1 - slideOffset) * mParallaxBy);
        final int dx = oldOffset - newOffset;

        v.offsetLeftAndRight(dx);

        if (dimViews) {
            dimChildView(v,
                    1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
Example 2
Project: RNLearn_Project1   File: FlatNativeViewHierarchyManager.java   Source Code and License Vote up 6 votes
/**
 * Updates View bounds, possibly re-measuring and re-layouting it if the size changed.
 *
 * @param reactTag reactTag to lookup a View by
 * @param left left coordinate relative to parent
 * @param top top coordinate relative to parent
 * @param right right coordinate relative to parent
 * @param bottom bottom coordinate relative to parent
 */
/* package */ void updateViewBounds(int reactTag, int left, int top, int right, int bottom) {
  View view = resolveView(reactTag);
  int width = right - left;
  int height = bottom - top;
  if (view.getWidth() != width || view.getHeight() != height) {
    // size changed, we need to measure and layout the View
    view.measure(
        MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    view.layout(left, top, right, bottom);
  } else {
    // same size, only location changed, there is a faster route.
    view.offsetLeftAndRight(left - view.getLeft());
    view.offsetTopAndBottom(top - view.getTop());
  }
}
 
Example 3
Project: RNLearn_Project1   File: FlatNativeViewHierarchyManager.java   Source Code and License Vote up 6 votes
/**
 * Updates View bounds, possibly re-measuring and re-layouting it if the size changed.
 *
 * @param reactTag reactTag to lookup a View by
 * @param left left coordinate relative to parent
 * @param top top coordinate relative to parent
 * @param right right coordinate relative to parent
 * @param bottom bottom coordinate relative to parent
 */
/* package */ void updateViewBounds(int reactTag, int left, int top, int right, int bottom) {
  View view = resolveView(reactTag);
  int width = right - left;
  int height = bottom - top;
  if (view.getWidth() != width || view.getHeight() != height) {
    // size changed, we need to measure and layout the View
    view.measure(
        MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
        MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
    view.layout(left, top, right, bottom);
  } else {
    // same size, only location changed, there is a faster route.
    view.offsetLeftAndRight(left - view.getLeft());
    view.offsetTopAndBottom(top - view.getTop());
  }
}
 
Example 4
Project: WechatChatroomHelper   File: BGASwipeBackLayout.java   Source Code and License Vote up 6 votes
private void parallaxOtherViews(float slideOffset) {
    final boolean isLayoutRtl = isLayoutRtlSupport();
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset
            && (isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View v = getChildAt(i);
        if (v == mSlideableView) continue;

        final int oldOffset = (int) ((1 - mParallaxOffset) * mParallaxBy);
        mParallaxOffset = slideOffset;
        final int newOffset = (int) ((1 - slideOffset) * mParallaxBy);
        final int dx = oldOffset - newOffset;

        v.offsetLeftAndRight(isLayoutRtl ? -dx : dx);

        if (dimViews) {
            dimChildView(v, isLayoutRtl ? mParallaxOffset - 1
                    : 1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
Example 5
Project: boohee_v5.6   File: CoordinatorLayout.java   Source Code and License Vote up 6 votes
void offsetChildToAnchor(View child, int layoutDirection) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    if (lp.mAnchorView != null) {
        Rect anchorRect = this.mTempRect1;
        Rect childRect = this.mTempRect2;
        Rect desiredChildRect = this.mTempRect3;
        getDescendantRect(lp.mAnchorView, anchorRect);
        getChildRect(child, false, childRect);
        getDesiredAnchoredChildRect(child, layoutDirection, anchorRect, desiredChildRect);
        int dx = desiredChildRect.left - childRect.left;
        int dy = desiredChildRect.top - childRect.top;
        if (dx != 0) {
            child.offsetLeftAndRight(dx);
        }
        if (dy != 0) {
            child.offsetTopAndBottom(dy);
        }
        if (dx != 0 || dy != 0) {
            Behavior b = lp.getBehavior();
            if (b != null) {
                b.onDependentViewChanged(this, child, lp.mAnchorView);
            }
        }
    }
}
 
Example 6
Project: WechatChatroomHelper   File: BGASwipeBackLayout2.java   Source Code and License Vote up 6 votes
private void parallaxOtherViews(float slideOffset) {
    final boolean isLayoutRtl = isLayoutRtlSupport();
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset
            && (isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View v = getChildAt(i);
        if (v == mSlideableView) continue;

        final int oldOffset = (int) ((1 - mParallaxOffset) * mParallaxBy);
        mParallaxOffset = slideOffset;
        final int newOffset = (int) ((1 - slideOffset) * mParallaxBy);
        final int dx = oldOffset - newOffset;

        v.offsetLeftAndRight(isLayoutRtl ? -dx : dx);

        if (dimViews) {
            dimChildView(v, isLayoutRtl ? mParallaxOffset - 1
                    : 1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
Example 7
Project: superglue   File: DebugDrawerLayout.java   Source Code and License Vote up 6 votes
void moveDrawerToOffset(View drawerView, float slideOffset) {
  final float oldOffset = getDrawerViewOffset(drawerView);
  final int width = drawerView.getWidth();
  final int oldPos = (int) (width * oldOffset);
  final int newPos = (int) (width * slideOffset);
  final int dx = newPos - oldPos;

  drawerView.offsetLeftAndRight(
      checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT) ? dx : -dx);
  setDrawerViewOffset(drawerView, slideOffset);
}
 
Example 8
Project: boohee_v5.6   File: ViewCompatHC.java   Source Code and License Vote up 5 votes
static void offsetLeftAndRight(View view, int offset) {
    view.offsetLeftAndRight(offset);
    ViewParent parent = view.getParent();
    if (parent instanceof View) {
        tickleInvalidationFlag((View) parent);
    }
}
 
Example 9
Project: letv   File: HListView.java   Source Code and License Vote up 5 votes
private View moveSelection(View oldSel, View newSel, int delta, int childrenLeft, int childrenRight) {
    View sel;
    int fadingEdgeLength = getHorizontalFadingEdgeLength();
    int selectedPosition = this.mSelectedPosition;
    int leftSelectionPixel = getLeftSelectionPixel(childrenLeft, fadingEdgeLength, selectedPosition);
    int rightSelectionPixel = getRightSelectionPixel(childrenLeft, fadingEdgeLength, selectedPosition);
    int halfHorizontalSpace;
    if (delta > 0) {
        oldSel = makeAndAddView(selectedPosition - 1, oldSel.getLeft(), true, this.mListPadding.top, false);
        int dividerWidth = this.mDividerWidth;
        sel = makeAndAddView(selectedPosition, oldSel.getRight() + dividerWidth, true, this.mListPadding.top, true);
        if (sel.getRight() > rightSelectionPixel) {
            halfHorizontalSpace = (childrenRight - childrenLeft) / 2;
            int offset = Math.min(Math.min(sel.getLeft() - leftSelectionPixel, sel.getRight() - rightSelectionPixel), halfHorizontalSpace);
            oldSel.offsetLeftAndRight(-offset);
            sel.offsetLeftAndRight(-offset);
        }
        if (this.mStackFromRight) {
            fillRight(this.mSelectedPosition + 1, sel.getRight() + dividerWidth);
            adjustViewsLeftOrRight();
            fillLeft(this.mSelectedPosition - 2, sel.getLeft() - dividerWidth);
        } else {
            fillLeft(this.mSelectedPosition - 2, sel.getLeft() - dividerWidth);
            adjustViewsLeftOrRight();
            fillRight(this.mSelectedPosition + 1, sel.getRight() + dividerWidth);
        }
    } else if (delta < 0) {
        if (newSel != null) {
            sel = makeAndAddView(selectedPosition, newSel.getLeft(), true, this.mListPadding.top, true);
        } else {
            sel = makeAndAddView(selectedPosition, oldSel.getLeft(), false, this.mListPadding.top, true);
        }
        if (sel.getLeft() < leftSelectionPixel) {
            halfHorizontalSpace = (childrenRight - childrenLeft) / 2;
            View view = sel;
            view.offsetLeftAndRight(Math.min(Math.min(leftSelectionPixel - sel.getLeft(), rightSelectionPixel - sel.getRight()), halfHorizontalSpace));
        }
        fillBeforeAndAfter(sel, selectedPosition);
    } else {
        int oldLeft = oldSel.getLeft();
        sel = makeAndAddView(selectedPosition, oldLeft, true, this.mListPadding.top, true);
        if (oldLeft < childrenLeft && sel.getRight() < childrenLeft + 20) {
            sel.offsetLeftAndRight(childrenLeft - sel.getLeft());
        }
        fillBeforeAndAfter(sel, selectedPosition);
    }
    return sel;
}
 
Example 10
Project: letv   File: HListView.java   Source Code and License Vote up 5 votes
@TargetApi(11)
private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, boolean selected, boolean recycled) {
    boolean isSelected = selected && shouldShowSelector();
    boolean updateChildSelected = isSelected != child.isSelected();
    int mode = this.mTouchMode;
    boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
    boolean updateChildPressed = isPressed != child.isPressed();
    boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        p = (LayoutParams) generateDefaultLayoutParams();
    }
    p.viewType = this.mAdapter.getItemViewType(position);
    if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
        p.forceAdd = false;
        if (p.viewType == -2) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    } else {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (!(this.mChoiceMode == 0 || this.mCheckStates == null)) {
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        } else if (VERSION.SDK_INT >= 11) {
            child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        }
    }
    if (needToMeasure) {
        int childWidthSpec;
        int childHeightSpec = ViewGroup.getChildMeasureSpec(this.mHeightMeasureSpec, this.mListPadding.top + this.mListPadding.bottom, p.height);
        int lpWidth = p.width;
        if (lpWidth > 0) {
            childWidthSpec = MeasureSpec.makeMeasureSpec(lpWidth, 1073741824);
        } else {
            childWidthSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        child.measure(childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childLeft = flowDown ? x : x - w;
    if (needToMeasure) {
        child.layout(childLeft, childrenTop, childLeft + w, childrenTop + h);
    } else {
        child.offsetLeftAndRight(childLeft - child.getLeft());
        child.offsetTopAndBottom(childrenTop - child.getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
    if (VERSION.SDK_INT >= 11 && recycled && ((LayoutParams) child.getLayoutParams()).scrappedFromPosition != position) {
        child.jumpDrawablesToCurrentState();
    }
}
 
Example 11
Project: Glitchy   File: SideMenu.java   Source Code and License Vote up 5 votes
private void parallaxOtherViews(float slideOffset) {
    final boolean isLayoutRtl = isLayoutRtlSupport();
    final LayoutParams slideLp = (LayoutParams) mSlideableView.getLayoutParams();
    final boolean dimViews = slideLp.dimWhenOffset &&
            (isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View v = getChildAt(i);
        if (v == mSlideableView) continue;

        //////
        mBottomView = v;
        /////

        final int oldOffset = (int) ((1 - mParallaxOffset) * mParallaxBy);
        mParallaxOffset = slideOffset;
        final int newOffset = (int) ((1 - slideOffset) * mParallaxBy);
        final int dx = oldOffset - newOffset;

        v.offsetLeftAndRight(isLayoutRtl ? -dx : dx);

        if (dimViews) {
            dimChildView(v, isLayoutRtl ? mParallaxOffset - 1 :
                    1 - mParallaxOffset, mCoveredFadeColor);
        }
    }
}
 
Example 12
Project: letv   File: DrawerLayout.java   Source Code and License Vote up 5 votes
void moveDrawerToOffset(View drawerView, float slideOffset) {
    float oldOffset = getDrawerViewOffset(drawerView);
    int width = drawerView.getWidth();
    int dx = ((int) (((float) width) * slideOffset)) - ((int) (((float) width) * oldOffset));
    if (!checkDrawerViewAbsoluteGravity(drawerView, 3)) {
        dx = -dx;
    }
    drawerView.offsetLeftAndRight(dx);
    setDrawerViewOffset(drawerView, slideOffset);
}
 
Example 13
Project: cardslider-android   File: CardSliderLayoutManager.java   Source Code and License Vote up 5 votes
private int scrollLeft(int dx) {
    final int childCount = getChildCount();
    if (childCount == 0) {
        return 0;
    }

    final View lastView = getChildAt(childCount - 1);
    final boolean isLastItem = getPosition(lastView) == getItemCount() - 1;

    final int delta;
    if (isLastItem) {
        delta = Math.min(dx, getDecoratedRight(lastView) - activeCardRight);
    } else {
        delta = dx;
    }

    final int step = activeCardLeft / LEFT_CARD_COUNT;
    final int jDelta = (int) Math.ceil(1f * delta * step / cardWidth);

    for (int i = childCount - 1; i >= 0; i--) {
        final View view = getChildAt(i);
        final int viewLeft = getDecoratedLeft(view);

        if (viewLeft > activeCardLeft) {
            view.offsetLeftAndRight(getAllowedLeftDelta(view, delta, activeCardLeft));
        } else {
            int border = activeCardLeft - step;
            for (int j = i; j >= 0; j--) {
                final View jView = getChildAt(j);
                jView.offsetLeftAndRight(getAllowedLeftDelta(jView, jDelta, border));
                border -= step;
            }

            break;
        }
    }

    return delta;
}
 
Example 14
Project: boohee_v5.6   File: DrawerLayout.java   Source Code and License Vote up 5 votes
void moveDrawerToOffset(View drawerView, float slideOffset) {
    float oldOffset = getDrawerViewOffset(drawerView);
    int width = drawerView.getWidth();
    int dx = ((int) (((float) width) * slideOffset)) - ((int) (((float) width) * oldOffset));
    if (!checkDrawerViewAbsoluteGravity(drawerView, 3)) {
        dx = -dx;
    }
    drawerView.offsetLeftAndRight(dx);
    setDrawerViewOffset(drawerView, slideOffset);
}
 
Example 15
Project: boohee_v5.6   File: StaggeredGridLayoutManager.java   Source Code and License Vote up 4 votes
private void repositionToWrapContentIfNecessary() {
    if (this.mSecondaryOrientation.getMode() != 1073741824) {
        int i;
        View child;
        float maxSize = 0.0f;
        int childCount = getChildCount();
        for (i = 0; i < childCount; i++) {
            child = getChildAt(i);
            float size = (float) this.mSecondaryOrientation.getDecoratedMeasurement(child);
            if (size >= maxSize) {
                if (((LayoutParams) child.getLayoutParams()).isFullSpan()) {
                    size = (1.0f * size) / ((float) this.mSpanCount);
                }
                maxSize = Math.max(maxSize, size);
            }
        }
        int before = this.mSizePerSpan;
        int desired = Math.round(((float) this.mSpanCount) * maxSize);
        if (this.mSecondaryOrientation.getMode() == Integer.MIN_VALUE) {
            desired = Math.min(desired, this.mSecondaryOrientation.getTotalSpace());
        }
        updateMeasureSpecs(desired);
        if (this.mSizePerSpan != before) {
            for (i = 0; i < childCount; i++) {
                child = getChildAt(i);
                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (!lp.mFullSpan) {
                    if (isLayoutRTL() && this.mOrientation == 1) {
                        child.offsetLeftAndRight(((-((this.mSpanCount - 1) - lp.mSpan.mIndex)) * this.mSizePerSpan) - ((-((this.mSpanCount - 1) - lp.mSpan.mIndex)) * before));
                    } else {
                        int newOffset = lp.mSpan.mIndex * this.mSizePerSpan;
                        int prevOffset = lp.mSpan.mIndex * before;
                        if (this.mOrientation == 1) {
                            child.offsetLeftAndRight(newOffset - prevOffset);
                        } else {
                            child.offsetTopAndBottom(newOffset - prevOffset);
                        }
                    }
                }
            }
        }
    }
}
 
Example 16
Project: Swap   File: PLA_ListView.java   Source Code and License Vote up 4 votes
protected void onOffsetChild(View child, int position, int offsetLeft, int offsetTop) {
    child.offsetLeftAndRight(offsetLeft);
    child.offsetTopAndBottom(offsetTop);
}
 
Example 17
Project: boohee_v5.6   File: ViewPager.java   Source Code and License Vote up 4 votes
@CallSuper
protected void onPageScrolled(int position, float offset, int offsetPixels) {
    int scrollX;
    int childCount;
    int i;
    View child;
    if (this.mDecorChildCount > 0) {
        scrollX = getScrollX();
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        int width = getWidth();
        childCount = getChildCount();
        for (i = 0; i < childCount; i++) {
            child = getChildAt(i);
            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp.isDecor) {
                int childLeft;
                switch (lp.gravity & 7) {
                    case 1:
                        childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft);
                        break;
                    case 3:
                        childLeft = paddingLeft;
                        paddingLeft += child.getWidth();
                        break;
                    case 5:
                        childLeft = (width - paddingRight) - child.getMeasuredWidth();
                        paddingRight += child.getMeasuredWidth();
                        break;
                    default:
                        childLeft = paddingLeft;
                        break;
                }
                int childOffset = (childLeft + scrollX) - child.getLeft();
                if (childOffset != 0) {
                    child.offsetLeftAndRight(childOffset);
                }
            }
        }
    }
    dispatchOnPageScrolled(position, offset, offsetPixels);
    if (this.mPageTransformer != null) {
        scrollX = getScrollX();
        childCount = getChildCount();
        for (i = 0; i < childCount; i++) {
            child = getChildAt(i);
            if (!((LayoutParams) child.getLayoutParams()).isDecor) {
                this.mPageTransformer.transformPage(child, ((float) (child.getLeft() - scrollX)) / ((float) getClientWidth()));
            }
        }
    }
    this.mCalledSuper = true;
}
 
Example 18
Project: letv   File: StaggeredGridLayoutManager.java   Source Code and License Vote up 4 votes
private void repositionToWrapContentIfNecessary() {
    if (this.mSecondaryOrientation.getMode() != 1073741824) {
        int i;
        View child;
        float maxSize = 0.0f;
        int childCount = getChildCount();
        for (i = 0; i < childCount; i++) {
            child = getChildAt(i);
            float size = (float) this.mSecondaryOrientation.getDecoratedMeasurement(child);
            if (size >= maxSize) {
                if (((LayoutParams) child.getLayoutParams()).isFullSpan()) {
                    size = (1.0f * size) / ((float) this.mSpanCount);
                }
                maxSize = Math.max(maxSize, size);
            }
        }
        int before = this.mSizePerSpan;
        int desired = Math.round(((float) this.mSpanCount) * maxSize);
        if (this.mSecondaryOrientation.getMode() == Integer.MIN_VALUE) {
            desired = Math.min(desired, this.mSecondaryOrientation.getTotalSpace());
        }
        updateMeasureSpecs(desired);
        if (this.mSizePerSpan != before) {
            for (i = 0; i < childCount; i++) {
                child = getChildAt(i);
                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (!lp.mFullSpan) {
                    if (isLayoutRTL() && this.mOrientation == 1) {
                        child.offsetLeftAndRight(((-((this.mSpanCount - 1) - lp.mSpan.mIndex)) * this.mSizePerSpan) - ((-((this.mSpanCount - 1) - lp.mSpan.mIndex)) * before));
                    } else {
                        int newOffset = lp.mSpan.mIndex * this.mSizePerSpan;
                        int prevOffset = lp.mSpan.mIndex * before;
                        if (this.mOrientation == 1) {
                            child.offsetLeftAndRight(newOffset - prevOffset);
                        } else {
                            child.offsetTopAndBottom(newOffset - prevOffset);
                        }
                    }
                }
            }
        }
    }
}
 
Example 19
Project: boohee_v5.6   File: SlidingPaneLayout.java   Source Code and License Vote up 4 votes
private void parallaxOtherViews(float slideOffset) {
    boolean dimViews;
    int childCount;
    int i;
    View v;
    int dx;
    boolean isLayoutRtl = isLayoutRtlSupport();
    LayoutParams slideLp = (LayoutParams) this.mSlideableView.getLayoutParams();
    if (slideLp.dimWhenOffset) {
        if ((isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0) {
            dimViews = true;
            childCount = getChildCount();
            for (i = 0; i < childCount; i++) {
                v = getChildAt(i);
                if (v == this.mSlideableView) {
                    int oldOffset = (int) ((1.0f - this.mParallaxOffset) * ((float) this.mParallaxBy));
                    this.mParallaxOffset = slideOffset;
                    dx = oldOffset - ((int) ((1.0f - slideOffset) * ((float) this.mParallaxBy)));
                    if (isLayoutRtl) {
                        dx = -dx;
                    }
                    v.offsetLeftAndRight(dx);
                    if (!dimViews) {
                        dimChildView(v, isLayoutRtl ? this.mParallaxOffset - 1.0f : 1.0f - this.mParallaxOffset, this.mCoveredFadeColor);
                    }
                }
            }
        }
    }
    dimViews = false;
    childCount = getChildCount();
    for (i = 0; i < childCount; i++) {
        v = getChildAt(i);
        if (v == this.mSlideableView) {
            int oldOffset2 = (int) ((1.0f - this.mParallaxOffset) * ((float) this.mParallaxBy));
            this.mParallaxOffset = slideOffset;
            dx = oldOffset2 - ((int) ((1.0f - slideOffset) * ((float) this.mParallaxBy)));
            if (isLayoutRtl) {
                dx = -dx;
            }
            v.offsetLeftAndRight(dx);
            if (!dimViews) {
                if (isLayoutRtl) {
                }
                dimChildView(v, isLayoutRtl ? this.mParallaxOffset - 1.0f : 1.0f - this.mParallaxOffset, this.mCoveredFadeColor);
            }
        }
    }
}
 
Example 20
Project: letv   File: SlidingPaneLayout.java   Source Code and License Vote up 4 votes
private void parallaxOtherViews(float slideOffset) {
    boolean dimViews;
    int childCount;
    int i;
    View v;
    int dx;
    boolean isLayoutRtl = isLayoutRtlSupport();
    LayoutParams slideLp = (LayoutParams) this.mSlideableView.getLayoutParams();
    if (slideLp.dimWhenOffset) {
        if ((isLayoutRtl ? slideLp.rightMargin : slideLp.leftMargin) <= 0) {
            dimViews = true;
            childCount = getChildCount();
            for (i = 0; i < childCount; i++) {
                v = getChildAt(i);
                if (v == this.mSlideableView) {
                    int oldOffset = (int) ((1.0f - this.mParallaxOffset) * ((float) this.mParallaxBy));
                    this.mParallaxOffset = slideOffset;
                    dx = oldOffset - ((int) ((1.0f - slideOffset) * ((float) this.mParallaxBy)));
                    if (isLayoutRtl) {
                        dx = -dx;
                    }
                    v.offsetLeftAndRight(dx);
                    if (!dimViews) {
                        dimChildView(v, isLayoutRtl ? this.mParallaxOffset - 1.0f : 1.0f - this.mParallaxOffset, this.mCoveredFadeColor);
                    }
                }
            }
        }
    }
    dimViews = false;
    childCount = getChildCount();
    for (i = 0; i < childCount; i++) {
        v = getChildAt(i);
        if (v == this.mSlideableView) {
            int oldOffset2 = (int) ((1.0f - this.mParallaxOffset) * ((float) this.mParallaxBy));
            this.mParallaxOffset = slideOffset;
            dx = oldOffset2 - ((int) ((1.0f - slideOffset) * ((float) this.mParallaxBy)));
            if (isLayoutRtl) {
                dx = -dx;
            }
            v.offsetLeftAndRight(dx);
            if (!dimViews) {
                if (isLayoutRtl) {
                }
                dimChildView(v, isLayoutRtl ? this.mParallaxOffset - 1.0f : 1.0f - this.mParallaxOffset, this.mCoveredFadeColor);
            }
        }
    }
}