From 1b36a5557b1ca0fa5e96f8ab1d8f5460aaaf2bbc Mon Sep 17 00:00:00 2001 From: Thomas Weidmann Date: Sun, 16 Feb 2020 18:34:03 +0100 Subject: [PATCH] =?UTF-8?q?sortieren=20nach=20titel=20und=20datum=20hinzug?= =?UTF-8?q?ef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/DisplaySearchListFragment.kt | 40 ------------------- .../viewmodel/DisplaySearchListViewmodel.kt | 30 -------------- .../layout/display_searchlist_fragment.xml | 8 +--- app/src/main/res/values/strings.xml | 1 + 4 files changed, 2 insertions(+), 77 deletions(-) diff --git a/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/view/DisplaySearchListFragment.kt b/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/view/DisplaySearchListFragment.kt index 85a1d7b7..7f830bac 100644 --- a/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/view/DisplaySearchListFragment.kt +++ b/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/view/DisplaySearchListFragment.kt @@ -64,46 +64,6 @@ class DisplaySearchListFragment : Fragment(){ binding.radioButtonVegan.setOnClickListener { viewModel.recipes.postValue(viewModel.recipesSortedTitle.value!!) } - /* - // Radio button logic - binding.radioButtonVegan.setOnClickListener{ - var sortedRecipes = viewModel.sortByVegan() - val adapter = DisplaySearchListAdaper(sortedRecipes,viewModel, requireContext()) - binding.recyclerViewSearchlistFragment.adapter = adapter - val observer = Observer> { items -> - exampleAdapter.setNewItems(items) - } - viewModel.recipes.observe(this.viewLifecycleOwner, observer) - - } - binding.radioButtonVegetarian.setOnClickListener{ - var sortedRecipesVegetarian = viewModel.sortByVegetarian() - val adapterVegetarian = DisplaySearchListAdaper(sortedRecipesVegetarian,viewModel, requireContext()) - binding.recyclerViewSearchlistFragment.adapter = adapterVegetarian - val observer = Observer> { items -> - exampleAdapter.setNewItems(items) - } - viewModel.recipes.observe(this.viewLifecycleOwner, observer) - - } - binding.radioButtonDate.setOnClickListener{ - viewModel.sortByDate() - - var sortedRecipesDate = viewModel.recipes.value!! - val adapterDate = DisplaySearchListAdaper(sortedRecipesDate,viewModel, requireContext()) - binding.recyclerViewSearchlistFragment.adapter = adapterDate - val observer = Observer> { items -> - exampleAdapter.setNewItems(items) - } - viewModel.recipes.observe(this.viewLifecycleOwner, observer) - - } - */ - - - //ERROR - - return binding.root } diff --git a/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/viewmodel/DisplaySearchListViewmodel.kt b/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/viewmodel/DisplaySearchListViewmodel.kt index 0af7b684..45cc6668 100644 --- a/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/viewmodel/DisplaySearchListViewmodel.kt +++ b/app/src/main/java/de/psekochbuch/exzellenzkoch/userinterfacelayer/viewmodel/DisplaySearchListViewmodel.kt @@ -60,35 +60,5 @@ class DisplaySearchListViewmodel(repo:PublicRecipeRepository) : ViewModel() { } })) } - - } - - - fun sortByVegan(): List{ - var sortedList = mutableListOf() - if(recipes.value != null) { - for (recipe in recipes.value!!) { - if(recipe.tags.contains("vegan")) { - sortedList.add(recipe) - } - } - } - return sortedList - - - } - fun sortByVegetarian() : List{ - var sortedList = mutableListOf() - if(recipes.value != null) { - for (recipe in recipes.value!!) { - if(recipe.tags.contains("vegetarisch")) { - sortedList.add(recipe) - } - } - } - return sortedList - } - fun sortByDate() { - } } \ No newline at end of file diff --git a/app/src/main/res/layout/display_searchlist_fragment.xml b/app/src/main/res/layout/display_searchlist_fragment.xml index 7392f84b..9b99743b 100644 --- a/app/src/main/res/layout/display_searchlist_fragment.xml +++ b/app/src/main/res/layout/display_searchlist_fragment.xml @@ -44,13 +44,7 @@ android:id="@+id/radioButton_vegan" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/vegan" /> - - + android:text="@string/titel" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ce62cafc..fd208b3d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -93,6 +93,7 @@ Zubereitungszeit: Teilen Ausloggen + Titel vegan