@@ -127,6 +127,7 @@ public class WeekView extends View {
127127 private double mScrollToHour = -1 ;
128128 private ScaleGestureDetector mScaleDetector ;
129129 private boolean mIsZooming ;
130+ private int mEventCornerRadius = 0 ;
130131
131132 // Listeners.
132133 private EventClickListener mEventClickListener ;
@@ -289,6 +290,7 @@ public WeekView(Context context, AttributeSet attrs, int defStyleAttr) {
289290 mOverlappingEventGap = a .getDimensionPixelSize (R .styleable .WeekView_overlappingEventGap , mOverlappingEventGap );
290291 mEventMarginVertical = a .getDimensionPixelSize (R .styleable .WeekView_eventMarginVertical , mEventMarginVertical );
291292 mXScrollingSpeed = a .getFloat (R .styleable .WeekView_xScrollingSpeed , mXScrollingSpeed );
293+ mEventCornerRadius = a .getDimensionPixelSize (R .styleable .WeekView_eventCornerRadius , mEventCornerRadius );
292294 } finally {
293295 a .recycle ();
294296 }
@@ -429,7 +431,7 @@ protected void onDraw(Canvas canvas) {
429431 canvas .drawRect (0 , 0 , mTimeTextWidth + mHeaderColumnPadding * 2 , mHeaderTextHeight + mHeaderRowPadding * 2 , mHeaderBackgroundPaint );
430432
431433 // 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 );
433435 }
434436
435437 private void drawTimeColumnAndAxes (Canvas canvas ) {
@@ -675,9 +677,6 @@ private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
675677
676678 // Calculate top.
677679 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 ;
681680
682681 // Calculate bottom.
683682 float bottom = mEventRects .get (i ).bottom ;
@@ -687,11 +686,9 @@ private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
687686 float left = startFromPixel + mEventRects .get (i ).left * mWidthPerDay ;
688687 if (left < startFromPixel )
689688 left += mOverlappingEventGap ;
690- float originalLeft = left ;
691689 float right = left + mEventRects .get (i ).width * mWidthPerDay ;
692690 if (right < startFromPixel + mWidthPerDay )
693691 right -= mOverlappingEventGap ;
694- if (left < mHeaderColumnWidth ) left = mHeaderColumnWidth ;
695692
696693 // Draw the event and the event name on top of it.
697694 RectF eventRectF = new RectF (left , top , right , bottom );
@@ -704,8 +701,8 @@ eventRectF.top < getHeight() &&
704701 ) {
705702 mEventRects .get (i ).rectF = eventRectF ;
706703 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 );
709706 }
710707 else
711708 mEventRects .get (i ).rectF = null ;
@@ -1400,6 +1397,19 @@ public void setOverlappingEventGap(int overlappingEventGap) {
14001397 invalidate ();
14011398 }
14021399
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+
14031413 public int getEventMarginVertical () {
14041414 return mEventMarginVertical ;
14051415 }
0 commit comments