Example usage for android.view View getBottom

List of usage examples for android.view View getBottom

Introduction

In this page you can find the example usage for android.view View getBottom.

Prototype

@ViewDebug.CapturedViewProperty
public final int getBottom() 

Source Link

Document

Bottom position of this view relative to its parent.

Usage

From source file:com.cdwx.moka.widget.SwipeRefreshLayout.java

public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
            if (lastChild != null) {
                return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1))
                        && lastChild.getBottom() > absListView.getPaddingBottom();
            } else {
                return false;
            }//from   w  ww .  j a v  a 2 s. c  om
        } else {
            return mTarget.getHeight() - mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}

From source file:com.hynet.mergepay.components.widget.panellayout.ViewDragHelper.java

public boolean isViewUnder(View view, int x, int y) {
    if (view == null) {
        return false;
    }//from  www .j  av  a2 s .  co  m
    return x >= view.getLeft() && x < view.getRight() && y >= view.getTop() && y < view.getBottom();
}

From source file:com.kindleren.kandouwo.common.views.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;//  w  w w.ja va  2  s.  c  om
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    //change alpha
    if (indicatorDrawable != null) {
        ((TextView) currentTab)
                .setTextColor(tabTextColor.withAlpha((int) (500 * Math.abs(currentPositionOffset - 0.5))));
    }
    currentTab.setSelected(true);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();
    float lineTop = currentTab.getTop();
    float lineBottom = currentTab.getBottom();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset >= 0f && currentPosition < tabCount - 1) {
        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        //change alpha
        if (indicatorDrawable != null) {
            ((TextView) nextTab)
                    .setTextColor(tabTextColor.withAlpha((int) (500 * Math.abs(currentPositionOffset - 0.5))));
        }
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);

        //change view state
        if (currentPositionOffset > 0.5) {
            currentTab.setSelected(false);
            nextTab.setSelected(true);
        } else {
            currentTab.setSelected(true);
            nextTab.setSelected(false);
        }
    }
    rectPaint.setColor(underlineColor);
    if (indicatorDrawable != null) {
        indicatorDrawable.setBounds((int) lineLeft + getPaddingLeft(), (int) lineTop + getPaddingTop(),
                (int) lineRight + getPaddingLeft(), (int) lineBottom + getPaddingTop());
        indicatorDrawable.draw(canvas);
    } else {
        canvas.drawRect(lineLeft + 30, height - indicatorHeight, lineRight - 30, height, rectPaint);
    }

    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw divider

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }
}

From source file:com.hynet.mergepay.components.widget.panellayout.ViewDragHelper.java

protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }//from   www.j a  v a 2 s . com
        }
    }

    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}

From source file:com.recyclerviewpulldownrefresh.view.refresh.AbPullToRefreshView.java

/**
 * ??/*from   w  ww.j  a v  a  2  s .  c  o m*/
 *
 * @return
 */
public boolean canChildScrollDown() {
    if (!mEnableLoadMore) {
        return false;
    }
    if (mTarget instanceof AdapterView<?>) {
        AdapterView<?> absListView = (AdapterView<?>) mTarget;
        View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
        if (lastChild == null) {
            return true;
        }
        // ??viewBottom?ViewmAdapterView?view,
        // ViewmAdapterView??
        if (lastChild.getBottom() <= getHeight()
                && absListView.getLastVisiblePosition() == absListView.getCount() - 1) {
            return true;
        }
    } else if (mTarget instanceof WebView) {
        WebView webview = (WebView) mTarget;
        return webview.getContentHeight() * webview.getScale() <= webview.getHeight() + webview.getScrollY();
    } else if (mTarget instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) mTarget;
        View childView = scrollView.getChildAt(0);
        if (childView != null) {
            return childView.getMeasuredHeight() <= getHeight() + mScrollView.getScrollY();
        }
    } else if (mTarget instanceof RecyclerView) {
        int lastVisiblePosition = 0;
        View childView = null;

        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();

        if (layoutManager instanceof LinearLayoutManager) {
            lastVisiblePosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
            childView = layoutManager.findViewByPosition(lastVisiblePosition);
        } else if (layoutManager instanceof GridLayoutManager) {
            lastVisiblePosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
            childView = layoutManager.findViewByPosition(lastVisiblePosition);
        } else if (layoutManager instanceof StaggeredGridLayoutManager) {
            int[] spanPosition = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()];
            ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(spanPosition);
            lastVisiblePosition = getLastVisibleItemPosition(spanPosition);
            childView = getLastVisibleItemBottomView(layoutManager, spanPosition, lastVisiblePosition);
        }
        if (null == childView) {
            return false;
        }

        if (lastVisiblePosition == layoutManager.getItemCount() - 1 && childView.getBottom()
                + layoutManager.getBottomDecorationHeight(childView) <= mTarget.getBottom()) {
            return true;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
    return false;
}

