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

Removed favorite bug

parent 462dc528
No related branches found
No related tags found
1 merge request!1Mal aufn Master megren
Showing with 80 additions and 4 deletions
...@@ -2,6 +2,7 @@ package com.example.mampfmobil.ui.Classes; ...@@ -2,6 +2,7 @@ package com.example.mampfmobil.ui.Classes;
import android.util.Log; import android.util.Log;
import java.util.ArrayList;
import java.util.Vector; import java.util.Vector;
public class Customer { public class Customer {
...@@ -49,10 +50,14 @@ public class Customer { ...@@ -49,10 +50,14 @@ public class Customer {
favoriten.add(sI); favoriten.add(sI);
} }
public void removeFromFavourits(ShopItem sI){ public void removeFromFavourits(ShopItem sI){
ArrayList<ShopItem> itemsToRemove = new ArrayList<>();
for(ShopItem si: favoriten){ for(ShopItem si: favoriten){
if(si == sI){ if(si == sI){
favoriten.remove(si); itemsToRemove.add(si);
} }
} }
favoriten.removeAll(itemsToRemove);
} }
} }
...@@ -68,6 +68,7 @@ public class Recyclerviewadapter_Shop extends RecyclerView.Adapter<Recyclerviewa ...@@ -68,6 +68,7 @@ public class Recyclerviewadapter_Shop extends RecyclerView.Adapter<Recyclerviewa
holder.favBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { holder.favBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
......
...@@ -42,7 +42,7 @@ private ActivityCustomerBinding binding; ...@@ -42,7 +42,7 @@ private ActivityCustomerBinding binding;
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications) R.id.navigation_shop, R.id.navigation_shopping_cart, R.id.navigation_orders)
.build(); .build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_customer); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_customer);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
...@@ -106,4 +106,4 @@ private ActivityCustomerBinding binding; ...@@ -106,4 +106,4 @@ private ActivityCustomerBinding binding;
} }
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ import com.example.mampfmobil.MainActivity; ...@@ -14,6 +14,7 @@ import com.example.mampfmobil.MainActivity;
import com.example.mampfmobil.R; import com.example.mampfmobil.R;
import com.example.mampfmobil.databinding.ActivityCustomerBinding; import com.example.mampfmobil.databinding.ActivityCustomerBinding;
import com.example.mampfmobil.databinding.ActivitySupplierBinding; import com.example.mampfmobil.databinding.ActivitySupplierBinding;
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
public class SupplierActivity extends AppCompatActivity { public class SupplierActivity extends AppCompatActivity {
...@@ -29,11 +30,12 @@ public class SupplierActivity extends AppCompatActivity { ...@@ -29,11 +30,12 @@ public class SupplierActivity extends AppCompatActivity {
// Fragment "fragment_decide" wird angezeigt // Fragment "fragment_decide" wird angezeigt
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications) R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications, R.id.navigation_ordersSupplier)
.build(); .build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_supplier); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_supplier);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(binding.navView2, navController); NavigationUI.setupWithNavController(binding.navView2, navController);
binding.navView2.setLabelVisibilityMode(1);
} }
......
package com.example.mampfmobil.ui.supplier;
import androidx.lifecycle.ViewModelProvider;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.mampfmobil.R;
public class SupplierOrdersFragment extends Fragment {
private SupplierOrdersViewModel mViewModel;
public static SupplierOrdersFragment newInstance() {
return new SupplierOrdersFragment();
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_supplier_orders, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mViewModel = new ViewModelProvider(this).get(SupplierOrdersViewModel.class);
// TODO: Use the ViewModel
}
}
\ No newline at end of file
package com.example.mampfmobil.ui.supplier;
import androidx.lifecycle.ViewModel;
public class SupplierOrdersViewModel extends ViewModel {
// TODO: Implement the ViewModel
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.supplier.SupplierOrdersFragment">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello" />
</FrameLayout>
\ No newline at end of file
...@@ -12,5 +12,8 @@ ...@@ -12,5 +12,8 @@
<item <item
android:id="@+id/navigation_statistics" android:id="@+id/navigation_statistics"
android:title="@string/statistics" /> android:title="@string/statistics" />
<item
android:id="@+id/navigation_ordersSupplier"
android:title="@string/orders" />
</menu> </menu>
\ No newline at end of file
...@@ -22,4 +22,11 @@ ...@@ -22,4 +22,11 @@
android:name="com.example.mampfmobil.ui.supplier.SupplierStatisticsFragment" android:name="com.example.mampfmobil.ui.supplier.SupplierStatisticsFragment"
android:label="@string/statistics" android:label="@string/statistics"
tools:layout="@layout/fragment_supplier_statistics" /> tools:layout="@layout/fragment_supplier_statistics" />
<fragment
android:id="@+id/navigation_ordersSupplier"
android:name="com.example.mampfmobil.ui.supplier.SupplierOrdersFragment"
android:label="Orders"
tools:layout="@layout/fragment_supplier_orders" />
</navigation> </navigation>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment