@Test public void testDispatchDraw() throws NoSuchFieldException, IllegalAccessException { mActivity.addContentView(mCoachmarkView, new LinearLayout.LayoutParams(200, 200)); Canvas canvasMock = mock(Canvas.class); mCoachmarkView.setView(mock(View.class)); mCoachmarkView.mCircleView = mock(CircleView.class); mCoachmarkView.dispatchDraw(canvasMock); AnimationRenderer animRenderer = ReflectionUtil.getField(CoachmarkView.class, mCoachmarkView, "mAnimationRenderer"); Assert.assertTrue(animRenderer instanceof NoAnimationRenderer); Bitmap bitmap = ReflectionUtil.getField(CoachmarkView.class, mCoachmarkView, "mBitmap"); Assert.assertEquals(200, bitmap.getWidth()); Assert.assertEquals(200, bitmap.getHeight()); }
@Override protected void dispatchDraw(Canvas canvas) { if (mBitmap == null) { createWindowFrame(); } canvas.drawBitmap(mBitmap, null, calcScreenRectF(), null); super.dispatchDraw(canvas); if (!mIsInitialized) { mIsInitialized = true; if (mAnimationRenderer == null) { mAnimationRenderer = new NoAnimationRenderer(); } mAnimationRenderer.animate(CoachmarkView.this, mCircleView, CoachmarkView.this); } }
CoachmarkView extends FrameLayout implements CoachmarkViewLayout, AnimationListener { @Override protected void dispatchDraw(Canvas canvas) { if (mBitmap == null) { createWindowFrame(); } canvas.drawBitmap(mBitmap, null, calcScreenRectF(), null); super.dispatchDraw(canvas); if (!mIsInitialized) { mIsInitialized = true; if (mAnimationRenderer == null) { mAnimationRenderer = new NoAnimationRenderer(); } mAnimationRenderer.animate(CoachmarkView.this, mCircleView, CoachmarkView.this); } } }
CoachmarkView extends FrameLayout implements CoachmarkViewLayout, AnimationListener { @Override protected void dispatchDraw(Canvas canvas) { if (mBitmap == null) { createWindowFrame(); } canvas.drawBitmap(mBitmap, null, calcScreenRectF(), null); super.dispatchDraw(canvas); if (!mIsInitialized) { mIsInitialized = true; if (mAnimationRenderer == null) { mAnimationRenderer = new NoAnimationRenderer(); } mAnimationRenderer.animate(CoachmarkView.this, mCircleView, CoachmarkView.this); } } 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 { @Override protected void dispatchDraw(Canvas canvas) { if (mBitmap == null) { createWindowFrame(); } canvas.drawBitmap(mBitmap, null, calcScreenRectF(), null); super.dispatchDraw(canvas); if (!mIsInitialized) { mIsInitialized = true; if (mAnimationRenderer == null) { mAnimationRenderer = new NoAnimationRenderer(); } mAnimationRenderer.animate(CoachmarkView.this, mCircleView, CoachmarkView.this); } } 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 { @Override protected void dispatchDraw(Canvas canvas) { if (mBitmap == null) { createWindowFrame(); } canvas.drawBitmap(mBitmap, null, calcScreenRectF(), null); super.dispatchDraw(canvas); if (!mIsInitialized) { mIsInitialized = true; if (mAnimationRenderer == null) { mAnimationRenderer = new NoAnimationRenderer(); } mAnimationRenderer.animate(CoachmarkView.this, mCircleView, CoachmarkView.this); } } 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);  }