Skip to content

Commit 62c7e8a

Browse files
author
Anton Danshin
committed
A couple of minor improvements
+ added hasFired() method to the view + do not draw shape if it is empty, i.e. radius == 0 or rect.isEmpty()
1 parent 8c80257 commit 62c7e8a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ private void updateDismissButton() {
433433
}
434434
}
435435

436+
public boolean hasFired() {
437+
return mPrefsManager.hasFired();
438+
}
439+
436440
/**
437441
* REDRAW LISTENER - this ensures we redraw after activity finishes laying out
438442
*/

library/src/main/java/uk/co/deanwild/materialshowcaseview/shape/CircleShape.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ public void setRadius(int radius) {
4747

4848
@Override
4949
public void draw(Canvas canvas, Paint paint, int x, int y, int padding) {
50-
canvas.drawCircle(x, y, radius + padding, paint);
50+
if (radius > 0) {
51+
canvas.drawCircle(x, y, radius + padding, paint);
52+
}
5153
}
5254

5355
@Override

library/src/main/java/uk/co/deanwild/materialshowcaseview/shape/RectangleShape.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ private void init() {
5050

5151
@Override
5252
public void draw(Canvas canvas, Paint paint, int x, int y, int padding) {
53-
canvas.drawRect(
54-
rect.left + x - padding,
55-
rect.top + y - padding,
56-
rect.right + x + padding,
57-
rect.bottom + y + padding,
58-
paint
59-
);
60-
rect.offset(-x, -y);
53+
if (!rect.isEmpty()) {
54+
canvas.drawRect(
55+
rect.left + x - padding,
56+
rect.top + y - padding,
57+
rect.right + x + padding,
58+
rect.bottom + y + padding,
59+
paint
60+
);
61+
}
6162
}
6263

6364
@Override

0 commit comments

Comments
 (0)