Skip to content

Commit

Permalink
🚨 resolve kt lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkim2689 committed Jul 25, 2024
1 parent 55f9fac commit 249c9c2
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 42 deletions.
1 change: 0 additions & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.android.build.gradle.internal.cxx.attribution.decodeBuildTaskAttributions
import java.io.FileInputStream
import java.util.Properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import net.pengcook.android.data.remote.api.FeedService
import retrofit2.Response

class DefaultFeedRemoteDataSource(
private val feedService: FeedService
private val feedService: FeedService,
) : FeedRemoteDataSource {
override suspend fun fetchRecipes(pageNumber: Int, pageSize: Int): Response<List<FeedItemResponse>> {
override suspend fun fetchRecipes(
pageNumber: Int,
pageSize: Int,
): Response<List<FeedItemResponse>> {
return feedService.fetchRecipes(pageNumber, pageSize)
}

Expand All @@ -19,7 +22,7 @@ class DefaultFeedRemoteDataSource(
override suspend fun fetchRecipesByCategory(
pageNumber: Int,
pageSize: Int,
category: String
category: String,
): Response<List<FeedItemResponse>> {
return feedService.fetchRecipesByCategory(pageNumber, pageSize, category)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ interface FeedRemoteDataSource {
pageSize: Int,
): Response<List<FeedItemResponse>>

suspend fun fetchRecipeSteps(
recipeId: Long
): Response<List<RecipeStepResponse>>
suspend fun fetchRecipeSteps(recipeId: Long): Response<List<RecipeStepResponse>>

suspend fun fetchRecipesByCategory(
pageNumber: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.pengcook.android.data.model.feed.item


import com.google.gson.annotations.SerializedName

data class AuthorResponse(
Expand All @@ -9,5 +8,5 @@ data class AuthorResponse(
@SerializedName("authorImage")
val authorImage: String,
@SerializedName("authorName")
val authorName: String
val authorName: String,
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package net.pengcook.android.data.model.feed.item


import com.google.gson.annotations.SerializedName

data class CategoryResponse(
@SerializedName("categoryId")
val categoryId: Long,
@SerializedName("categoryName")
val categoryName: String
val categoryName: String,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.pengcook.android.data.model.feed.item


import com.google.gson.annotations.SerializedName

data class FeedItemResponse(
Expand All @@ -23,5 +22,5 @@ data class FeedItemResponse(
@SerializedName("thumbnail")
val thumbnail: String,
@SerializedName("title")
val title: String
val title: String,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.pengcook.android.data.model.feed.item


import com.google.gson.annotations.SerializedName

data class IngredientResponse(
Expand All @@ -9,5 +8,5 @@ data class IngredientResponse(
@SerializedName("ingredientName")
val ingredientName: String,
@SerializedName("requirement")
val requirement: String
val requirement: String,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.pengcook.android.data.model.feed.step


import com.google.gson.annotations.SerializedName

data class RecipeStepResponse(
Expand All @@ -13,5 +12,5 @@ data class RecipeStepResponse(
@SerializedName("recipeId")
val recipeId: Int,
@SerializedName("sequence")
val sequence: Int
val sequence: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface FeedService {

@GET("/api/recipes/{recipeId}/steps")
suspend fun fetchRecipeSteps(
@Path("recipeId") recipeId: Long
@Path("recipeId") recipeId: Long,
): Response<List<RecipeStepResponse>>

@GET("/api/categories")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DefaultFeedRepository(
) : FeedRepository, NetworkResponseHandler {
override suspend fun fetchRecipes(
pageNumber: Int,
pageSize: Int
pageSize: Int,
): Result<List<Feed>> {
return runCatching {
val response = feedRemoteDataSource.fetchRecipes(pageNumber, pageSize)
Expand All @@ -33,7 +33,7 @@ class DefaultFeedRepository(
override suspend fun fetchRecipesByCategory(
pageNumber: Int,
pageSize: Int,
category: String
category: String,
): Result<List<Feed>> {
return runCatching {
val response =
Expand All @@ -42,7 +42,10 @@ class DefaultFeedRepository(
}
}

override fun <T> body(response: Response<T>, validHttpCode: Int): T {
override fun <T> body(
response: Response<T>,
validHttpCode: Int,
): T {
val code = response.code()
val body = response.body()
if (code != validHttpCode) throw RuntimeException(EXCEPTION_HTTP_CODE)
Expand All @@ -56,5 +59,3 @@ class DefaultFeedRepository(
private const val RESPONSE_CODE_SUCCESS = 200
}
}


Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package net.pengcook.android.data.repository.feed

import net.pengcook.android.data.model.feed.item.FeedItemResponse
import net.pengcook.android.data.model.feed.step.RecipeStepResponse
import net.pengcook.android.presentation.core.model.Feed
import net.pengcook.android.presentation.detail.RecipeStep

Expand All @@ -11,9 +9,7 @@ interface FeedRepository {
pageSize: Int,
): Result<List<Feed>>

suspend fun fetchRecipeSteps(
recipeId: Long
): Result<List<RecipeStep>>
suspend fun fetchRecipeSteps(recipeId: Long): Result<List<RecipeStep>>

suspend fun fetchRecipesByCategory(
pageNumber: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fun FeedItemResponse.toFeed(): Feed =
recipeImageUrl = thumbnail,
recipeTitle = title,
likeCount = likeCount,
commentCount = 0
commentCount = 0,
)

fun RecipeStepResponse.toRecipeStep(): RecipeStep =
Expand All @@ -22,5 +22,5 @@ fun RecipeStepResponse.toRecipeStep(): RecipeStep =
recipeId = recipeId,
description = description,
image = image,
sequence = sequence
sequence = sequence,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ package net.pengcook.android.data.util.network
import retrofit2.Response

interface NetworkResponseHandler {
fun <T> body(response: Response<T>, validHttpCode: Int): T
fun <T> body(
response: Response<T>,
validHttpCode: Int,
): T
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object RetrofitClient {
private val retrofit = Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
private val retrofit =
Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()

fun <T> service(apiService: Class<T>): T {
return retrofit.create(apiService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ data class RecipeStep(
val recipeId: Int,
val description: String,
val image: Any,
val sequence: Int
val sequence: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.pengcook.android.data.datasource.feed.DefaultFeedRemoteDataSource
import net.pengcook.android.data.datasource.feed.FeedRemoteDataSource
import net.pengcook.android.data.remote.api.FeedService
import net.pengcook.android.data.repository.feed.DefaultFeedRepository
import net.pengcook.android.data.repository.feed.FeedRepository
Expand All @@ -26,10 +25,10 @@ class HomeFragment : Fragment() {
DefaultFeedRepository(
DefaultFeedRemoteDataSource(
RetrofitClient.service(
FeedService::class.java
)
)
)
FeedService::class.java,
),
),
),
)
}
private lateinit var binding: FragmentHomeBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.paging.PagingData
import androidx.paging.cachedIn
import androidx.paging.liveData
import net.pengcook.android.data.datasource.FeedPagingSource
import net.pengcook.android.data.repository.DummyFeedsRepository
import net.pengcook.android.data.repository.feed.FeedRepository
import net.pengcook.android.presentation.core.model.Feed
import net.pengcook.android.presentation.home.listener.FeedItemEventListener
Expand Down

0 comments on commit 249c9c2

Please sign in to comment.