Skip to content
Snippets Groups Projects
Commit 277aff65 authored by Fabio Heyming's avatar Fabio Heyming
Browse files

BUGFIXING LIKE HELL

parent f3b33d28
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,11 @@ public class Recyclerviewadapter_Shop extends RecyclerView.Adapter<Recyclerviewa ...@@ -32,7 +32,11 @@ public class Recyclerviewadapter_Shop extends RecyclerView.Adapter<Recyclerviewa
public Recyclerviewadapter_Shop(Context context, ArrayList<ShopItem> shopItemList){ public Recyclerviewadapter_Shop(Context context, ArrayList<ShopItem> shopItemList){
this.context = context; this.context = context;
CustomerActivity.setupShop();
this.shopItemList = shopItemList; this.shopItemList = shopItemList;
for(ShopItem sI:shopItemList){
Log.d("myTag", sI.item.name);
}
} }
......
...@@ -132,6 +132,24 @@ private ActivityCustomerBinding binding; ...@@ -132,6 +132,24 @@ private ActivityCustomerBinding binding;
return Double.compare(item1.item.price, item2.item.price); 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))) { if (inputString.equals(context.getString(R.string.restamount))) {
Collections.sort(shopItemList, new Comparator<ShopItem>() { Collections.sort(shopItemList, new Comparator<ShopItem>() {
...@@ -140,14 +158,51 @@ private ActivityCustomerBinding binding; ...@@ -140,14 +158,51 @@ private ActivityCustomerBinding binding;
return Double.compare( item2.quantity,item1.quantity); 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))) { if (inputString.equals(context.getString(R.string.name))) {
Collections.sort(shopItemList, new Comparator<ShopItem>() { Collections.sort(shopItemList, new Comparator<ShopItem>() {
@Override @Override
public int compare(ShopItem item1, ShopItem item2) { public int compare(ShopItem item1, ShopItem item2) {
return item1.item.name.compareTo(item2.item.name); 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);
} }
} }
......
...@@ -100,6 +100,8 @@ public class CustomerShopFragment extends Fragment { ...@@ -100,6 +100,8 @@ public class CustomerShopFragment extends Fragment {
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
} }
CustomerActivity.setupShop();
adapter.notifyDataSetChanged();
// Return the inflated rootView // Return the inflated rootView
return rootView; return rootView;
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
android:id="@+id/buttonEdit" android:id="@+id/buttonEdit"
android:layout_width="93dp" android:layout_width="93dp"
android:layout_height="41dp" android:layout_height="41dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="4dp"
android:text="@string/edit" android:text="@string/edit"
android:textSize="14sp" android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<string name="supplieraddress_dp">Lieferantenadresse:</string> <string name="supplieraddress_dp">Lieferantenadresse:</string>
<string name="edit">edit</string> <string name="edit">edit</string>
<string name="total">Gesamt</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="noemptyinput">Keine leere eingaben</string>
<string name="item_already_exists">Item existiert bereits</string> <string name="item_already_exists">Item existiert bereits</string>
<string name="added_to_shopping_cart">Zum Einkaufswagen hinzugefügt</string> <string name="added_to_shopping_cart">Zum Einkaufswagen hinzugefügt</string>
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<string name="edit">EDIT</string> <string name="edit">EDIT</string>
<string name="sum_dp">Sum:</string> <string name="sum_dp">Sum:</string>
<string name="total">Total</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="reserve">reserve</string>
<string name="ordered">ordered</string> <string name="ordered">ordered</string>
<string name="noemptyinput">noEmptyInput</string> <string name="noemptyinput">noEmptyInput</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment