@Test public void testCalcCircleRectF() { View mClickedViewMock = mock(View.class); when(mClickedViewMock.getHeight()).thenReturn(10); when(mClickedViewMock.getWidth()).thenReturn(30); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); int[] mArg = (int[]) args[0]; mArg[0] = 3; mArg[1] = 2; return null; } }).when(mClickedViewMock).getLocationOnScreen(any(int[].class)); mCoachmarkView.setView(mClickedViewMock); mCoachmarkView.mMarginAroundCircle = 2; RectF mRectF = mCoachmarkView.calcCircleRectF(); Assert.assertEquals(34.0f, mRectF.width()); Assert.assertEquals(34.0f, mRectF.height()); Assert.assertEquals(1.0f, mRectF.left); Assert.assertEquals(-10.0f, mRectF.top); }
public RectF calcCircleRectF() { if (mView == null) { return new RectF(); } float radius = mMarginAroundCircle + mView.getWidth() / 2; int[] xy = new int[2]; mView.getLocationOnScreen(xy); float centerX = xy[0] + mView.getWidth() / 2; float centerY = xy[1] + mView.getHeight() / 2; return new RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius); }
CoachmarkView extends FrameLayout implements CoachmarkViewLayout, AnimationListener { public RectF calcCircleRectF() { if (mView == null) { return new RectF(); } float radius = mMarginAroundCircle + mView.getWidth() / 2; int[] xy = new int[2]; mView.getLocationOnScreen(xy); float centerX = xy[0] + mView.getWidth() / 2; float centerY = xy[1] + mView.getHeight() / 2; return new RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius); } }
CoachmarkView extends FrameLayout implements CoachmarkViewLayout, AnimationListener { public RectF calcCircleRectF() { if (mView == null) { return new RectF(); } float radius = mMarginAroundCircle + mView.getWidth() / 2; int[] xy = new int[2]; mView.getLocationOnScreen(xy); float centerX = xy[0] + mView.getWidth() / 2; float centerY = xy[1] + mView.getHeight() / 2; return new RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius); } CoachmarkView(Context context);  CoachmarkView(Context context, AttributeSet attrs);  CoachmarkView(Context context, AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  CoachmarkView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes); }
CoachmarkView extends FrameLayout implements CoachmarkViewLayout, AnimationListener { public RectF calcCircleRectF() { if (mView == null) { return new RectF(); } float radius = mMarginAroundCircle + mView.getWidth() / 2; int[] xy = new int[2]; mView.getLocationOnScreen(xy); float centerX = xy[0] + mView.getWidth() / 2; float centerY = xy[1] + mView.getHeight() / 2; return new RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius); } CoachmarkView(Context context);  CoachmarkView(Context context, AttributeSet attrs);  CoachmarkView(Context context, AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  CoachmarkView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes); @Override void onAnimationFinished(); CoachmarkView show(); @NonNull RectF calcActionArrowRect(); RectF calcActionDescriptionRect(); RectF calcDescriptionRect(); RectF calcScreenRectF(); RectF calcCircleRectF(); @Override boolean isInEditMode(); void setActionDescription(View actionDescription); void setDescription(View description); void setActionDescriptionRenderer(ActionDescriptionRenderer... actionDescriptionRenderer); void setDescriptionRenderer(DescriptionRenderer descriptionRenderer); void setView(View view); void setButtonRenderer(ButtonRenderer buttonRenderer); void setBackColor(int backColor); void setPaddingAroundCircle(int paddingAroundCircle); @Override void dismiss(); void setAnimationRenderer(AnimationRenderer animationRenderer); void setDismissListener(DismissListener listener); }
CoachmarkView extends FrameLayout implements CoachmarkViewLayout, AnimationListener { public RectF calcCircleRectF() { if (mView == null) { return new RectF(); } float radius = mMarginAroundCircle + mView.getWidth() / 2; int[] xy = new int[2]; mView.getLocationOnScreen(xy); float centerX = xy[0] + mView.getWidth() / 2; float centerY = xy[1] + mView.getHeight() / 2; return new RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius); } CoachmarkView(Context context);  CoachmarkView(Context context, AttributeSet attrs);  CoachmarkView(Context context, AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  CoachmarkView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes); @Override void onAnimationFinished(); CoachmarkView show(); @NonNull RectF calcActionArrowRect(); RectF calcActionDescriptionRect(); RectF calcDescriptionRect(); RectF calcScreenRectF(); RectF calcCircleRectF(); @Override boolean isInEditMode(); void setActionDescription(View actionDescription); void setDescription(View description); void setActionDescriptionRenderer(ActionDescriptionRenderer... actionDescriptionRenderer); void setDescriptionRenderer(DescriptionRenderer descriptionRenderer); void setView(View view); void setButtonRenderer(ButtonRenderer buttonRenderer); void setBackColor(int backColor); void setPaddingAroundCircle(int paddingAroundCircle); @Override void dismiss(); void setAnimationRenderer(AnimationRenderer animationRenderer); void setDismissListener(DismissListener listener);  }