List of usage examples for android.view View getDrawingRect
public void getDrawingRect(Rect outRect)
From source file:Main.java
public static boolean inViewInBounds(View view, int x, int y) { Rect outRect = new Rect(); int[] location = new int[2]; view.getDrawingRect(outRect); view.getLocationOnScreen(location);//from ww w.ja v a 2 s . c o m outRect.offset(location[0], location[1]); return outRect.contains(x, y); }
From source file:Main.java
/** * to judge whether items take full page * if not ,even if last item is visible ,we should not call listener * * @return whether items take up full page *///from w w w . ja v a 2 s .c o m public static boolean itemTakeFullPage(ListView list) { if (list.getChildCount() > 0) { int totalHeight = 0; for (int i = 0; i < list.getChildCount(); i++) { View child = list.getChildAt(i); Rect childRect = new Rect(); child.getDrawingRect(childRect); totalHeight += childRect.height(); } Rect visibleRect = new Rect(); list.getGlobalVisibleRect(visibleRect); return (visibleRect.bottom - visibleRect.top) - totalHeight < VISIBLE_SLOP; } return false; }
From source file:com.crucentralcoast.app.common.NCVScrollToAction.java
@Override public void perform(UiController uiController, View view) { if (isDisplayingAtLeast(90).matches(view)) { Log.i(TAG, "View is already displayed. Returning."); return;/*from w ww. j av a 2 s. co m*/ } Rect rect = new Rect(); view.getDrawingRect(rect); if (!view.requestRectangleOnScreen(rect, true /* immediate */)) { Log.w(TAG, "Scrolling to view was requested, but none of the parents scrolled."); } uiController.loopMainThreadUntilIdle(); if (!isDisplayingAtLeast(90).matches(view)) { throw new PerformException.Builder().withActionDescription(this.getDescription()) .withViewDescription(HumanReadables.describe(view)) .withCause( new RuntimeException("Scrolling to view was attempted, but the view is not displayed")) .build(); } }
From source file:org.xbmc.kore.testhelpers.action.NestedScrollTo.java
@Override public void perform(UiController uiController, View view) { if (isDisplayingAtLeast(90).matches(view)) { LogUtils.LOGI(TAG, "View is already displayed. Returning."); return;//ww w . j a v a2s . c om } Rect rect = new Rect(); view.getDrawingRect(rect); if (!view.requestRectangleOnScreen(rect, true /* immediate */)) { LogUtils.LOGW(TAG, "Scrolling to view was requested, but none of the parents scrolled."); } uiController.loopMainThreadUntilIdle(); if (!isDisplayingAtLeast(90).matches(view)) { throw new PerformException.Builder().withActionDescription(this.getDescription()) .withViewDescription(HumanReadables.describe(view)) .withCause( new RuntimeException("Scrolling to view was attempted, but the view is not displayed")) .build(); } }
From source file:com.itsronald.widget.IndicatorDotPathView.java
/** * Convert the coordinates of one of this view's subviews into the coordinate space of one of * this view's other subviews.//from ww w . j a v a 2s.c om * * @param view The view whose bounds to offset into neighbor's coords. * @param neighbor The view into whose coordinate space to offset view's bounds. * @return The bounds of view in neighbor's coordinate space. */ @NonNull private Rect viewRectInNeighborCoords(@NonNull View view, @NonNull View neighbor) { final Rect bounds = new Rect(); view.getDrawingRect(bounds); offsetDescendantRectToMyCoords(view, bounds); offsetRectIntoDescendantCoords(neighbor, bounds); return bounds; }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
/** * Compute the adjusted expanded photo size to fit within the enclosing view with the same * aspect ratio./*ww w . j a v a 2 s . co m*/ * @param enclosingView This is the view that the photo must fit within. * @param heightOffset This is the amount of height to leave open for the photo action popup. */ private int getAdjustedExpandedPhotoSize(View enclosingView, int heightOffset) { // pull out the bounds of the backdrop final Rect bounds = new Rect(); enclosingView.getDrawingRect(bounds); final int boundsWidth = bounds.width(); final int boundsHeight = bounds.height() - heightOffset; // ensure that the new expanded photo size can fit within the backdrop final float alpha = Math.min((float) boundsHeight / (float) mExpandedPhotoSize, (float) boundsWidth / (float) mExpandedPhotoSize); if (alpha < 1.0f) { // need to shrink width and height while maintaining aspect ratio return (int) (alpha * mExpandedPhotoSize); } else { return mExpandedPhotoSize; } }
From source file:com.waz.zclient.pages.main.RootFragment.java
@Override public void onShowUserProfile(User user, View anchorView) { if (LayoutSpec.isPhone(getActivity())) { return;/* w w w . j a v a 2s . c om*/ } final Rect outRect = new Rect(); anchorView.getDrawingRect(outRect); final Point locationOnScreen = ViewUtils.getLocationOnScreen(anchorView); final Point rootViewLocation = ViewUtils .getLocationOnScreen(ViewUtils.getView(getActivity(), R.id.fl_main_content)); locationOnScreen.offset(-rootViewLocation.x, -rootViewLocation.y); final int posX = locationOnScreen.x; final int posY = locationOnScreen.y; getChildFragmentManager().beginTransaction() .replace(R.id.fl__root__participant_container, ParticipantsDialogFragment.newAvatarPopoverInstance(posX, posY, outRect, user.getId()), ParticipantsDialogFragment.TAG) .commit(); }
From source file:com.waz.zclient.pages.main.RootFragment.java
@Override public void onShowPickUser(IPickUserController.Destination destination, View anchorView) { if (LayoutSpec.isPhone(getActivity()) || anchorView == null || !destination.equals(IPickUserController.Destination.CURSOR)) { return;//ww w . j a va 2 s .com } final Rect outRect = new Rect(); anchorView.getDrawingRect(outRect); final Point locationOnScreen = ViewUtils.getLocationOnScreen(anchorView); final Point rootViewLocation = ViewUtils .getLocationOnScreen(ViewUtils.getView(getActivity(), R.id.fl_main_content)); locationOnScreen.offset(-rootViewLocation.x, -rootViewLocation.y); final int posX = locationOnScreen.x; final int posY = locationOnScreen.y; if (!groupConversation && otherUser != null) { getControllerFactory().getPickUserController().addUser(otherUser); } getControllerFactory().getConversationScreenController() .setPopoverLaunchedMode(DialogLaunchMode.PARTICIPANT_BUTTON); getChildFragmentManager().beginTransaction() .replace(R.id.fl__root__participant_container, ParticipantsDialogFragment.newStartUiInstance(posX, posY, outRect, groupConversation), ParticipantsDialogFragment.TAG) .commit(); }
From source file:com.waz.zclient.pages.main.RootFragment.java
@Override public void onShowParticipants(View anchorView, boolean isSingleConversation, boolean isMemberOfConversation, boolean showDeviceTabSingle) { if (LayoutSpec.isPhone(getActivity()) || anchorView == null) { return;/*from w ww . j a va 2 s . co m*/ } final Rect outRect = new Rect(); anchorView.getDrawingRect(outRect); final Point locationOnScreen = ViewUtils.getLocationOnScreen(anchorView); final Point rootViewLocation = ViewUtils .getLocationOnScreen(ViewUtils.getView(getActivity(), R.id.fl_main_content)); locationOnScreen.offset(-rootViewLocation.x, -rootViewLocation.y); final int posX = locationOnScreen.x; final int posY = locationOnScreen.y; if (anchorView instanceof Toolbar) { getControllerFactory().getConversationScreenController() .setPopoverLaunchedMode(DialogLaunchMode.CONVERSATION_TOOLBAR); } else { getControllerFactory().getConversationScreenController() .setPopoverLaunchedMode(DialogLaunchMode.PARTICIPANT_BUTTON); } int firstPage = (isSingleConversation && showDeviceTabSingle) ? TabbedParticipantBodyFragment.DEVICE_PAGE : TabbedParticipantBodyFragment.USER_PAGE; getChildFragmentManager().beginTransaction() .replace(R.id.fl__root__participant_container, ParticipantsDialogFragment.newParticipantButtonInstance(posX, posY, outRect, firstPage), ParticipantsDialogFragment.TAG) .commit(); }
From source file:com.android.leanlauncher.Workspace.java
/** * Draw the View v into the given Canvas. * * @param v the view to draw/*from ww w . ja v a 2 s . co m*/ * @param destCanvas the canvas to draw on * @param padding the horizontal and vertical padding to use when drawing */ private static void drawDragView(View v, Canvas destCanvas, int padding) { final Rect clipRect = sTempRect; v.getDrawingRect(clipRect); destCanvas.save(); if (v instanceof TextView) { Drawable d = ((TextView) v).getCompoundDrawables()[1]; Rect bounds = getDrawableBounds(d); clipRect.set(0, 0, bounds.width() + padding, bounds.height() + padding); destCanvas.translate(padding / 2 - bounds.left, padding / 2 - bounds.top); d.draw(destCanvas); } else { destCanvas.translate(-v.getScrollX() + padding / 2, -v.getScrollY() + padding / 2); destCanvas.clipRect(clipRect, Op.REPLACE); v.draw(destCanvas); } destCanvas.restore(); }