@@ -125,6 +125,7 @@ public class WeekView extends View {
125
125
private double mScrollToHour = -1 ;
126
126
private ScaleGestureDetector mScaleDetector ;
127
127
private boolean mIsZooming ;
128
+ private int mEventCornerRadius = 0 ;
128
129
129
130
// Listeners.
130
131
private EventClickListener mEventClickListener ;
@@ -287,6 +288,7 @@ public WeekView(Context context, AttributeSet attrs, int defStyleAttr) {
287
288
mOverlappingEventGap = a .getDimensionPixelSize (R .styleable .WeekView_overlappingEventGap , mOverlappingEventGap );
288
289
mEventMarginVertical = a .getDimensionPixelSize (R .styleable .WeekView_eventMarginVertical , mEventMarginVertical );
289
290
mXScrollingSpeed = a .getFloat (R .styleable .WeekView_xScrollingSpeed , mXScrollingSpeed );
291
+ mEventCornerRadius = a .getDimensionPixelSize (R .styleable .WeekView_eventCornerRadius , mEventCornerRadius );
290
292
} finally {
291
293
a .recycle ();
292
294
}
@@ -421,7 +423,7 @@ protected void onDraw(Canvas canvas) {
421
423
canvas .drawRect (0 , 0 , mTimeTextWidth + mHeaderColumnPadding * 2 , mHeaderTextHeight + mHeaderRowPadding * 2 , mHeaderBackgroundPaint );
422
424
423
425
// Hide anything that is in the bottom margin of the header row.
424
- canvas .drawRect (mHeaderColumnWidth , mHeaderTextHeight + mHeaderRowPadding * 2 , getWidth (), mHeaderRowPadding * 2 + mHeaderTextHeight + mHeaderMarginBottom + mTimeTextHeight /2 - mHourSeparatorHeight / 2 , mHeaderColumnBackgroundPaint );
426
+ canvas .drawRect (mHeaderColumnWidth , mHeaderTextHeight + mHeaderRowPadding * 2 , getWidth (), mHeaderRowPadding * 2 + mHeaderTextHeight + mHeaderMarginBottom + mTimeTextHeight /2 , mHeaderColumnBackgroundPaint );
425
427
}
426
428
427
429
private void drawTimeColumnAndAxes (Canvas canvas ) {
@@ -667,9 +669,6 @@ private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
667
669
668
670
// Calculate top.
669
671
float top = mHourHeight * 24 * mEventRects .get (i ).top / 1440 + mCurrentOrigin .y + mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight /2 + mEventMarginVertical ;
670
- float originalTop = top ;
671
- if (top < mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight /2 )
672
- top = mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight /2 ;
673
672
674
673
// Calculate bottom.
675
674
float bottom = mEventRects .get (i ).bottom ;
@@ -679,11 +678,9 @@ private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
679
678
float left = startFromPixel + mEventRects .get (i ).left * mWidthPerDay ;
680
679
if (left < startFromPixel )
681
680
left += mOverlappingEventGap ;
682
- float originalLeft = left ;
683
681
float right = left + mEventRects .get (i ).width * mWidthPerDay ;
684
682
if (right < startFromPixel + mWidthPerDay )
685
683
right -= mOverlappingEventGap ;
686
- if (left < mHeaderColumnWidth ) left = mHeaderColumnWidth ;
687
684
688
685
// Draw the event and the event name on top of it.
689
686
RectF eventRectF = new RectF (left , top , right , bottom );
@@ -696,8 +693,8 @@ eventRectF.top < getHeight() &&
696
693
) {
697
694
mEventRects .get (i ).rectF = eventRectF ;
698
695
mEventBackgroundPaint .setColor (mEventRects .get (i ).event .getColor () == 0 ? mDefaultEventColor : mEventRects .get (i ).event .getColor ());
699
- canvas .drawRect (mEventRects .get (i ).rectF , mEventBackgroundPaint );
700
- drawEventTitle (mEventRects .get (i ).event , mEventRects .get (i ).rectF , canvas , originalTop , originalLeft );
696
+ canvas .drawRoundRect (mEventRects .get (i ).rectF , mEventCornerRadius , mEventCornerRadius , mEventBackgroundPaint );
697
+ drawEventTitle (mEventRects .get (i ).event , mEventRects .get (i ).rectF , canvas , top , left );
701
698
}
702
699
else
703
700
mEventRects .get (i ).rectF = null ;
@@ -1389,6 +1386,19 @@ public void setOverlappingEventGap(int overlappingEventGap) {
1389
1386
invalidate ();
1390
1387
}
1391
1388
1389
+ public int getEventCornerRadius () {
1390
+ return mEventCornerRadius ;
1391
+ }
1392
+
1393
+ /**
1394
+ * Set corner radius for event rect.
1395
+ *
1396
+ * @param eventCornerRadius the radius in px.
1397
+ */
1398
+ public void setEventCornerRadius (int eventCornerRadius ) {
1399
+ mEventCornerRadius = eventCornerRadius ;
1400
+ }
1401
+
1392
1402
public int getEventMarginVertical () {
1393
1403
return mEventMarginVertical ;
1394
1404
}
0 commit comments