From source file:de.dreier.mytargets.utils.DividerItemDecoration.java

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mDivider == null) {
        super.onDrawOver(c, parent, state);
        return;//  w w w.j  a v a  2  s .  c  o  m
    }

    // Initialization needed to avoid compiler warning
    int left = 0;
    int right = 0;
    int top = 0;
    int bottom = 0;
    int size;
    int orientation = mOrientation != -1 ? mOrientation : getOrientation(parent);
    int childCount = parent.getChildCount();

    if (orientation == LinearLayoutManager.VERTICAL) {
        size = mDivider.getIntrinsicHeight();
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
    } else { //horizontal
        size = mDivider.getIntrinsicWidth();
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
    }

    for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getTop() - params.topMargin - size;
            bottom = top + size;
        } else { //horizontal
            left = child.getLeft() - params.leftMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }

    // show last divider
    if (mShowLastDivider && childCount > 0) {
        View child = parent.getChildAt(childCount - 1);
        if (parent.getChildAdapterPosition(child) == (state.getItemCount() - 1)) {
            RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
            if (orientation == LinearLayoutManager.VERTICAL) {
                top = child.getBottom() + params.bottomMargin;
                bottom = top + size;
            } else { // horizontal
                left = child.getRight() + params.rightMargin;
                right = left + size;
            }
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }
}

From source file:com.andrada.sitracker.ui.fragment.PublicationInfoFragment.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override/*from   w w w .  ja va  2 s . com*/
public void onScrollChanged(int deltaX, int deltaY) {
    final BaseActivity activity = (BaseActivity) getActivity();
    if (activity == null) {
        return;
    }

    // Reposition the header bar -- it's normally anchored to the top of the content,
    // but locks to the top of the screen on scroll
    int scrollY = mScrollView.getScrollY();

    if (!rateShowcaseShown && mRatingVisible && delayedScrollCheck) {
        //Check for bottom scroll
        //Showcase if bottom
        View view = mScrollView.getChildAt(mScrollView.getChildCount() - 1);
        int diff = (view.getBottom() - (mScrollView.getHeight() + mScrollView.getScrollY()));
        if (diff <= 0) {
            attemptToShowShowcaseForRatings();
        }
    }

    newTop = Math.max(mPhotoHeightPixels, scrollY + mHeaderTopClearance);

    if (UIUtils.hasHoneycombMR1()) {
        mHeaderBox.setTranslationY(newTop);
        mReadPubButton.setTranslationY(newTop + mHeaderHeightPixels - mReadPubButtonHeightPixels / 2);
        mHeaderBackgroundBox.setPivotY(mHeaderHeightPixels);
    } else {
        ViewHelper.setTranslationY(mHeaderBox, newTop);

        //TODO get rid of this on next release with API 14
        ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) mReadPubButton.getLayoutParams();
        if (mlp.topMargin != Math.round(newTop + mHeaderHeightPixels - mReadPubButtonHeightPixels / 2)) {
            mlp.topMargin = Math.round(newTop + mHeaderHeightPixels - mReadPubButtonHeightPixels / 2);
            mReadPubButton.setLayoutParams(mlp);
        }
        ViewHelper.setPivotY(mHeaderBackgroundBox, mHeaderHeightPixels);
    }
    int gapFillDistance = (int) (mHeaderTopClearance * GAP_FILL_DISTANCE_MULTIPLIER);
    boolean showGapFill = !mHasPhoto || (scrollY > (mPhotoHeightPixels - gapFillDistance));
    float desiredHeaderScaleY = showGapFill
            ? ((mHeaderHeightPixels + gapFillDistance + 1) * 1f / mHeaderHeightPixels)
            : 1f;

    if (!mHasPhoto) {
        if (UIUtils.hasHoneycombMR1()) {
            mHeaderBackgroundBox.setScaleY(desiredHeaderScaleY);
        } else {
            ViewHelper.setScaleY(mHeaderBackgroundBox, desiredHeaderScaleY);
        }
    } else if (mGapFillShown != showGapFill) {
        if (UIUtils.hasICS()) {
            mHeaderBackgroundBox.animate().scaleY(desiredHeaderScaleY)
                    .setInterpolator(new DecelerateInterpolator(2f)).setDuration(250).start();
        } else {
            //TODO get rid of this on next release with API 14
            animate(mHeaderBackgroundBox).scaleY(desiredHeaderScaleY)
                    .setInterpolator(new DecelerateInterpolator(2f)).setDuration(250);
        }
    }
    mGapFillShown = showGapFill;

    mHeaderShadow.setVisibility(View.VISIBLE);

    if (mHeaderTopClearance != 0) {
        // Fill the gap between status bar and header bar with color
        float gapFillProgress = Math.min(Math.max(UIUtils.getProgress(scrollY,
                mPhotoHeightPixels - mHeaderTopClearance * 2, mPhotoHeightPixels - mHeaderTopClearance), 0), 1);
        if (UIUtils.hasHoneycombMR1()) {
            mHeaderShadow.setAlpha(gapFillProgress);
        } else {
            ViewHelper.setAlpha(mHeaderShadow, gapFillProgress);
        }
    }

    // Move background photo (parallax effect)
    if (UIUtils.hasHoneycombMR1()) {
        mPhotoViewContainer.setTranslationY(scrollY * 0.3f);
    } else {
        //TODO get rid of this on next release with API 14
        ViewHelper.setTranslationY(mPhotoViewContainer, scrollY * 0.3f);
    }

}

