Search in sources :

Example 1 with BaseFragment

use of xyz.zedler.patrick.grocy.fragment.BaseFragment in project grocy-android by patzly.

the class MainActivity method onBackPressed.

@Override
public void onBackPressed() {
    BaseFragment currentFragment = getCurrentFragment();
    if (currentFragment.isSearchVisible()) {
        currentFragment.dismissSearch();
    } else {
        boolean handled = currentFragment.onBackPressed();
        if (!handled) {
            super.onBackPressed();
        }
        if (!isServerUrlEmpty()) {
            binding.bottomAppBar.show();
        // isScrollRestored = true;
        }
    }
    hideKeyboard();
}
Also used : BaseFragment(xyz.zedler.patrick.grocy.fragment.BaseFragment)

Example 2 with BaseFragment

use of xyz.zedler.patrick.grocy.fragment.BaseFragment in project grocy-android by patzly.

the class MasterDeleteBottomSheet method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_bottomsheet_master_delete, container, false);
    activity = (MainActivity) getActivity();
    assert activity != null;
    String entity = requireArguments().getString(Constants.ARGUMENT.ENTITY);
    String textName = requireArguments().getString(Constants.ARGUMENT.OBJECT_NAME);
    int objectId = requireArguments().getInt(Constants.ARGUMENT.OBJECT_ID);
    int entityStrId;
    switch(entity) {
        case GrocyApi.ENTITY.PRODUCTS:
            entityStrId = R.string.property_product;
            break;
        case GrocyApi.ENTITY.QUANTITY_UNITS:
            entityStrId = R.string.property_quantity_unit;
            break;
        case GrocyApi.ENTITY.LOCATIONS:
            entityStrId = R.string.property_location;
            break;
        case GrocyApi.ENTITY.PRODUCT_GROUPS:
            entityStrId = R.string.property_product_group;
            break;
        default:
            // STORES
            entityStrId = R.string.property_store;
    }
    String entityText = getString(entityStrId);
    TextView textView = view.findViewById(R.id.text_master_delete_question);
    if (entity.equals(GrocyApi.ENTITY.PRODUCTS)) {
        textView.setText(activity.getString(R.string.msg_master_delete_product, textName));
    } else {
        textView.setText(activity.getString(R.string.msg_master_delete, entityText, textName));
    }
    view.findViewById(R.id.button_master_delete_delete).setOnClickListener(v -> {
        BaseFragment currentFragment = activity.getCurrentFragment();
        currentFragment.deleteObject(objectId);
        dismiss();
    });
    view.findViewById(R.id.button_master_delete_cancel).setOnClickListener(v -> dismiss());
    return view;
}
Also used : TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) BaseFragment(xyz.zedler.patrick.grocy.fragment.BaseFragment)

Example 3 with BaseFragment

use of xyz.zedler.patrick.grocy.fragment.BaseFragment in project grocy-android by patzly.

the class StoresBottomSheet method onItemRowClicked.

@Override
public void onItemRowClicked(int position) {
    BaseFragment currentFragment = activity.getCurrentFragment();
    currentFragment.selectStore(stores.get(position));
    dismiss();
}
Also used : BaseFragment(xyz.zedler.patrick.grocy.fragment.BaseFragment)

Example 4 with BaseFragment

use of xyz.zedler.patrick.grocy.fragment.BaseFragment in project grocy-android by patzly.

