/** * Toggle keyboard according flag. If flag equals 0, hide or close keyboard. Otherwise, open. * @param flag A flag which indicate it should open keyboard or not. */ public void toggleKeyboard(int flag) { InputMethodManager inputMethodManager = (InputMethodManager) (context.getSystemService(Context.INPUT_METHOD_SERVICE)); if (inputMethodManager != null) { if (flag == 0) { View currentFocus = ((AppCompatActivity) context).getCurrentFocus(); if (currentFocus != null) { inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); } } else { inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } } } }
private void save() { if (TextUtils.isEmpty(recording.getTitle())) { if (activity.getCurrentFocus() != null) { Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_empty_title), Snackbar.LENGTH_SHORT).show(); } return; } if (!TextUtils.isEmpty(id)) { updateTimerRecording(); } else { addTimerRecording(); } }
/** * Checks certain given values for plausibility and if everything is fine * creates the intent that will be passed to the service to save the newly * created recording. */ private void save() { if (TextUtils.isEmpty(recording.getTitle()) && serverStatus.getHtspVersion() >= 21) { if (activity.getCurrentFocus() != null) { Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_empty_title), Snackbar.LENGTH_SHORT).show(); } return; } if (recording.getChannelId() == 0 && serverStatus.getHtspVersion() < 21) { if (activity.getCurrentFocus() != null) { Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_no_channel_selected), Snackbar.LENGTH_SHORT).show(); } return; } if (recording.getStart() >= recording.getStop()) { if (activity.getCurrentFocus() != null) { Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_start_time_past_stop_time), Snackbar.LENGTH_SHORT).show(); } return; } if (id > 0) { updateRecording(); } else { addRecording(); } }
/** * Checks certain given values for plausibility and if everything is fine * creates the intent that will be passed to the service to save the newly * created recording. */ private void save() { if (TextUtils.isEmpty(recording.getTitle())) { if (activity.getCurrentFocus() != null) { Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_empty_title), Snackbar.LENGTH_SHORT).show(); } return; } // The maximum durationTextView must be at least the minimum durationTextView if (recording.getMinDuration() > 0 && recording.getMaxDuration() > 0 && recording.getMaxDuration() < recording.getMinDuration()) { recording.setMaxDuration(recording.getMinDuration()); } if (!TextUtils.isEmpty(id)) { updateSeriesRecording(); } else { addSeriesRecording(); } }