From source file:com.limxing.library.PullToRefresh.SwipeRefreshLayout.java

/**
 * @return Whether it is possible for the child view of this layout to
 *         scroll down. Override this if the child view is a custom view.
 *//* ww  w  . j  av a  2s  .  com*/
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);

            if (lastChild != null) {
                if ((absListView.getLastVisiblePosition() == (absListView.getCount() - 1))
                        && lastChild.getBottom() >= absListView.getPaddingBottom()) {
                    return false;
                }
                return true;
            } else {
                return false;
            }
        } else {
            return mTarget.getHeight() - mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}

From source file:com.facebook.litho.MountState.java

private static void mountViewIncrementally(View view, Rect localVisibleRect) {
    assertMainThread();//from   ww  w  . ja v  a 2s.co m

    if (view instanceof LithoView) {
        final LithoView lithoView = (LithoView) view;
        lithoView.performIncrementalMount(localVisibleRect);
    } else if (view instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) view;

        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            final View childView = viewGroup.getChildAt(i);

            if (localVisibleRect.intersects(childView.getLeft(), childView.getTop(), childView.getRight(),
                    childView.getBottom())) {
                final Rect rect = ComponentsPools.acquireRect();
                rect.set(Math.max(0, localVisibleRect.left - childView.getLeft()),
                        Math.max(0, localVisibleRect.top - childView.getTop()),
                        childView.getWidth() - Math.max(0, childView.getRight() - localVisibleRect.right),
                        childView.getHeight() - Math.max(0, childView.getBottom() - localVisibleRect.bottom));

                mountViewIncrementally(childView, rect);

                ComponentsPools.release(rect);
            }
        }
    }
}

From source file:android.support.car.app.CarFragmentActivity.java

private static String viewToString(View view) {
    StringBuilder out = new StringBuilder(128);
    out.append(view.getClass().getName());
    out.append('{');
    out.append(Integer.toHexString(System.identityHashCode(view)));
    out.append(' ');
    switch (view.getVisibility()) {
    case View.VISIBLE:
        out.append('V');
        break;/* w  w  w .  ja v a 2s .  com*/
    case View.INVISIBLE:
        out.append('I');
        break;
    case View.GONE:
        out.append('G');
        break;
    default:
        out.append('.');
        break;
    }
    out.append(view.isFocusable() ? 'F' : '.');
    out.append(view.isEnabled() ? 'E' : '.');
    out.append(view.willNotDraw() ? '.' : 'D');
    out.append(view.isHorizontalScrollBarEnabled() ? 'H' : '.');
    out.append(view.isVerticalScrollBarEnabled() ? 'V' : '.');
    out.append(view.isClickable() ? 'C' : '.');
    out.append(view.isLongClickable() ? 'L' : '.');
    out.append(' ');
    out.append(view.isFocused() ? 'F' : '.');
    out.append(view.isSelected() ? 'S' : '.');
    out.append(view.isPressed() ? 'P' : '.');
    out.append(' ');
    out.append(view.getLeft());
    out.append(',');
    out.append(view.getTop());
    out.append('-');
    out.append(view.getRight());
    out.append(',');
    out.append(view.getBottom());
    final int id = view.getId();
    if (id != View.NO_ID) {
        out.append(" #");
        out.append(Integer.toHexString(id));
        final Resources r = view.getResources();
        if (id != 0 && r != null) {
            try {
                String pkgname;
                switch (id & 0xff000000) {
                case 0x7f000000:
                    pkgname = "app";
                    break;
                case 0x01000000:
                    pkgname = "android";
                    break;
                default:
                    pkgname = r.getResourcePackageName(id);
                    break;
                }
                String typename = r.getResourceTypeName(id);
                String entryname = r.getResourceEntryName(id);
                out.append(" ");
                out.append(pkgname);
                out.append(":");
                out.append(typename);
                out.append("/");
                out.append(entryname);
            } catch (Resources.NotFoundException e) {
            }
        }
    }
    out.append("}");
    return out.toString();
}