Initialize v1 support

This commit is contained in:
Kirill Kamakin
2022-08-07 17:19:35 +02:00
parent 684b492fb2
commit 95205f8ffe
24 changed files with 478 additions and 26 deletions

View File

@@ -9,5 +9,5 @@ interface RecipeRepo {
suspend fun clearLocalData()
suspend fun loadRecipeInfo(recipeId: Long, recipeSlug: String): FullRecipeInfo
suspend fun loadRecipeInfo(recipeId: String, recipeSlug: String): FullRecipeInfo
}

View File

@@ -17,5 +17,5 @@ interface RecipeStorage {
suspend fun saveRecipeInfo(recipe: GetRecipeResponse)
suspend fun queryRecipeInfo(recipeId: Long): FullRecipeInfo
suspend fun queryRecipeInfo(recipeId: String): FullRecipeInfo
}

View File

@@ -132,7 +132,7 @@ class RecipeStorageImpl @Inject constructor(
}
}
override suspend fun queryRecipeInfo(recipeId: Long): FullRecipeInfo {
override suspend fun queryRecipeInfo(recipeId: String): FullRecipeInfo {
logger.v { "queryRecipeInfo() called with: recipeId = $recipeId" }
val fullRecipeInfo = checkNotNull(recipeDao.queryFullRecipeInfo(recipeId)) {
"Can't find recipe by id $recipeId in DB"

View File

@@ -38,7 +38,7 @@ class RecipeRepoImpl @Inject constructor(
storage.clearAllLocalData()
}
override suspend fun loadRecipeInfo(recipeId: Long, recipeSlug: String): FullRecipeInfo {
override suspend fun loadRecipeInfo(recipeId: String, recipeSlug: String): FullRecipeInfo {
logger.v { "loadRecipeInfo() called with: recipeId = $recipeId, recipeSlug = $recipeSlug" }
runCatchingExceptCancel {

View File

@@ -13,7 +13,7 @@ fun GetRecipeResponse.toRecipeEntity() = RecipeEntity(
recipeYield = recipeYield
)
fun GetRecipeIngredientResponse.toRecipeIngredientEntity(remoteId: Long) =
fun GetRecipeIngredientResponse.toRecipeIngredientEntity(remoteId: String) =
RecipeIngredientEntity(
recipeId = remoteId,
title = title,
@@ -24,7 +24,7 @@ fun GetRecipeIngredientResponse.toRecipeIngredientEntity(remoteId: Long) =
quantity = quantity
)
fun GetRecipeInstructionResponse.toRecipeInstructionEntity(remoteId: Long) =
fun GetRecipeInstructionResponse.toRecipeInstructionEntity(remoteId: String) =
RecipeInstructionEntity(
recipeId = remoteId,
title = title,

View File

@@ -44,7 +44,7 @@ class RecipeModelLoader private constructor(
options: Options?
): String? {
logger.v { "getUrl() called with: model = $model, width = $width, height = $height, options = $options" }
return runBlocking { recipeImageUrlProvider.generateImageUrl(model?.slug) }
return runBlocking { recipeImageUrlProvider.generateImageUrl(model?.remoteId) }
}
override fun getHeaders(

View File

@@ -20,7 +20,7 @@ class RecipeInfoViewModel @Inject constructor(
private val _uiState = MutableLiveData(RecipeInfoUiState())
val uiState: LiveData<RecipeInfoUiState> get() = _uiState
fun loadRecipeInfo(recipeId: Long, recipeSlug: String) {
fun loadRecipeInfo(recipeId: String, recipeSlug: String) {
logger.v { "loadRecipeInfo() called with: recipeId = $recipeId, recipeSlug = $recipeSlug" }
_uiState.value = RecipeInfoUiState()
viewModelScope.launch {

View File

@@ -36,7 +36,7 @@
app:argType="string" />
<argument
android:name="recipe_id"
app:argType="long" />
app:argType="string" />
</dialog>
<fragment
android:id="@+id/disclaimerFragment"