Java Code Examples for android.view.ViewGroup#offsetDescendantRectToMyCoords()

The following examples show how to use android.view.ViewGroup#offsetDescendantRectToMyCoords() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void initPeekHeight(DialogInterface dialog)
{
    if (dialog == null) {
        return;
    }

    BottomSheetDialog bottomSheet = (BottomSheetDialog) dialog;
    FrameLayout layout = (FrameLayout) bottomSheet.findViewById(android.support.design.R.id.design_bottom_sheet);  // for AndroidX, resource is renamed to com.google.android.material.R.id.design_bottom_sheet
    if (layout != null)
    {
        BottomSheetBehavior behavior = BottomSheetBehavior.from(layout);
        ViewGroup dialogLayout = (LinearLayout) bottomSheet.findViewById(R.id.moondialog_layout);
        View divider1 = bottomSheet.findViewById(R.id.divider1);
        if (dialogLayout != null && divider1 != null)
        {
            Rect headerBounds = new Rect();
            divider1.getDrawingRect(headerBounds);
            dialogLayout.offsetDescendantRectToMyCoords(divider1, headerBounds);
            behavior.setPeekHeight(headerBounds.top);

        } else {
            behavior.setPeekHeight(-1);
        }
    }
}
 
Example 2
Source Project: scene   File: ViewOtherAnimationBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Rect get(View object) {
    ViewGroup viewGroup = (ViewGroup) object.getParent();
    Rect rect = new Rect();
    viewGroup.offsetDescendantRectToMyCoords(viewGroup, rect);
    return rect;
}
 
Example 3
public Rect findLocationWithView(View view)
{
    ViewGroup root = (ViewGroup)getMainUpView().getParent();
    Rect rect = new Rect();
    root.offsetDescendantRectToMyCoords(view, rect);
    return rect;
}
 
Example 4
Source Project: UIWidget   File: ViewGroupUtils.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
    // View#offsetDescendantRectToMyCoords includes scroll offsets of the last child.
    // We need to reverse it here so that we get the rect of the view itself rather
    // than its content.
    rect.offset(child.getScrollX(), child.getScrollY());
}
 
Example 5
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
    // View#offsetDescendantRectToMyCoords includes scroll offsets of the last child.
    // We need to reverse it here so that we get the rect of the view itself rather
    // than its content.
    rect.offset(child.getScrollX(), child.getScrollY());
}
 
Example 6
Source Project: scene   File: ViewOtherAnimationBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public T bounds(Rect toValue) {
    ViewGroup viewGroup = (ViewGroup) mView.getParent();
    Rect rect = new Rect();
    viewGroup.offsetDescendantRectToMyCoords(viewGroup, rect);
    return bounds(rect, toValue);
}
 
Example 7
Source Project: FireFiles   File: ViewGroupUtils.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
}
 
Example 8
Source Project: FireFiles   File: ViewGroupUtils.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
}
 
Example 9
Source Project: FireFiles   File: ViewGroupUtils.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
}
 
Example 10
private int[] getCenterClickedView(ViewGroup from) {
  Rect clickedViewRect = new Rect();
  clickedView.getDrawingRect(clickedViewRect);
  from.offsetDescendantRectToMyCoords(clickedView, clickedViewRect);
  return new int[] {(int) clickedViewRect.exactCenterX(), (int) clickedViewRect.exactCenterY()};
}
 
Example 11
Source Project: CircularReveal   File: MainActivity.java    License: MIT License 4 votes vote down vote up
@OnClick(R.id.reset) void resetUi(View resetCard) {
  cardsLine.setVisibility(View.INVISIBLE);

  final View target = ButterKnife.findById(this, R.id.activator);

  // Coordinates of circle initial point
  final ViewGroup parent = (ViewGroup) activatorMask.getParent();
  final Rect bounds = new Rect();
  final Rect maskBounds = new Rect();

  target.getDrawingRect(bounds);
  activatorMask.getDrawingRect(maskBounds);
  parent.offsetDescendantRectToMyCoords(target, bounds);
  parent.offsetDescendantRectToMyCoords(activatorMask, maskBounds);

  maskElevation = activatorMask.getCardElevation();
  activatorMask.setCardElevation(0);

  final int cX = maskBounds.centerX();
  final int cY = maskBounds.centerY();

  final Animator circularReveal = ViewAnimationUtils.createCircularReveal(activatorMask, cX, cY,
      (float) Math.hypot(maskBounds.width() * .5f, maskBounds.height() * .5f),
      target.getWidth() / 2f, View.LAYER_TYPE_HARDWARE);

  final float c0X = bounds.centerX() - maskBounds.centerX();
  final float c0Y = bounds.centerY() - maskBounds.centerY();

  AnimatorPath path = new AnimatorPath();
  path.moveTo(0, 0);
  path.curveTo(0, 0, 0, c0Y, c0X, c0Y);

  ObjectAnimator pathAnimator = ObjectAnimator.ofObject(this, "maskLocation", new PathEvaluator(),
      path.getPoints().toArray());

  AnimatorSet set = new AnimatorSet();
  set.playTogether(circularReveal, pathAnimator);
  set.setInterpolator(new FastOutSlowInInterpolator());
  set.setDuration(SLOW_DURATION);
  set.addListener(new AnimatorListenerAdapter() {
    @Override public void onAnimationEnd(Animator animation) {
      activatorMask.setCardElevation(maskElevation);
      activatorMask.setVisibility(View.INVISIBLE);

      circlesLine.setVisibility(View.VISIBLE);
      executeCirclesDropDown();
      target.setEnabled(true);
    }
  });
  set.start();
}
 
Example 12
Source Project: ticdesign   File: ViewGroupUtils.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
}
 
Example 13
Source Project: fab-speed-dial   File: ViewGroupUtils.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
}
 
Example 14
public Rect findLocationWithView(View view) {
	ViewGroup root = (ViewGroup) getMainUpView().getParent();
	Rect rect = new Rect();
	root.offsetDescendantRectToMyCoords(view, rect);
	return rect;
}
 
Example 15
public Rect findLocationWithView(View view) {
    ViewGroup root = (ViewGroup) vf.getParent();
    Rect rect = new Rect();
    root.offsetDescendantRectToMyCoords(view, rect);
    return rect;
}
 
Example 16
Source Project: TvLauncher   File: FlyBorderView.java    License: Apache License 2.0 4 votes vote down vote up
public Rect findLocationWithView(View view) {
    ViewGroup root = (ViewGroup) this.getParent();
    Rect rect = new Rect();
    root.offsetDescendantRectToMyCoords(view, rect);
    return rect;
}
 
Example 17
Source Project: TvRecyclerView   File: BaseEffect.java    License: Apache License 2.0 4 votes vote down vote up
protected Rect findLocationWithView(View view) {
    ViewGroup root = (ViewGroup) view.getParent();
    Rect rect = new Rect();
    root.offsetDescendantRectToMyCoords(view, rect);
    return rect;
}
 
Example 18
public Rect findLocationWithView(View view) {
	ViewGroup root = (ViewGroup) getMainUpView().getParent();
	Rect rect = new Rect();
	root.offsetDescendantRectToMyCoords(view, rect);
	return rect;
}
 
Example 19
@Override
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
    parent.offsetDescendantRectToMyCoords(child, rect);
}
 
Example 20
Source Project: hipda   File: UIUtils.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static int getRelativeTop(View myView, ViewGroup parentView) {
    Rect offsetViewBounds = new Rect();
    myView.getDrawingRect(offsetViewBounds);
    parentView.offsetDescendantRectToMyCoords(myView, offsetViewBounds);
    return offsetViewBounds.top;
}