Search in sources :

Example 6 with BaseFragment

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();
}
Also used : Date(java.util.Date) FormDataMasterProductCatDueDate(xyz.zedler.patrick.grocy.model.FormDataMasterProductCatDueDate) BaseFragment(xyz.zedler.patrick.grocy.fragment.BaseFragment)

Aggregations

BaseFragment (xyz.zedler.patrick.grocy.fragment.BaseFragment)6 View (android.view.View)2 Bundle (android.os.Bundle)1 TextView (android.widget.TextView)1 MaterialToolbar (com.google.android.material.appbar.MaterialToolbar)1 Date (java.util.Date)1 ConsumeFragment (xyz.zedler.patrick.grocy.fragment.ConsumeFragment)1 InventoryFragment (xyz.zedler.patrick.grocy.fragment.InventoryFragment)1 MasterObjectListFragment (xyz.zedler.patrick.grocy.fragment.MasterObjectListFragment)1 PurchaseFragment (xyz.zedler.patrick.grocy.fragment.PurchaseFragment)1 SettingsFragment (xyz.zedler.patrick.grocy.fragment.SettingsFragment)1 ShoppingListFragment (xyz.zedler.patrick.grocy.fragment.ShoppingListFragment)1 StockOverviewFragment (xyz.zedler.patrick.grocy.fragment.StockOverviewFragment)1 TransferFragment (xyz.zedler.patrick.grocy.fragment.TransferFragment)1 FormDataMasterProductCatDueDate (xyz.zedler.patrick.grocy.model.FormDataMasterProductCatDueDate)1