From f5d84419daaebed18a6ca07eecf9e949762d45ce Mon Sep 17 00:00:00 2001 From: Nedyalko Nikolov Date: Tue, 8 Mar 2016 16:27:32 +0200 Subject: [PATCH] Hot fix for DatePicker to emit date change only once. --- ui/date-picker/date-picker.android.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/date-picker/date-picker.android.ts b/ui/date-picker/date-picker.android.ts index 8a29dce26..c147e146c 100644 --- a/ui/date-picker/date-picker.android.ts +++ b/ui/date-picker/date-picker.android.ts @@ -100,20 +100,22 @@ export class DatePicker extends common.DatePicker { onDateChanged: function (picker: android.widget.DatePicker, year: number, month: number, day: number) { if (this.owner) { - + let dateIsChanged = false; if (year !== this.owner.year) { this.owner._onPropertyChangedFromNative(common.DatePicker.yearProperty, year); - this.owner._onPropertyChangedFromNative(common.DatePicker.dateProperty, new Date(year, this.owner.month - 1, this.owner.day)); + dateIsChanged = true; } - if ((month + 1) !== this.owner.month) { this.owner._onPropertyChangedFromNative(common.DatePicker.monthProperty, month + 1); - this.owner._onPropertyChangedFromNative(common.DatePicker.dateProperty, new Date(this.owner.year, month, this.owner.day)); + dateIsChanged = true; } - if (day !== this.owner.day) { this.owner._onPropertyChangedFromNative(common.DatePicker.dayProperty, day); - this.owner._onPropertyChangedFromNative(common.DatePicker.dateProperty, new Date(this.owner.year, this.owner.month - 1, day)); + dateIsChanged = true; + } + + if (dateIsChanged) { + this.owner._onPropertyChangedFromNative(common.DatePicker.dateProperty, new Date(year, month, day)); } } }