List of usage examples for android.view View getRight
@ViewDebug.CapturedViewProperty public final int getRight()
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.utils.CustomRecyclerViewUtils.java
private static View findChildViewUnderWithoutTranslation(@NonNull ViewGroup parent, float x, float y) { final int count = parent.getChildCount(); for (int i = count - 1; i >= 0; i--) { final View child = parent.getChildAt(i); if (x >= child.getLeft() && x <= child.getRight() && y >= child.getTop() && y <= child.getBottom()) { return child; }/*www . j ava 2s . c o m*/ } return null; }
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.utils.CustomRecyclerViewUtils.java
public static Rect getViewBounds(@NonNull View v, @NonNull Rect outBounds) { outBounds.left = v.getLeft();/*w w w . j av a 2s . c o m*/ outBounds.right = v.getRight(); outBounds.top = v.getTop(); outBounds.bottom = v.getBottom(); return outBounds; }
From source file:app.hanks.com.testadvancerecyclerview.MyDraggableSwipeableItemAdapter.java
public static boolean hitTest(View v, int x, int y) { final int tx = (int) (ViewCompat.getTranslationX(v) + 0.5f); final int ty = (int) (ViewCompat.getTranslationY(v) + 0.5f); final int left = v.getLeft() + tx; final int right = v.getRight() + tx; final int top = v.getTop() + ty; final int bottom = v.getBottom() + ty; return (x >= left) && (x <= right) && (y >= top) && (y <= bottom); }
From source file:com.nextgis.maplibui.util.ControlHelper.java
public static void setClearAction(final EditText target) { target.setOnTouchListener(new View.OnTouchListener() { final int RIGHT = 2; @Override//from w w w. j a va2 s. c o m public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { int leftEdgeOfRightDrawable = view.getRight() - target.getCompoundDrawables()[RIGHT].getBounds().width(); // when EditBox has padding, adjust leftEdge like // leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right); if (event.getRawX() >= leftEdgeOfRightDrawable) { // clicked on clear icon target.setText(""); target.clearFocus(); return false; } } return false; } }); }
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.utils.CustomRecyclerViewUtils.java
private static View findOneVisibleChildIncludesPadding(LinearLayoutManager lm, int fromIndex, int toIndex, boolean completelyVisible, boolean acceptPartiallyVisible) { boolean isVertical = (lm.getOrientation() == LinearLayoutManager.VERTICAL); final int start = 0; final int end = (isVertical) ? lm.getHeight() : lm.getWidth(); final int next = toIndex > fromIndex ? 1 : -1; View partiallyVisible = null; for (int i = fromIndex; i != toIndex; i += next) { final View child = lm.getChildAt(i); final int childStart = (isVertical) ? child.getTop() : child.getLeft(); final int childEnd = (isVertical) ? child.getBottom() : child.getRight(); if (childStart < end && childEnd > start) { if (completelyVisible) { if (childStart >= start && childEnd <= end) { return child; } else if (acceptPartiallyVisible && partiallyVisible == null) { partiallyVisible = child; }/* w w w. java2s .c o m*/ } else { return child; } } } return partiallyVisible; }
From source file:com.daycle.daycleapp.custom.swipelistview.itemmanipulation.swipedismiss.SwipeTouchListener.java
private static Rect getChildViewRect(final View parentView, final View childView) { Rect childRect = new Rect(childView.getLeft(), childView.getTop(), childView.getRight(), childView.getBottom());/*from ww w. ja va 2 s . com*/ if (!parentView.equals(childView)) { View workingChildView = childView; ViewGroup parent; while (!(parent = (ViewGroup) workingChildView.getParent()).equals(parentView)) { childRect.offset(parent.getLeft(), parent.getTop()); workingChildView = parent; } } return childRect; }
From source file:com.android.clear.reminder.AnimatorUtils.java
/** * @param target the view to be morphed/*from ww w . j a v a 2s. com*/ * @param from the bounds of the {@code target} before animating * @param to the bounds of the {@code target} after animating * @return an animator that morphs the {@code target} between the {@code from} bounds and the * {@code to} bounds. Note that it is the *content* bounds that matter here, so padding * insets contributed by the background are subtracted from the views when computing the * {@code target} bounds. */ public static Animator getBoundsAnimator(View target, View from, View to) { // Fetch the content insets for the views. Content bounds are what matter, not total bounds. final Rect targetInsets = new Rect(); target.getBackground().getPadding(targetInsets); final Rect fromInsets = new Rect(); from.getBackground().getPadding(fromInsets); final Rect toInsets = new Rect(); to.getBackground().getPadding(toInsets); // Before animating, the content bounds of target must match the content bounds of from. final int startLeft = from.getLeft() - fromInsets.left + targetInsets.left; final int startTop = from.getTop() - fromInsets.top + targetInsets.top; final int startRight = from.getRight() - fromInsets.right + targetInsets.right; final int startBottom = from.getBottom() - fromInsets.bottom + targetInsets.bottom; // After animating, the content bounds of target must match the content bounds of to. final int endLeft = to.getLeft() - toInsets.left + targetInsets.left; final int endTop = to.getTop() - toInsets.top + targetInsets.top; final int endRight = to.getRight() - toInsets.right + targetInsets.right; final int endBottom = to.getBottom() - toInsets.bottom + targetInsets.bottom; return getBoundsAnimator(target, startLeft, startTop, startRight, startBottom, endLeft, endTop, endRight, endBottom); }
From source file:com.fastbootmobile.encore.utils.Utils.java
public static int getEnclosingCircleRadius(View v, int cx, int cy) { int realCenterX = cx + v.getLeft(); int realCenterY = cy + v.getTop(); int distanceTopLeft = (int) Math.hypot(realCenterX - v.getLeft(), realCenterY - v.getTop()); int distanceTopRight = (int) Math.hypot(v.getRight() - realCenterX, realCenterY - v.getTop()); int distanceBottomLeft = (int) Math.hypot(realCenterX - v.getLeft(), v.getBottom() - realCenterY); int distanceBotomRight = (int) Math.hypot(v.getRight() - realCenterX, v.getBottom() - realCenterY); int[] distances = new int[] { distanceTopLeft, distanceTopRight, distanceBottomLeft, distanceBotomRight }; int radius = distances[0]; for (int i = 1; i < distances.length; i++) { if (distances[i] > radius) radius = distances[i];//from w ww . j a v a 2 s.c o m } return radius; }
From source file:com.facebook.litho.LithoView.java
private static void performLayoutOnChildrenIfNecessary(ComponentHost host) { for (int i = 0, count = host.getChildCount(); i < count; i++) { final View child = host.getChildAt(i); if (child.isLayoutRequested()) { // The hosting view doesn't allow children to change sizes dynamically as // this would conflict with the component's own layout calculations. child.measure(MeasureSpec.makeMeasureSpec(child.getWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getHeight(), MeasureSpec.EXACTLY)); child.layout(child.getLeft(), child.getTop(), child.getRight(), child.getBottom()); }/*from w w w . ja v a 2 s . c o m*/ if (child instanceof ComponentHost) { performLayoutOnChildrenIfNecessary((ComponentHost) child); } } }
From source file:com.facebook.litho.utils.IncrementalMountUtils.java
private static void maybePerformIncrementalMountOnView(int scrollingParentWidth, int scrollingParentHeight, View view) { final View underlyingView = view instanceof WrapperView ? ((WrapperView) view).getWrappedView() : view; if (!(underlyingView instanceof LithoView)) { return;/*from ww w. j a v a 2s . com*/ } final LithoView lithoView = (LithoView) underlyingView; if (!lithoView.isIncrementalMountEnabled()) { return; } if (view != underlyingView && view.getHeight() != underlyingView.getHeight()) { throw new IllegalStateException( "ViewDiagnosticsWrapper must be the same height as the underlying view"); } final int translationX = (int) view.getTranslationX(); final int translationY = (int) view.getTranslationY(); final int top = view.getTop() + translationY; final int bottom = view.getBottom() + translationY; final int left = view.getLeft() + translationX; final int right = view.getRight() + translationX; if (left >= 0 && top >= 0 && right <= scrollingParentWidth && bottom <= scrollingParentHeight && lithoView.getPreviousMountBounds().width() == lithoView.getWidth() && lithoView.getPreviousMountBounds().height() == lithoView.getHeight()) { // View is fully visible, and has already been completely mounted. return; } final Rect rect = acquireRect(); rect.set(Math.max(0, -left), Math.max(0, -top), Math.min(right, scrollingParentWidth) - left, Math.min(bottom, scrollingParentHeight) - top); if (rect.isEmpty()) { // View is not visible at all, nothing to do. release(rect); return; } lithoView.performIncrementalMount(rect); release(rect); }