diff --git a/SheLi/src/main/java/net/buggy/shoplist/units/ShopItemListUnit.java b/SheLi/src/main/java/net/buggy/shoplist/units/ShopItemListUnit.java index 28442be..0180343 100644 --- a/SheLi/src/main/java/net/buggy/shoplist/units/ShopItemListUnit.java +++ b/SheLi/src/main/java/net/buggy/shoplist/units/ShopItemListUnit.java @@ -259,9 +259,7 @@ public void removed(ShopItem item) { dao.removeShopItem(item); if (item.isChecked()) { - final Product product = item.getProduct(); - product.setLastBuyDate(new Date()); - dao.saveProduct(product); + updateProductBuyDate(item, dao); } } @@ -327,10 +325,14 @@ private void initCleanButton(RelativeLayout parentView) { cleanCheckedButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + final Dao dao = getHostingActivity().getDao(); + final List selectedItems = adapter.getSelectedItems(); for (ShopItem selectedItem : selectedItems) { - getHostingActivity().getDao().removeShopItem(selectedItem); + dao.removeShopItem(selectedItem); + updateProductBuyDate(selectedItem, dao); } + cleanCheckedButton.setEnabled(false); } }); @@ -368,6 +370,12 @@ public void run() { } + private void updateProductBuyDate(ShopItem item, Dao dao) { + final Product product = item.getProduct(); + product.setLastBuyDate(new Date()); + dao.saveProduct(product); + } + private void initEmptyScreen(RelativeLayout parentView) { final ViewGroup defaultEmptyPanel = parentView.findViewById( R.id.unit_shop_item_list_empty_stub);