help reimar

This commit is contained in:
LilleBRG 2025-05-14 12:47:20 +02:00
parent 4a935514cf
commit f9e006539c
3 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package tech.mercantec.easyeat.helpers
import android.content.Context
import android.util.Log
import kotlinx.serialization.Serializable
import tech.mercantec.easyeat.models.Ingredient
import tech.mercantec.easyeat.models.Recipe

View File

@ -154,12 +154,11 @@ class DishDetailsActivity : AppCompatActivity() {
val editRecipeBtn: Button = findViewById(R.id.editRecipeBtn)
editRecipeBtn.setOnClickListener {
val jsonRecipe = Json.encodeToString(recipe) // convert Recipe to JSON string
Log.i("jsonrecipe", jsonRecipe)
val intent = Intent(this, EditDishActivity::class.java)
intent.putExtra("recipe_json", jsonRecipe) // put as string
startActivity(intent)
}
}
}
}

View File

@ -2,7 +2,6 @@ package tech.mercantec.easyeat.ui.dishes
import android.app.Activity
import android.app.ProgressDialog
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import android.os.Bundle
import android.view.LayoutInflater
@ -57,7 +56,6 @@ class EditDishActivity : AppCompatActivity() {
addIngredientRow()
}
saveButton.setOnClickListener {
saveButton.setOnClickListener {
val ingredientList = collectIngredients()
val instructions = findViewById<EditText>(R.id.instructions).text.toString().trim()
@ -67,6 +65,7 @@ class EditDishActivity : AppCompatActivity() {
.filter { it.isNotEmpty() }
val updatedRecipe = Recipe(
id = null,
name = findViewById<EditText>(R.id.dishName).text.toString().trim(),
description = findViewById<EditText>(R.id.dishDescription).text.toString().trim(),
directions = directions,
@ -78,6 +77,7 @@ class EditDishActivity : AppCompatActivity() {
progressDialog.show()
thread {
try {
updateRecipe(this, recipe.id!!, updatedRecipe)
} catch (e: ApiRequestException) {
runOnUiThread {
@ -99,7 +99,6 @@ class EditDishActivity : AppCompatActivity() {
finish()
}
}
}
}
private fun addIngredientRow(ingredient: Ingredient? = null) {