From c373657472d5f33a5afb039452b384a7033667bb Mon Sep 17 00:00:00 2001 From: lizhi Date: Mon, 31 Jul 2017 12:24:47 +0800 Subject: [PATCH] android second input manually don't take effect bug fix --- src/android/DatePickerPlugin.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/android/DatePickerPlugin.java b/src/android/DatePickerPlugin.java index b76edcc..2795c95 100644 --- a/src/android/DatePickerPlugin.java +++ b/src/android/DatePickerPlugin.java @@ -36,6 +36,7 @@ import android.widget.DatePicker; import android.widget.DatePicker.OnDateChangedListener; import android.widget.TimePicker; +import android.widget.Toast; @SuppressLint("NewApi") public class DatePickerPlugin extends CordovaPlugin { @@ -102,7 +103,16 @@ public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { timePickerHour = hourOfDay; timePickerMinute = minute; } + + @Override + public void onClick(DialogInterface dialog, int which) { + if(dialog instanceof TimePickerDialog){ + ((TimePickerDialog)dialog).getWindow().getDecorView().clearFocus(); + } + super.onClick(dialog, which); + } }; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { timeDialog.setCancelable(true); timeDialog.setCanceledOnTouchOutside(false); @@ -130,7 +140,7 @@ public void onClick(DialogInterface dialog, int which) { } }); String labelOk = jsonDate.okText.isEmpty() ? currentCtx.getString(android.R.string.ok) : jsonDate.okText; - timeDialog.setButton(DialogInterface.BUTTON_POSITIVE, labelOk, timeDialog); + timeDialog.setButton(DialogInterface.BUTTON_POSITIVE, labelOk,timeDialog); } timeDialog.show(); timeDialog.updateTime(new Random().nextInt(23), new Random().nextInt(59));