use of xyz.zedler.patrick.grocy.fragment.BaseFragment in project grocy-android by patzly.
the class DateBottomSheet method onDismiss.
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
super.onDismiss(dialog);
String date;
if (!keyboardInputEnabled) {
if (!binding.checkboxNeverExpires.isChecked()) {
calendar.set(binding.datePicker.getYear(), binding.datePicker.getMonth(), binding.datePicker.getDayOfMonth());
date = dateFormatGrocy.format(calendar.getTime());
} else {
date = Constants.DATE.NEVER_OVERDUE;
}
} else {
Date textFieldDate = getTextFieldDate();
if (textFieldDate != null) {
date = dateFormatGrocy.format(textFieldDate);
} else {
date = Constants.DATE.NEVER_OVERDUE;
}
}
BaseFragment currentFragment = activity.getCurrentFragment();
if (args.getInt(DATE_TYPE) == DUE_DATE) {
currentFragment.selectDueDate(date);
} else if (args.getInt(DATE_TYPE) == PURCHASED_DATE) {
currentFragment.selectPurchasedDate(date);
} else {
activity.getCurrentFragment().saveInput(date.equals(Constants.DATE.NEVER_OVERDUE) ? String.valueOf(-1) : String.valueOf(DateUtil.getDaysFromNow(date)), requireArguments());
}
currentFragment.onBottomSheetDismissed();
}
Aggregations