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
Thoms3 committed Feb 16, 2020
2 parents 1b36a55 + 7aafa03 commit 6451480
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,66 @@ class CreateRecipeFragment : Fragment() {
setPortions(recipe.portions)
setPublishedID(recipe.publishedRecipeId)
getTagsFromRecipe(recipe.tags)
Log.i(Tagg, recipe.preparation.plus(" DDDDDD"))})
})




binding.checkBoxVeganCreateRecipeFragment.setOnClickListener{
if(viewModel.tagCheckBoxVegan.value!!){
viewModel.tagCheckBoxVegan.value = false
binding.checkBoxVeganCreateRecipeFragment.isChecked = false
}else {
viewModel.tagCheckBoxVegan.value = true
binding.checkBoxVeganCreateRecipeFragment.isChecked = true
}
Log.i(Tagg, viewModel.tagCheckBoxVegan.value.toString().plus( " = vm ; ").plus( binding.checkBoxVeganCreateRecipeFragment.isChecked.toString().plus(" = binding")))

}
binding.checkBoxVegetarianCreateRecipeFragment.setOnClickListener{
if(viewModel.tagCheckBoxVegetarian.value!!){
viewModel.tagCheckBoxVegetarian.value = false
binding.checkBoxVegetarianCreateRecipeFragment.isChecked = false
}else{
viewModel.tagCheckBoxVegetarian.value = true
binding.checkBoxVegetarianCreateRecipeFragment.isChecked = true
}
}
binding.checkBoxHeartyCreateRecipeFragment.setOnClickListener{
viewModel.tagCheckBoxSavoury.value = true
binding.checkBoxHeartyCreateRecipeFragment.isChecked = true
if(viewModel.tagCheckBoxSavoury.value!!){
viewModel.tagCheckBoxSavoury.value = false
binding.checkBoxHeartyCreateRecipeFragment.isChecked = false
}else{
viewModel.tagCheckBoxSavoury.value = true
binding.checkBoxHeartyCreateRecipeFragment.isChecked = true
}
}
binding.checkBoxSweetCreateRecipeFragment.setOnClickListener{
viewModel.tagCheckBoxSweet.value = true
binding.checkBoxSweetCreateRecipeFragment.isChecked = true
if(viewModel.tagCheckBoxSweet.value!!){
viewModel.tagCheckBoxSweet.value = false
binding.checkBoxSweetCreateRecipeFragment.isChecked = false
}else{
viewModel.tagCheckBoxSweet.value = true
binding.checkBoxSweetCreateRecipeFragment.isChecked = true
}
}
binding.checkBoxSaltyCreateRecipeFragment.setOnClickListener{
viewModel.tagCheckBoxSalty.value = true
binding.checkBoxSaltyCreateRecipeFragment.isChecked = true
if(viewModel.tagCheckBoxSalty.value!!){
viewModel.tagCheckBoxSalty.value = false
binding.checkBoxSaltyCreateRecipeFragment.isChecked = false
}else{
viewModel.tagCheckBoxSalty.value = true
binding.checkBoxSaltyCreateRecipeFragment.isChecked = true
}
}
binding.checkBoxCheap.setOnClickListener{
viewModel.tagCheckBoxCheap.value = true
binding.checkBoxCheap.isChecked = true
if(viewModel.tagCheckBoxCheap.value!!){
viewModel.tagCheckBoxCheap.value = false
binding.checkBoxCheap.isChecked = false
}else{
viewModel.tagCheckBoxCheap.value = true
binding.checkBoxCheap.isChecked = true
}
}
binding.checkBoxPublishCreateRecipeFragment.setOnClickListener() {
view -> if (view is CheckBox) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import android.content.Context
import android.util.Log
import android.widget.Toast
import androidx.lifecycle.*
import de.psekochbuch.exzellenzkoch.datalayer.remote.service.AuthentificationImpl
import de.psekochbuch.exzellenzkoch.domainlayer.domainentities.PrivateRecipe
import de.psekochbuch.exzellenzkoch.domainlayer.domainentities.PublicRecipe
import de.psekochbuch.exzellenzkoch.domainlayer.domainentities.User
import de.psekochbuch.exzellenzkoch.domainlayer.interfaces.repository.PrivateRecipeRepository
import de.psekochbuch.exzellenzkoch.domainlayer.interfaces.repository.PublicRecipeRepository
import de.psekochbuch.exzellenzkoch.domainlayer.interfaces.repository.UserRepository
Expand Down Expand Up @@ -110,7 +112,13 @@ class CreateRecipeViewmodel(privateRepository: PrivateRecipeRepository,
*/

fun publishRecipe() {
_snackbarMessage.value = "Beim Speichern wird Rezept als öffentlich verfügbar gemacht"
val loggedIn = AuthentificationImpl.isLogIn()
if(loggedIn) {
_snackbarMessage.value = "Beim Speichern wird Rezept als öffentlich verfügbar gemacht"
}
else {
_snackbarMessage.value = "Fehler: Sie sind nicht mit einem Account eingeloggt."
}
_showSnackbarEvent.value = true
}

Expand Down Expand Up @@ -158,10 +166,12 @@ class CreateRecipeViewmodel(privateRepository: PrivateRecipeRepository,
//TODO muss anscheinend seit neuestem ein Feld "User übergeben"
//Man muss da Zugriff auf den Benutzer haben,
// und wenn keiner angemeldet ist soll man ja auch nicht publishen können
if(this.tagCheckBoxPublish.value == true){
//val user = User("Test")
//val convertedPublicRecipe = newPrivateRecipe.convertToPublicRepipe(AuthentificationImpl.getUserId())
val convertedPublicRecipe = PublicRecipe(title="Test", imgUrl = newPrivateRecipe.imgUrl)
if(this.tagCheckBoxPublish.value == true && AuthentificationImpl.isLogIn()){
val userId = AuthentificationImpl.getUserId()
val user = User(userId)
//val _user = userRepo.getUser(userId)
val convertedPublicRecipe = newPrivateRecipe.convertToPublicRepipe(user)
// val convertedPublicRecipe = PublicRecipe(title="Test", user=user,imgUrl = newPrivateRecipe.imgUrl)
Log.i("CreateRecipeViewmodel", "bin am veröffentlichen des Rezepts")
//Coroutine
viewModelScope.launch {
Expand Down

0 comments on commit 6451480

Please sign in to comment.