Skip to content

Commit

Permalink
♻️ apply feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkim2689 committed Oct 7, 2024
1 parent 6683026 commit f5c70ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fun RecipeStepEntity.toRecipeStepMaking(): RecipeStepMaking =
image = imageTitle ?: "",
imageUri = imageUri ?: "",
stepId = id,
cookingTime = cookingTime ?: "::",
cookingTime = cookingTime ?: "00:00:00",
)

fun IngredientEntity.toIngredient(): Ingredient =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class RecipeMakingViewModel
val ingredients = ingredientContent.value?.trim()
val title = titleContent.value?.trim()
val hour = hourContent.value
val second = secondContent.value
val minute = minuteContent.value
val second = secondContent.value

if (category.isNullOrEmpty() ||
introduction.isNullOrEmpty() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,13 @@ class StepMakingViewModel
sequence = stepNumber,
).onSuccess { recipeStep ->
if (recipeStep == null) return@onSuccess
val minute = recipeStep.cookingTime.split(SEPARATOR_TIME).getOrNull(1) ?: ""
val second = recipeStep.cookingTime.split(SEPARATOR_TIME).getOrNull(2) ?: ""
val minute =
recipeStep.cookingTime.split(SEPARATOR_TIME).getOrNull(1) ?: DEFAULT_TIME_STRING
val second =
recipeStep.cookingTime.split(SEPARATOR_TIME).getOrNull(2) ?: DEFAULT_TIME_STRING
introductionContent.value = recipeStep.description
minuteContent.value = if (minute.toIntOrNull() == 0) "" else minute
secondContent.value = if (second.toIntOrNull() == 0) "" else second
minuteContent.value = if (minute.toIntOrNull() == 0) DEFAULT_TIME_STRING else minute
secondContent.value = if (second.toIntOrNull() == 0) DEFAULT_TIME_STRING else second
if (recipeStep.imageUri.isNotEmpty()) {
_imageUri.value = Uri.parse(recipeStep.imageUri)
}
Expand All @@ -294,22 +296,20 @@ class StepMakingViewModel
) {
val minute = minuteContent.value
val second = secondContent.value
println("minute : $minute")
println("second : $second")

val recipeStep =
RecipeStepMaking(
recipeId = recipeId,
sequence = stepNumber,
description = introductionContent.value ?: "",
image = thumbnailTitle ?: "",
description = introductionContent.value ?: DEFAULT_TIME_STRING,
image = thumbnailTitle ?: DEFAULT_TIME_STRING,
stepId = 1L,
imageUri = imageUri.value?.toString() ?: "",
imageUri = imageUri.value?.toString() ?: DEFAULT_IMAGE_URI,
cookingTime =
FORMAT_TIME_REQUIRED.format(
0,
minute?.toIntOrNull() ?: 0,
second?.toIntOrNull() ?: 0,
DEFAULT_TIME_VALUE,
minute?.toIntOrNull() ?: DEFAULT_TIME_VALUE,
second?.toIntOrNull() ?: DEFAULT_TIME_VALUE,
),
)

Expand All @@ -326,6 +326,9 @@ class StepMakingViewModel
companion object {
private const val FORMAT_TIME_REQUIRED = "%02d:%02d:%02d"
private const val SEPARATOR_TIME = ":"
private const val DEFAULT_TIME_STRING = ""
private const val DEFAULT_TIME_VALUE = 0
private const val DEFAULT_IMAGE_URI = ""

fun provideFactory(
assistedFactory: StepMakingViewModelFactory,
Expand Down

0 comments on commit f5c70ff

Please sign in to comment.