List of usage examples for android.view View requestRectangleOnScreen
public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate)
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;/* w w w .j a v a 2 s . c om*/ } 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;//from w w w .j a v a 2s . 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:Main.java
private static void expandInner(final View view, final View parentView, final ViewGroup rootContainer, final int targtetHeight) { setHeight(view, 0);/*from www.j a v a2 s.co m*/ view.setVisibility(View.VISIBLE); final Animation animation = new Animation() { private final Rect rect = new Rect(); private final Rect parentVisibleRect = new Rect(); ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener; private final Runnable checkViewRunnable = new Runnable() { @Override public void run() { checkForViewInsideVisibleArea(); } }; @Override protected void applyTransformation(float interpolatedTime, Transformation t) { int neededHeight = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT : (int) (targtetHeight * interpolatedTime); setHeight(view, neededHeight); final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver(); if (globalLayoutListener == null) { globalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (globalLayoutListener == null) { removeGlobalLayoutListener(viewTreeObserver, this); } checkForViewInsideVisibleArea(); } }; viewTreeObserver.addOnGlobalLayoutListener(globalLayoutListener); } if (globalLayoutListener != null && interpolatedTime == 1) { runInUIThread(checkViewRunnable); globalLayoutListener = null; } view.requestLayout(); } @Override public boolean willChangeBounds() { return true; } private void checkForViewInsideVisibleArea() { if (rootContainer.indexOfChild(parentView) == -1) { return; } parentVisibleRect.left = 0; parentVisibleRect.top = 0; parentVisibleRect.right = parentView.getWidth(); parentVisibleRect.bottom = parentView.getHeight(); rootContainer.offsetDescendantRectToMyCoords(parentView, parentVisibleRect); if (parentVisibleRect.top < 0 || parentVisibleRect.bottom > rootContainer.getHeight()) { rect.left = parentView.getLeft(); rect.top = parentView.getTop(); rect.right = parentView.getRight(); rect.bottom = parentView.getBottom(); parentView.requestRectangleOnScreen(rect, true); } } }; animation.setDuration(ANIMATION_DURATION); view.startAnimation(animation); }