diff --git a/app/src/main/java/com/example/mampfmobil/ui/Classes/Recyclerviewadapter_Shop.java b/app/src/main/java/com/example/mampfmobil/ui/Classes/Recyclerviewadapter_Shop.java index 6c23b77be2b6f135ced720ba3acf026349300943..2892b4dedc5a0fd06df34c44d88cf912762d25b0 100644 --- a/app/src/main/java/com/example/mampfmobil/ui/Classes/Recyclerviewadapter_Shop.java +++ b/app/src/main/java/com/example/mampfmobil/ui/Classes/Recyclerviewadapter_Shop.java @@ -32,7 +32,11 @@ public class Recyclerviewadapter_Shop extends RecyclerView.Adapter<Recyclerviewa public Recyclerviewadapter_Shop(Context context, ArrayList<ShopItem> shopItemList){ this.context = context; + CustomerActivity.setupShop(); this.shopItemList = shopItemList; + for(ShopItem sI:shopItemList){ + Log.d("myTag", sI.item.name); + } } diff --git a/app/src/main/java/com/example/mampfmobil/ui/CustomerActivity.java b/app/src/main/java/com/example/mampfmobil/ui/CustomerActivity.java index 9ede2334513f438b7e9c09d42ab7b285539db5ed..08f6318e47bd5879a8003d588618ee69d67b493f 100644 --- a/app/src/main/java/com/example/mampfmobil/ui/CustomerActivity.java +++ b/app/src/main/java/com/example/mampfmobil/ui/CustomerActivity.java @@ -132,6 +132,24 @@ private ActivityCustomerBinding binding; return Double.compare(item1.item.price, item2.item.price); } }); + ArrayList<ShopItem> rearrangedList = new ArrayList<>(); + for(ShopItem sI : shopItemList){ + boolean fav = false; + for (ShopItem favorit : MampfMobil.currentCustomer.favoriten) { + if (sI == favorit) { + fav = true; + break; // Exit the inner loop since a match is found + } + } + + if (fav) { + rearrangedList.add(0, sI); // Add the item to the beginning of the rearrangedList + } else { + rearrangedList.add(sI); // Add the item to the end of the rearrangedList + } + } + shopItemList.clear(); + shopItemList.addAll(rearrangedList); } if (inputString.equals(context.getString(R.string.restamount))) { Collections.sort(shopItemList, new Comparator<ShopItem>() { @@ -140,14 +158,51 @@ private ActivityCustomerBinding binding; return Double.compare( item2.quantity,item1.quantity); } }); + ArrayList<ShopItem> rearrangedList = new ArrayList<>(); + for(ShopItem sI : shopItemList){ + boolean fav = false; + for (ShopItem favorit : MampfMobil.currentCustomer.favoriten) { + if (sI == favorit) { + fav = true; + break; // Exit the inner loop since a match is found + } + } + + if (fav) { + rearrangedList.add(0, sI); // Add the item to the beginning of the rearrangedList + } else { + rearrangedList.add(sI); // Add the item to the end of the rearrangedList + } + } + shopItemList.clear(); + shopItemList.addAll(rearrangedList); } if (inputString.equals(context.getString(R.string.name))) { + Collections.sort(shopItemList, new Comparator<ShopItem>() { @Override public int compare(ShopItem item1, ShopItem item2) { return item1.item.name.compareTo(item2.item.name); } }); + ArrayList<ShopItem> rearrangedList = new ArrayList<>(); + for(ShopItem sI : shopItemList){ + boolean fav = false; + for (ShopItem favorit : MampfMobil.currentCustomer.favoriten) { + if (sI == favorit) { + fav = true; + break; // Exit the inner loop since a match is found + } + } + + if (fav) { + rearrangedList.add(0, sI); // Add the item to the beginning of the rearrangedList + } else { + rearrangedList.add(sI); // Add the item to the end of the rearrangedList + } + } + shopItemList.clear(); + shopItemList.addAll(rearrangedList); } } diff --git a/app/src/main/java/com/example/mampfmobil/ui/customer/CustomerShopFragment.java b/app/src/main/java/com/example/mampfmobil/ui/customer/CustomerShopFragment.java index 9e6e4c21f718e62ff4b5ce47d18fd1d0b4ad8309..51bd6f47264f62c7e3ac150de9b1c9e90e5c63e3 100644 --- a/app/src/main/java/com/example/mampfmobil/ui/customer/CustomerShopFragment.java +++ b/app/src/main/java/com/example/mampfmobil/ui/customer/CustomerShopFragment.java @@ -100,6 +100,8 @@ public class CustomerShopFragment extends Fragment { actionBar.setDisplayHomeAsUpEnabled(true); } + CustomerActivity.setupShop(); + adapter.notifyDataSetChanged(); // Return the inflated rootView return rootView; } diff --git a/app/src/main/res/layout/recyclerview_edititemrow.xml b/app/src/main/res/layout/recyclerview_edititemrow.xml index 12a8112eea58d98d0e83a18e87c2fa5ceb3769ef..30d4131586e96f66a7402a752c2afa0a3d00c5cc 100644 --- a/app/src/main/res/layout/recyclerview_edititemrow.xml +++ b/app/src/main/res/layout/recyclerview_edititemrow.xml @@ -54,7 +54,7 @@ android:id="@+id/buttonEdit" android:layout_width="93dp" android:layout_height="41dp" - android:layout_marginEnd="16dp" + android:layout_marginEnd="4dp" android:text="@string/edit" android:textSize="14sp" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index 332ffe8916ebc1014f77253862b3a41436a9b464..a8afed9f1ea9afc99725368fda162a4170dee735 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -61,7 +61,7 @@ <string name="supplieraddress_dp">Lieferantenadresse:</string> <string name="edit">edit</string> <string name="total">Gesamt</string> - <string name="sold_units_dp">Verkaufte Items:</string> + <string name="sold_units_dp">Verkäufe:</string> <string name="noemptyinput">Keine leere eingaben</string> <string name="item_already_exists">Item existiert bereits</string> <string name="added_to_shopping_cart">Zum Einkaufswagen hinzugefügt</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 90f7c42f832982eb9cebe1f5fe2a0c77262c35ed..cbef0213dcbaac6f38a6f4c8a36c570773930a8c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,7 +58,7 @@ <string name="edit">EDIT</string> <string name="sum_dp">Sum:</string> <string name="total">Total</string> - <string name="sold_units_dp">Sold Units:</string> + <string name="sold_units_dp">Sales:</string> <string name="reserve">reserve</string> <string name="ordered">ordered</string> <string name="noemptyinput">noEmptyInput</string>