Extract AddRecipeInput proto file to a module
This commit is contained in:
@@ -2,8 +2,8 @@ package gq.kirmanak.mealient.data.add.impl
|
||||
|
||||
import androidx.datastore.core.DataStore
|
||||
import gq.kirmanak.mealient.data.add.AddRecipeStorage
|
||||
import gq.kirmanak.mealient.data.add.models.AddRecipeInput
|
||||
import gq.kirmanak.mealient.data.add.models.AddRecipeRequest
|
||||
import gq.kirmanak.mealient.datastore.recipe.AddRecipeInput
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import timber.log.Timber
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package gq.kirmanak.mealient.data.add.models
|
||||
|
||||
import androidx.datastore.core.CorruptionException
|
||||
import androidx.datastore.core.Serializer
|
||||
import com.google.protobuf.InvalidProtocolBufferException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
object AddRecipeInputSerializer : Serializer<AddRecipeInput> {
|
||||
override val defaultValue: AddRecipeInput = AddRecipeInput.getDefaultInstance()
|
||||
|
||||
override suspend fun readFrom(input: InputStream): AddRecipeInput = try {
|
||||
AddRecipeInput.parseFrom(input)
|
||||
} catch (e: InvalidProtocolBufferException) {
|
||||
throw CorruptionException("Can't read proto file", e)
|
||||
}
|
||||
|
||||
override suspend fun writeTo(t: AddRecipeInput, output: OutputStream) = t.writeTo(output)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package gq.kirmanak.mealient.data.add.models
|
||||
|
||||
import gq.kirmanak.mealient.datastore.recipe.AddRecipeInput
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package gq.kirmanak.mealient.di
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.core.DataStoreFactory
|
||||
import androidx.datastore.dataStoreFile
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import gq.kirmanak.mealient.data.add.AddRecipeDataSource
|
||||
import gq.kirmanak.mealient.data.add.AddRecipeRepo
|
||||
@@ -17,8 +12,6 @@ import gq.kirmanak.mealient.data.add.impl.AddRecipeDataSourceImpl
|
||||
import gq.kirmanak.mealient.data.add.impl.AddRecipeRepoImpl
|
||||
import gq.kirmanak.mealient.data.add.impl.AddRecipeService
|
||||
import gq.kirmanak.mealient.data.add.impl.AddRecipeStorageImpl
|
||||
import gq.kirmanak.mealient.data.add.models.AddRecipeInput
|
||||
import gq.kirmanak.mealient.data.add.models.AddRecipeInputSerializer
|
||||
import gq.kirmanak.mealient.data.baseurl.BaseURLStorage
|
||||
import gq.kirmanak.mealient.data.network.RetrofitBuilder
|
||||
import gq.kirmanak.mealient.data.network.ServiceFactory
|
||||
@@ -34,14 +27,6 @@ interface AddRecipeModule {
|
||||
|
||||
companion object {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAddRecipeInputStore(
|
||||
@ApplicationContext context: Context
|
||||
): DataStore<AddRecipeInput> = DataStoreFactory.create(AddRecipeInputSerializer) {
|
||||
context.dataStoreFile("add_recipe_input")
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAddRecipeServiceFactory(
|
||||
|
||||
Reference in New Issue
Block a user