Skip to content

Commit

Permalink
Migrate to hilt 2.31
Browse files Browse the repository at this point in the history
  • Loading branch information
Drjacky committed Jan 16, 2021
1 parent 30bba49 commit 792d2ba
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import app.web.drjackycv.data.products.remote.ProductsApi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Singleton

@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
@Module
class ApiModule {

@Provides
@Singleton
fun products(retrofit: Retrofit): ProductsApi =
retrofit.create(ProductsApi::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import app.web.drjackycv.domain.products.repository.ProductsListRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@InstallIn(ApplicationComponent::class)
@Module
@InstallIn(ViewModelComponent::class)
class RepositoryModule {

@Provides
@ViewModelScoped
fun productsList(pagingSource: ProductsPagingSource): ProductsListRepository =
ProductsListRepositoryImpl(pagingSource)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object Depends {
const val multidexVersion = "2.0.1"
const val fragmentExtVersion = "1.2.5"
const val recyclerviewVersion = "1.2.0-alpha06"
const val hiltVersion = "2.30.1-alpha"
const val hiltVersion = "2.31-alpha"
const val hiltExtVersion = "1.0.0-alpha02"
const val javaxInjectVersion = "1"
const val timberVersion = "4.7.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import app.web.drjackycv.domain.base.usecase.GeneralUseCase
import app.web.drjackycv.domain.products.repository.ProductsListRepository
import io.reactivex.Flowable
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class GetBeersListUseCase @Inject constructor(
private val productsListRepository: ProductsListRepository
) : GeneralUseCase<Flowable<PagingData<RecyclerItem>>, GetBeersListParams> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app.web.drjackycv.presentation.base.viewmodel

import android.content.res.Resources
import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
Expand All @@ -12,13 +11,15 @@ import com.uber.autodispose.FlowableSubscribeProxy
import com.uber.autodispose.lifecycle.CorrespondingEventsFunction
import com.uber.autodispose.lifecycle.LifecycleEndedException
import com.uber.autodispose.lifecycle.LifecycleScopeProvider
import dagger.hilt.android.lifecycle.HiltViewModel
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.annotations.CheckReturnValue
import io.reactivex.subjects.BehaviorSubject
import javax.inject.Inject

open class BaseViewModel @ViewModelInject constructor() : ViewModel(),
@HiltViewModel
open class BaseViewModel @Inject constructor() : ViewModel(),
LifecycleScopeProvider<BaseViewModel.ViewModelEvent> {

private val lifecycleEventsDelegate =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package app.web.drjackycv.presentation.products.productlist

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
Expand All @@ -10,9 +9,12 @@ import app.web.drjackycv.domain.base.RecyclerItem
import app.web.drjackycv.domain.products.usecase.GetBeersListParams
import app.web.drjackycv.domain.products.usecase.GetBeersListUseCase
import app.web.drjackycv.presentation.base.viewmodel.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import io.reactivex.android.schedulers.AndroidSchedulers
import javax.inject.Inject

class ProductsListViewModel @ViewModelInject constructor(
@HiltViewModel
class ProductsListViewModel @Inject constructor(
private val getBeersUseCase: GetBeersListUseCase
) : BaseViewModel() {

Expand Down

0 comments on commit 792d2ba

Please sign in to comment.