the class DrawerBottomSheet method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    binding = FragmentBottomsheetDrawerBinding.inflate(inflater, container, false);
    activity = (MainActivity) requireActivity();
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
    binding.buttonDrawerShoppingMode.setOnClickListener(v -> navigateDeepLink(R.string.deep_link_shoppingModeFragment));
    ClickUtil.setOnClickListeners(this, binding.linearDrawerStock, binding.linearDrawerShoppingList, binding.linearDrawerConsume, binding.linearDrawerPurchase, binding.linearDrawerTransfer, binding.linearDrawerInventory, binding.linearDrawerMasterData, binding.linearDrawerSettings, binding.linearDrawerFeedback, binding.linearDrawerHelp);
    BaseFragment currentFragment = activity.getCurrentFragment();
    if (currentFragment instanceof StockOverviewFragment) {
        select(binding.linearDrawerStock, binding.textDrawerStock, false);
    } else if (currentFragment instanceof ShoppingListFragment) {
        select(binding.linearDrawerShoppingList, binding.textDrawerShoppingList, false);
    } else if (currentFragment instanceof ConsumeFragment) {
        select(binding.linearDrawerConsume, null, true);
    } else if (currentFragment instanceof PurchaseFragment) {
        select(binding.linearDrawerPurchase, null, true);
    } else if (currentFragment instanceof TransferFragment) {
        select(binding.linearDrawerTransfer, null, true);
    } else if (currentFragment instanceof InventoryFragment) {
        select(binding.linearDrawerInventory, null, true);
    } else if (currentFragment instanceof MasterObjectListFragment) {
        select(binding.linearDrawerMasterData, binding.textDrawerMasterData, false);
    } else if (currentFragment instanceof SettingsFragment) {
        select(binding.linearDrawerSettings, binding.textDrawerSettings, false);
    }
    hideDisabledFeatures();
    return binding.getRoot();
}
Also used : SettingsFragment(xyz.zedler.patrick.grocy.fragment.SettingsFragment) StockOverviewFragment(xyz.zedler.patrick.grocy.fragment.StockOverviewFragment) MasterObjectListFragment(xyz.zedler.patrick.grocy.fragment.MasterObjectListFragment) ConsumeFragment(xyz.zedler.patrick.grocy.fragment.ConsumeFragment) ShoppingListFragment(xyz.zedler.patrick.grocy.fragment.ShoppingListFragment) PurchaseFragment(xyz.zedler.patrick.grocy.fragment.PurchaseFragment) InventoryFragment(xyz.zedler.patrick.grocy.fragment.InventoryFragment) BaseFragment(xyz.zedler.patrick.grocy.fragment.BaseFragment) TransferFragment(xyz.zedler.patrick.grocy.fragment.TransferFragment)

Example 5 with BaseFragment

use of xyz.zedler.patrick.grocy.fragment.BaseFragment in project grocy-android by patzly.

the class MasterProductBottomSheet method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_bottomsheet_master_product, container, false);
    activity = (MainActivity) getActivity();
    assert activity != null;
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
    Bundle bundle = getArguments();
    if (bundle != null) {
        product = bundle.getParcelable(Constants.ARGUMENT.PRODUCT);
        location = bundle.getParcelable(Constants.ARGUMENT.LOCATION);
        quantityUnitPurchase = bundle.getParcelable(Constants.ARGUMENT.QUANTITY_UNIT_PURCHASE);
        quantityUnitStock = bundle.getParcelable(Constants.ARGUMENT.QUANTITY_UNIT_STOCK);
        productGroup = bundle.getParcelable(Constants.ARGUMENT.PRODUCT_GROUP);
    }
    // VIEWS
    itemName = view.findViewById(R.id.item_master_product_name);
    cardDescription = view.findViewById(R.id.card_master_product_description);
    itemLocation = view.findViewById(R.id.item_master_product_location);
    itemMinStockAmount = view.findViewById(R.id.item_master_product_min_stock_amount);
    itemQuPurchase = view.findViewById(R.id.item_master_product_qu_purchase);
    itemQuStock = view.findViewById(R.id.item_master_product_qu_stock);
    itemQuFactor = view.findViewById(R.id.item_master_product_qu_factor);
    itemProductGroup = view.findViewById(R.id.item_master_product_product_group);
    // TOOLBAR
    MaterialToolbar toolbar = view.findViewById(R.id.toolbar_master_product);
    toolbar.setOnMenuItemClickListener(item -> {
        BaseFragment fragmentCurrent = activity.getCurrentFragment();
        if (item.getItemId() == R.id.action_edit) {
            fragmentCurrent.editObject(product);
        } else if (item.getItemId() == R.id.action_copy) {
            fragmentCurrent.copyProduct(product);
        } else if (item.getItemId() == R.id.action_delete) {
            fragmentCurrent.deleteObjectSafely(product);
        }
        dismiss();
        return true;
    });
    setData();
    return view;
}
Also used : MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) Bundle(android.os.Bundle) View(android.view.View) 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