Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wlauppe/kochbuchapp
Browse files Browse the repository at this point in the history
  • Loading branch information
PassM committed Feb 16, 2020
2 parents d5d9fe5 + 6451480 commit 91add9f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<PublicRecipe>> { 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<List<PublicRecipe>> { 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<List<PublicRecipe>> { items ->
exampleAdapter.setNewItems(items)
}
viewModel.recipes.observe(this.viewLifecycleOwner, observer)
}
*/


//ERROR


return binding.root
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,5 @@ class DisplaySearchListViewmodel(repo:PublicRecipeRepository) : ViewModel() {
}
}))
}

}


fun sortByVegan(): List<PublicRecipe>{
var sortedList = mutableListOf<PublicRecipe>()
if(recipes.value != null) {
for (recipe in recipes.value!!) {
if(recipe.tags.contains("vegan")) {
sortedList.add(recipe)
}
}
}
return sortedList


}
fun sortByVegetarian() : List<PublicRecipe>{
var sortedList = mutableListOf<PublicRecipe>()
if(recipes.value != null) {
for (recipe in recipes.value!!) {
if(recipe.tags.contains("vegetarisch")) {
sortedList.add(recipe)
}
}
}
return sortedList
}
fun sortByDate() {

}
}
8 changes: 1 addition & 7 deletions app/src/main/res/layout/display_searchlist_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@
android:id="@+id/radioButton_vegan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vegan" />

<RadioButton
android:id="@+id/radioButton_vegetarian"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vegetarian" />
android:text="@string/titel" />
</RadioGroup>


Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<string name="preptime">Zubereitungszeit:</string>
<string name="share">Teilen</string>
<string name="logout">Ausloggen</string>
<string name="titel">Titel</string>

<string-array name="spinner">
<item>vegan</item>
Expand Down

0 comments on commit 91add9f

Please sign in to comment.