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();
}
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;
}
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();
}
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();
}
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;
}
Aggregations