Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Dagger Hilt version 2.31.2-alpha #5

Merged
merged 1 commit into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import com.paulrybitskyi.docskanner.utils.dialogs.DialogBuilderImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface CoreModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.paulrybitskyi.docskanner.ui.dashboard.fragment
import android.Manifest.permission.CAMERA
import android.net.Uri
import androidx.core.net.toUri
import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
Expand All @@ -42,12 +41,15 @@ import com.paulrybitskyi.docskanner.ui.views.docs.DocsUiState
import com.paulrybitskyi.docskanner.utils.dialogs.DialogConfig
import com.paulrybitskyi.docskanner.utils.dialogs.DialogContent
import com.paulrybitskyi.docskanner.utils.dialogs.DialogItem
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import java.io.File
import javax.inject.Inject


internal class DashboardViewModel @ViewModelInject constructor(
@HiltViewModel
internal class DashboardViewModel @Inject constructor(
private val observeAppStorageFolderFilesUseCase: ObserveAppStorageFolderFilesUseCase,
private val copyFileUseCase: CopyFileUseCase,
private val docsUiStateFactory: DocsUiStateFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.paulrybitskyi.docskanner.ui.editor

import android.graphics.Bitmap
import androidx.hilt.Assisted
import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.*
import com.paulrybitskyi.docskanner.R
import com.paulrybitskyi.docskanner.core.factories.PdfDocumentFileNameFactory
Expand All @@ -35,19 +34,22 @@ import com.paulrybitskyi.docskanner.ui.base.BaseViewModel
import com.paulrybitskyi.docskanner.ui.base.events.commons.GeneralCommand
import com.paulrybitskyi.docskanner.utils.dialogs.DialogConfig
import com.paulrybitskyi.docskanner.utils.dialogs.DialogContent
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.flatMapConcat
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
import java.io.File
import javax.inject.Inject


private const val PARAM_DOC_IMAGE_FILE = "doc_image_file"


internal class DocEditorViewModel @ViewModelInject constructor(
@HiltViewModel
internal class DocEditorViewModel @Inject constructor(
private val convertImageToPdfUseCase: ConvertImageToPdfUseCase,
private val clearAppCacheUseCase: ClearAppCacheUseCase,
private val pdfDocumentFileNameFactory: PdfDocumentFileNameFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@
package com.paulrybitskyi.docskanner.ui.preview

import androidx.hilt.Assisted
import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import com.paulrybitskyi.docskanner.ui.Constants
import com.paulrybitskyi.docskanner.ui.base.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.io.File
import javax.inject.Inject


private const val PARAM_DOC_FILE = "doc_file"


internal class DocPreviewViewModel @ViewModelInject constructor(
@HiltViewModel
internal class DocPreviewViewModel @Inject constructor(
@Assisted private val savedStateHandle: SavedStateHandle
) : BaseViewModel() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.paulrybitskyi.docskanner.ui.scanner

import android.graphics.Bitmap
import androidx.hilt.Assisted
import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.liveData
Expand All @@ -32,16 +31,19 @@ import com.paulrybitskyi.docskanner.domain.SaveImageToFileUseCase
import com.paulrybitskyi.docskanner.ui.Constants
import com.paulrybitskyi.docskanner.ui.base.BaseViewModel
import com.paulrybitskyi.docskanner.ui.base.events.commons.GeneralCommand
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import java.io.File
import javax.inject.Inject


private const val PARAM_DOC_IMAGE_FILE = "doc_image_file"


internal class DocScannerViewModel @ViewModelInject constructor(
@HiltViewModel
internal class DocScannerViewModel @Inject constructor(
private val saveImageToFileUseCase: SaveImageToFileUseCase,
private val temporaryImageFileFactory: TemporaryImageFileFactory,
private val stringProvider: StringProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.paulrybitskyi.docskanner.ui.splash

import android.Manifest.permission.WRITE_EXTERNAL_STORAGE
import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.viewModelScope
import com.paulrybitskyi.docskanner.R
import com.paulrybitskyi.docskanner.core.providers.StringProvider
Expand All @@ -32,12 +31,15 @@ import com.paulrybitskyi.docskanner.ui.base.BaseViewModel
import com.paulrybitskyi.docskanner.ui.base.events.commons.GeneralCommand
import com.paulrybitskyi.docskanner.utils.dialogs.DialogConfig
import com.paulrybitskyi.docskanner.utils.dialogs.DialogContent
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
import javax.inject.Inject

internal class SplashViewModel @ViewModelInject constructor(
@HiltViewModel
internal class SplashViewModel @Inject constructor(
private val imageProcessorInitializer: ImageProcessorInitializer,
private val createAppStorageFolderUseCase: CreateAppStorageFolderUseCase,
private val clearAppCacheUseCase: ClearAppCacheUseCase,
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object versions {

const val kotlin = "1.4.21" // also in buildSrc build.gradle.kts file
const val navigationVersion = "2.3.2"
const val daggerHilt = "2.28.3-alpha"
const val daggerHilt = "2.31.2-alpha"
const val gradleVersionsPlugin = "0.36.0"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.paulrybitskyi.docskanner.core

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import com.paulrybitskyi.docskanner.core.DocDetailsBuilderImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface CoreModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import com.paulrybitskyi.docskanner.core.factories.*
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface FactoriesModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import com.paulrybitskyi.docskanner.core.formatters.DocSizeFormatterImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface FormattersModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import com.paulrybitskyi.docskanner.core.providers.*
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface ProvidersModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import com.paulrybitskyi.docskanner.core.verifiers.*
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface VerifiersModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.paulrybitskyi.docskanner.core

import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.paulrybitskyi.docskanner.data

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import com.paulrybitskyi.docskanner.domain.*
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface UseCasesModule {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.paulrybitskyi.docskanner.data

import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.paulrybitskyi.docskanner.domain

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.paulrybitskyi.docskanner.domain

import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import com.paulrybitskyi.docskanner.imageloading.ImageLoaderImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface ImageLoadingBindingsModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import com.squareup.picasso.Picasso
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal object ImageLoadingModule {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import com.paulrybitskyi.docskanner.imageprocessing.resize.ResizeTransformationF
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
internal interface ImageProcessingModule {


Expand Down