1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.content.browser.input;
7 import android.content.Context;
8 import android.content.DialogInterface;
9 import android.widget.DatePicker;
12 * The behavior of the DatePickerDialog changed after JellyBean so it now calls
13 * OndateSetListener.onDateSet() even when the dialog is dismissed (e.g. back button, tap
14 * outside). This class will call the listener instead of the DatePickerDialog only when the
15 * BUTTON_POSITIVE has been clicked.
17 class ChromeDatePickerDialog extends android.app.DatePickerDialog {
18 private final OnDateSetListener mCallBack;
20 public ChromeDatePickerDialog(Context context,
21 OnDateSetListener callBack,
25 super(context, 0, callBack, year, monthOfYear, dayOfMonth);
30 * The superclass DatePickerDialog has null for OnDateSetListener so we need to call the
34 public void onClick(DialogInterface dialog, int which) {
35 if (which == BUTTON_POSITIVE && mCallBack != null) {
36 DatePicker datePicker = getDatePicker();
37 datePicker.clearFocus();
38 mCallBack.onDateSet(datePicker, datePicker.getYear(),
39 datePicker.getMonth(), datePicker.getDayOfMonth());