@@ -127,6 +127,7 @@ public class WeekView extends View {
127
127
private double mScrollToHour = -1 ;
128
128
private ScaleGestureDetector mScaleDetector ;
129
129
private boolean mIsZooming ;
130
+ private int mEventCornerRadius = 0 ;
130
131
131
132
// Listeners.
132
133
private EventClickListener mEventClickListener ;
@@ -289,6 +290,7 @@ public WeekView(Context context, AttributeSet attrs, int defStyleAttr) {
289
290
mOverlappingEventGap = a .getDimensionPixelSize (R .styleable .WeekView_overlappingEventGap , mOverlappingEventGap );
290
291
mEventMarginVertical = a .getDimensionPixelSize (R .styleable .WeekView_eventMarginVertical , mEventMarginVertical );
291
292
mXScrollingSpeed = a .getFloat (R .styleable .WeekView_xScrollingSpeed , mXScrollingSpeed );
293
+ mEventCornerRadius = a .getDimensionPixelSize (R .styleable .WeekView_eventCornerRadius , mEventCornerRadius );
292
294
} finally {
293
295
a .recycle ();
294
296
}
@@ -429,7 +431,7 @@ protected void onDraw(Canvas canvas) {
429
431
canvas .drawRect (0 , 0 , mTimeTextWidth + mHeaderColumnPadding * 2 , mHeaderTextHeight + mHeaderRowPadding * 2 , mHeaderBackgroundPaint );
430
432
431
433
// Hide anything that is in the bottom margin of the header row.
432
- canvas .drawRect (mHeaderColumnWidth , mHeaderTextHeight + mHeaderRowPadding * 2 , getWidth (), mHeaderRowPadding * 2 + mHeaderTextHeight + mHeaderMarginBottom + mTimeTextHeight /2 - mHourSeparatorHeight / 2 , mHeaderColumnBackgroundPaint );
434
+ canvas .drawRect (mHeaderColumnWidth , mHeaderTextHeight + mHeaderRowPadding * 2 , getWidth (), mHeaderRowPadding * 2 + mHeaderTextHeight + mHeaderMarginBottom + mTimeTextHeight /2 , mHeaderColumnBackgroundPaint );
433
435
}
434
436
435
437
private void drawTimeColumnAndAxes (Canvas canvas ) {
@@ -675,9 +677,6 @@ private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
675
677
676
678
// Calculate top.
677
679
float top = mHourHeight * 24 * mEventRects .get (i ).top / 1440 + mCurrentOrigin .y + mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight /2 + mEventMarginVertical ;
678
- float originalTop = top ;
679
- if (top < mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight /2 )
680
- top = mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight /2 ;
681
680
682
681
// Calculate bottom.
683
682
float bottom = mEventRects .get (i ).bottom ;
@@ -687,11 +686,9 @@ private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
687
686
float left = startFromPixel + mEventRects .get (i ).left * mWidthPerDay ;
688
687
if (left < startFromPixel )
689
688
left += mOverlappingEventGap ;
690
- float originalLeft = left ;
691
689
float right = left + mEventRects .get (i ).width * mWidthPerDay ;
692
690
if (right < startFromPixel + mWidthPerDay )
693
691
right -= mOverlappingEventGap ;
694
- if (left < mHeaderColumnWidth ) left = mHeaderColumnWidth ;
695
692
696
693
// Draw the event and the event name on top of it.
697
694
RectF eventRectF = new RectF (left , top , right , bottom );
@@ -704,8 +701,8 @@ eventRectF.top < getHeight() &&
704
701
) {
705
702
mEventRects .get (i ).rectF = eventRectF ;
706
703
mEventBackgroundPaint .setColor (mEventRects .get (i ).event .getColor () == 0 ? mDefaultEventColor : mEventRects .get (i ).event .getColor ());
707
- canvas .drawRect (mEventRects .get (i ).rectF , mEventBackgroundPaint );
708
- drawEventTitle (mEventRects .get (i ).event , mEventRects .get (i ).rectF , canvas , originalTop , originalLeft );
704
+ canvas .drawRoundRect (mEventRects .get (i ).rectF , mEventCornerRadius , mEventCornerRadius , mEventBackgroundPaint );
705
+ drawEventTitle (mEventRects .get (i ).event , mEventRects .get (i ).rectF , canvas , top , left );
709
706
}
710
707
else
711
708
mEventRects .get (i ).rectF = null ;
@@ -1400,6 +1397,19 @@ public void setOverlappingEventGap(int overlappingEventGap) {
1400
1397
invalidate ();
1401
1398
}
1402
1399
1400
+ public int getEventCornerRadius () {
1401
+ return mEventCornerRadius ;
1402
+ }
1403
+
1404
+ /**
1405
+ * Set corner radius for event rect.
1406
+ *
1407
+ * @param eventCornerRadius the radius in px.
1408
+ */
1409
+ public void setEventCornerRadius (int eventCornerRadius ) {
1410
+ mEventCornerRadius = eventCornerRadius ;
1411
+ }
1412
+
1403
1413
public int getEventMarginVertical () {
1404
1414
return mEventMarginVertical ;
1405
1415
}
0 commit comments