close keyboard when sleep time has been selected

This commit is contained in:
asdoi 2020-09-08 16:34:00 +02:00
parent 9e1c50ea63
commit 22e9a9af7e
1 changed files with 7 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@ -137,6 +138,7 @@ public class SleepTimerDialog extends DialogFragment {
if (controller != null) {
controller.setSleepTimer(time);
}
closeKeyboard(content);
} catch (NumberFormatException e) {
e.printStackTrace();
Snackbar.make(content, R.string.time_dialog_invalid_input, Snackbar.LENGTH_LONG).show();
@ -153,4 +155,9 @@ public class SleepTimerDialog extends DialogFragment {
timeDisplay.setVisibility(controller.sleepTimerActive() ? View.VISIBLE : View.GONE);
time.setText(Converter.getDurationStringLong((int) controller.getSleepTimerTimeLeft()));
}
private void closeKeyboard(View content) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(content.getWindowToken(), 0);
}
}