use of xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.ShoppingListItemBottomSheet in project grocy-android by patzly.
the class ShoppingListFragment method showItemBottomSheet.
private void showItemBottomSheet(ShoppingListItem item) {
if (item == null) {
return;
}
Bundle bundle = new Bundle();
Double amountInQuUnit = viewModel.getShoppingListItemAmountsHashMap().get(item.getId());
Product product = viewModel.getProductHashMap().get(item.getProductIdInt());
String amountStr;
if (product != null && amountInQuUnit != null) {
bundle.putString(Constants.ARGUMENT.PRODUCT_NAME, product.getName());
QuantityUnit quantityUnit = viewModel.getQuantityUnitHashMap().get(item.getQuIdInt());
String quStr = pluralUtil.getQuantityUnitPlural(quantityUnit, amountInQuUnit);
if (quStr != null) {
amountStr = getString(R.string.subtitle_amount, NumUtil.trim(amountInQuUnit), quStr);
} else {
amountStr = NumUtil.trim(amountInQuUnit);
}
} else if (product != null) {
bundle.putString(Constants.ARGUMENT.PRODUCT_NAME, product.getName());
QuantityUnit quantityUnit = viewModel.getQuantityUnitHashMap().get(product.getQuIdStockInt());
String quStr = pluralUtil.getQuantityUnitPlural(quantityUnit, item.getAmountDouble());
if (quStr != null) {
amountStr = getString(R.string.subtitle_amount, NumUtil.trim(item.getAmountDouble()), quStr);
} else {
amountStr = NumUtil.trim(item.getAmountDouble());
}
} else {
amountStr = NumUtil.trim(item.getAmountDouble());
}
bundle.putString(ARGUMENT.AMOUNT, amountStr);
bundle.putParcelable(Constants.ARGUMENT.SHOPPING_LIST_ITEM, item);
bundle.putBoolean(Constants.ARGUMENT.SHOW_OFFLINE, viewModel.isOffline());
activity.showBottomSheet(new ShoppingListItemBottomSheet(), bundle);
}
Aggregations