Use @Singleton where possible
This commit is contained in:
@@ -12,7 +12,9 @@ import retrofit2.HttpException
|
|||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class AuthDataSourceImpl @Inject constructor(
|
class AuthDataSourceImpl @Inject constructor(
|
||||||
private val authServiceFactory: ServiceFactory<AuthService>,
|
private val authServiceFactory: ServiceFactory<AuthService>,
|
||||||
private val json: Json,
|
private val json: Json,
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import kotlinx.coroutines.flow.map
|
|||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class AuthRepoImpl @Inject constructor(
|
class AuthRepoImpl @Inject constructor(
|
||||||
private val dataSource: AuthDataSource,
|
private val dataSource: AuthDataSource,
|
||||||
private val storage: AuthStorage,
|
private val storage: AuthStorage,
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
private const val AUTH_HEADER_KEY = "AUTH_TOKEN"
|
private const val AUTH_HEADER_KEY = "AUTH_TOKEN"
|
||||||
private const val BASE_URL_KEY = "BASE_URL"
|
private const val BASE_URL_KEY = "BASE_URL"
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class AuthStorageImpl @Inject constructor(
|
class AuthStorageImpl @Inject constructor(
|
||||||
private val sharedPreferences: SharedPreferences
|
private val sharedPreferences: SharedPreferences
|
||||||
) : AuthStorage {
|
) : AuthStorage {
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import android.content.SharedPreferences
|
|||||||
import gq.kirmanak.mealient.extensions.getBooleanOrFalse
|
import gq.kirmanak.mealient.extensions.getBooleanOrFalse
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
private const val IS_DISCLAIMER_ACCEPTED_KEY = "IS_DISCLAIMER_ACCEPTED"
|
private const val IS_DISCLAIMER_ACCEPTED_KEY = "IS_DISCLAIMER_ACCEPTED"
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class DisclaimerStorageImpl @Inject constructor(
|
class DisclaimerStorageImpl @Inject constructor(
|
||||||
private val sharedPreferences: SharedPreferences
|
private val sharedPreferences: SharedPreferences
|
||||||
) : DisclaimerStorage {
|
) : DisclaimerStorage {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import okhttp3.OkHttpClient
|
|||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class RetrofitBuilder @Inject constructor(
|
class RetrofitBuilder @Inject constructor(
|
||||||
private val okHttpClient: OkHttpClient,
|
private val okHttpClient: OkHttpClient,
|
||||||
private val json: Json
|
private val json: Json
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import gq.kirmanak.mealient.extensions.toRecipeIngredientEntity
|
|||||||
import gq.kirmanak.mealient.extensions.toRecipeInstructionEntity
|
import gq.kirmanak.mealient.extensions.toRecipeInstructionEntity
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class RecipeStorageImpl @Inject constructor(
|
class RecipeStorageImpl @Inject constructor(
|
||||||
private val db: AppDb
|
private val db: AppDb
|
||||||
) : RecipeStorage {
|
) : RecipeStorage {
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import gq.kirmanak.mealient.ui.ImageLoader
|
|||||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class RecipeImageLoaderImpl @Inject constructor(
|
class RecipeImageLoaderImpl @Inject constructor(
|
||||||
private val imageLoader: ImageLoader,
|
private val imageLoader: ImageLoader,
|
||||||
private val authRepo: AuthRepo
|
private val authRepo: AuthRepo
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import gq.kirmanak.mealient.data.recipes.network.RecipeDataSource
|
|||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@OptIn(ExperimentalPagingApi::class)
|
@OptIn(ExperimentalPagingApi::class)
|
||||||
|
@Singleton
|
||||||
class RecipeRepoImpl @Inject constructor(
|
class RecipeRepoImpl @Inject constructor(
|
||||||
private val mediator: RecipesRemoteMediator,
|
private val mediator: RecipesRemoteMediator,
|
||||||
private val storage: RecipeStorage,
|
private val storage: RecipeStorage,
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import gq.kirmanak.mealient.data.recipes.network.RecipeDataSource
|
|||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@OptIn(ExperimentalPagingApi::class)
|
@OptIn(ExperimentalPagingApi::class)
|
||||||
|
@Singleton
|
||||||
class RecipesRemoteMediator @Inject constructor(
|
class RecipesRemoteMediator @Inject constructor(
|
||||||
private val storage: RecipeStorage,
|
private val storage: RecipeStorage,
|
||||||
private val network: RecipeDataSource,
|
private val network: RecipeDataSource,
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import gq.kirmanak.mealient.data.recipes.network.response.GetRecipeResponse
|
|||||||
import gq.kirmanak.mealient.data.recipes.network.response.GetRecipeSummaryResponse
|
import gq.kirmanak.mealient.data.recipes.network.response.GetRecipeSummaryResponse
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class RecipeDataSourceImpl @Inject constructor(
|
class RecipeDataSourceImpl @Inject constructor(
|
||||||
private val authRepo: AuthRepo,
|
private val authRepo: AuthRepo,
|
||||||
private val recipeServiceFactory: ServiceFactory<RecipeService>,
|
private val recipeServiceFactory: ServiceFactory<RecipeService>,
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import com.squareup.picasso.Picasso
|
|||||||
import gq.kirmanak.mealient.ui.ImageLoader
|
import gq.kirmanak.mealient.ui.ImageLoader
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class ImageLoaderPicasso @Inject constructor(
|
class ImageLoaderPicasso @Inject constructor(
|
||||||
private val picasso: Picasso
|
private val picasso: Picasso
|
||||||
) : ImageLoader {
|
) : ImageLoader {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import gq.kirmanak.mealient.BuildConfig
|
|||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class PicassoBuilder @Inject constructor(
|
class PicassoBuilder @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val okHttpClient: OkHttpClient
|
private val okHttpClient: OkHttpClient
|
||||||
|
|||||||
Reference in New Issue
Block a user