Skip to content

Commit

Permalink
Fixed clip bounds being incorrectly calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
sjwall committed Oct 1, 2016
1 parent 91e9539 commit d70026e
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class MaterialTapTargetPrompt
ViewGroup mParentView;
boolean mParentViewIsDecor;
ViewGroup mClipToView;
final float mStatusBarHeight;
final float mStatusBarHeight, mScreenHeight;
final ViewTreeObserver.OnGlobalLayoutListener mGlobalLayoutListener;
boolean mAutoDismiss, mAutoFinish;

Expand Down Expand Up @@ -121,6 +121,7 @@ public void onPromptTouched(MotionEvent event, boolean tappedTarget)
Rect rect = new Rect();
mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
mStatusBarHeight = rect.top;
mScreenHeight = rect.bottom + mStatusBarHeight;

mGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener()
{
Expand Down Expand Up @@ -656,14 +657,17 @@ void updateClipBounds()
if (mClipToView != null)
{
mView.mClipBounds = true;
mView.mClipBoundsLeft = mClipToView.getLeft();
mView.mClipBoundsBottom = mClipToView.getBottom();
mView.mClipBoundsTop = mClipToView.getTop();
mView.mClipBoundsRight = mClipToView.getRight();
if (mParentViewIsDecor)

final int[] location = new int[2];
mClipToView.getLocationOnScreen(location);
mView.mClipBoundsLeft = location[0];
mView.mClipBoundsBottom = location[1] + mClipToView.getHeight();
mView.mClipBoundsTop = location[1];
mView.mClipBoundsRight = location[0] + mClipToView.getWidth();

if (mClipToView.getHeight() == mScreenHeight || (mParentViewIsDecor && mView.mClipBoundsTop == 0))
{
mView.mClipBoundsTop += mStatusBarHeight;
mView.mClipBoundsBottom += mStatusBarHeight;
}
}
else if (mParentViewIsDecor)
Expand All @@ -672,7 +676,7 @@ else if (mParentViewIsDecor)
//Stop the canvas drawing over the status bar
mView.mClipBoundsTop = mStatusBarHeight;
mView.mClipBoundsLeft = 0f;
mView.mClipBoundsBottom = mActivity.getResources().getDisplayMetrics().heightPixels - mStatusBarHeight;
mView.mClipBoundsBottom = mActivity.getResources().getDisplayMetrics().heightPixels;
mView.mClipBoundsRight = mActivity.getResources().getDisplayMetrics().widthPixels;
}
else
Expand Down

0 comments on commit d70026e

Please sign in to comment.