From fef0ed57a07ba09fb45290f023098af168c6a2dc Mon Sep 17 00:00:00 2001 From: Aaron He Date: Fri, 13 Dec 2013 13:51:49 -0800 Subject: [PATCH] Fix a bug where selected date won't be selected if OnDateSelected is null --- MonoDroid.TimesSquare/CalendarPickerView.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MonoDroid.TimesSquare/CalendarPickerView.cs b/MonoDroid.TimesSquare/CalendarPickerView.cs index 9633294..85be095 100644 --- a/MonoDroid.TimesSquare/CalendarPickerView.cs +++ b/MonoDroid.TimesSquare/CalendarPickerView.cs @@ -96,12 +96,15 @@ private void OnCellClicked(MonthCellDescriptor cell) OnInvalidDateSelected(this, new DateSelectedEventArgs(clickedDate)); } } - else if (OnDateSelected != null) { - if (DoSelectDate(clickedDate, cell)) { - OnDateSelected(this, new DateSelectedEventArgs(clickedDate)); - } - else { - OnDateUnselected(this, new DateSelectedEventArgs(clickedDate)); + else { + bool wasSelected = DoSelectDate(clickedDate, cell); + if (OnDateSelected != null) { + if (wasSelected) { + OnDateSelected(this, new DateSelectedEventArgs(clickedDate)); + } + else if(OnDateUnselected != null) { + OnDateUnselected(this, new DateSelectedEventArgs(clickedDate)); + } } } }