List of usage examples for android.view View getBottom
@ViewDebug.CapturedViewProperty public final int getBottom()
From source file:com.microsoft.mimickeralarm.appcore.AlarmListItemTouchHelperCallback.java
@Override public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { View itemView = viewHolder.itemView; Resources resources = AlarmApplication.getAppContext().getResources(); Bitmap icon = BitmapFactory.decodeResource(resources, R.drawable.delete_trash_can); int iconPadding = resources.getDimensionPixelOffset(R.dimen.alarm_list_delete_icon_padding); int maxDrawWidth = (iconPadding * 2) + icon.getWidth(); Paint paint = new Paint(); paint.setColor(ContextCompat.getColor(AlarmApplication.getAppContext(), R.color.red)); int x = Math.round(Math.abs(dX)); // Reset the dismiss flag if the view resets to its default position if (x == 0) { mCanDismiss = false;/*from www.j a va2s . c o m*/ } // If we have travelled beyond the icon area via direct user interaction // we will dismiss when we get a swipe callback. We do this to try to avoid // unwanted swipe dismissal if ((x > maxDrawWidth) && isCurrentlyActive) { mCanDismiss = true; } int drawWidth = Math.min(x, maxDrawWidth); // Cap the height of the drawable area to the selectable area - this improves the visual // for the first taller item in the alarm list int itemTop = itemView.getBottom() - resources.getDimensionPixelSize(R.dimen.alarm_list_item_height); if (dX > 0) { // Handle swiping to the right // Draw red background in area that we vacate up to maxDrawWidth canvas.drawRect((float) itemView.getLeft(), (float) itemTop, drawWidth, (float) itemView.getBottom(), paint); // Only draw icon when we've past the padding threshold if (x > iconPadding) { Rect destRect = new Rect(); destRect.left = itemView.getLeft() + iconPadding; destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2; int maxRight = destRect.left + icon.getWidth(); destRect.right = Math.min(x, maxRight); destRect.bottom = destRect.top + icon.getHeight(); // Only draw the appropriate parts of the bitmap as it is revealed Rect srcRect = null; if (x < maxRight) { srcRect = new Rect(); srcRect.top = 0; srcRect.left = 0; srcRect.bottom = icon.getHeight(); srcRect.right = x - iconPadding; } canvas.drawBitmap(icon, srcRect, destRect, paint); } } else { // Handle swiping to the left // Draw red background in area that we vacate up to maxDrawWidth canvas.drawRect((float) itemView.getRight() - drawWidth, (float) itemTop, (float) itemView.getRight(), (float) itemView.getBottom(), paint); // Only draw icon when we've past the padding threshold if (x > iconPadding) { int fromLeftX = itemView.getRight() - x; Rect destRect = new Rect(); destRect.right = itemView.getRight() - iconPadding; destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2; int maxFromLeft = destRect.right - icon.getWidth(); destRect.left = Math.max(fromLeftX, maxFromLeft); destRect.bottom = destRect.top + icon.getHeight(); // Only draw the appropriate parts of the bitmap as it is revealed Rect srcRect = null; if (fromLeftX > maxFromLeft) { srcRect = new Rect(); srcRect.top = 0; srcRect.right = icon.getWidth(); srcRect.bottom = icon.getHeight(); srcRect.left = srcRect.right - (x - iconPadding); } canvas.drawBitmap(icon, srcRect, destRect, paint); } } // Fade out the item as we swipe it float alpha = 1.0f - Math.abs(dX) / (float) itemView.getWidth(); itemView.setAlpha(alpha); itemView.setTranslationX(dX); } else { super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); } }
From source file:com.chauthai.swipereveallayout.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *//* w ww . j a v a 2 s . c o m*/ 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; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:com.dmcc.bid.widget.swipebacklayout.ViewDragHelper.java
public View findTopChildUnder(int x, int y) { final int childCount = mParentView.getChildCount(); for (int i = childCount - 1; i >= 0; i--) { final View child = mParentView.getChildAt(mCallback.getOrderedChildIndex(i)); if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop() && y < child.getBottom()) { return child; }/*from w w w.j a v a 2 s . com*/ } return null; }
From source file:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v/* ww w.j a va2s .c o m*/ * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for * scrollability (true), or just its children (false). * @param dx * Delta scrolled in pixels * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, 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--) { 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, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.yangc.swipebacklayout.helper.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *//* ww w .j a v a 2 s . com*/ 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; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:com.lansun.qmyo.view.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * // ww w .j a v a2s . c om * @param v * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for scrollability (true), or just its children (false). * @param dx * Delta scrolled in pixels along the X axis * @param dy * Delta scrolled in pixels along the Y axis * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ 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--) { // 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; } } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:com.shawnway.nav.app.yylg.view.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { if (isInEditMode() || tabCount == 0) { return;//from ww w .j av a 2 s.c o m } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); // 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); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } switch (indicatorStyle) { case STYLE_CIRCLE: canvas.drawCircle((lineLeft + lineRight) / 2, (currentTab.getTop() + currentTab.getBottom()) / 2, circleSize, rectPaint); break; case STYLE_RECTANGLE: drawRectangle(canvas, height, currentTab, lineLeft, lineRight); break; case STYLE_NORMAL: drawNormalUnderLine(canvas, height, currentTab, lineLeft, lineRight); default: break; } super.onDraw(canvas); // // draw underline // // rectPaint.setColor(underlineColor); // 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.cyanogenmod.filemanager.ui.widgets.ViewDragHelper.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels along the X axis * @param dy Delta scrolled in pixels along the Y axis * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. *///from w w w.j a va 2 s . com 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; } } } return checkV && (v.canScrollHorizontally(-dx) || v.canScrollVertically(-dy)); }
From source file:com.shawnway.nav.app.wtw.view.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { if (isInEditMode() || tabCount == 0) { return;/* w w w . j av a 2s . co m*/ } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); // if there is an offset, startWeChat interpolating left and right coordinates // between current and next tab if (currentPositionOffset > 0f && currentPosition < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } switch (indicatorStyle) { case STYLE_CIRCLE: canvas.drawCircle((lineLeft + lineRight) / 2, (currentTab.getTop() + currentTab.getBottom()) / 2, circleSize, rectPaint); break; case STYLE_RECTANGLE: drawRectangle(canvas, height, currentTab, lineLeft, lineRight); break; case STYLE_NORMAL: drawNormalUnderLine(canvas, height, currentTab, lineLeft, lineRight); default: break; } super.onDraw(canvas); // // draw underline // // rectPaint.setColor(underlineColor); // 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.callba.phone.widget.refreshlayout.RefreshLayout.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. *//*w w w .ja v a 2 s. 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) { return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1)) && lastChild.getBottom() > absListView.getPaddingBottom(); } else { return false; } } else { return mTarget.getHeight() - mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } }