-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
433 additions
and
839 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...roid-retrofit/src/main/java/io/rotlabs/flakerandroidretrofit/di/FlakerAndroidContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.rotlabs.flakerandroidretrofit.di | ||
|
||
import android.content.Context | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.lifecycle.createSavedStateHandle | ||
import androidx.lifecycle.viewmodel.initializer | ||
import androidx.lifecycle.viewmodel.viewModelFactory | ||
import io.rotlabs.FlakerDataDependencyContainer | ||
import io.rotlabs.flakerandroidretrofit.ui.FlakerViewModel | ||
import io.rotlabs.flakerdb.networkrequest.data.NetworkRequestRepo | ||
import io.rotlabs.flakerprefs.PrefDataStore | ||
import io.rotlabs.flakerretrofit.FlakerRetrofitDependencyContainer | ||
|
||
object FlakerAndroidContainer { | ||
|
||
private var networkRequestRepo: NetworkRequestRepo? = null | ||
|
||
private var prefDataStore: PrefDataStore? = null | ||
|
||
private fun networkRequestRepo() = networkRequestRepo!! | ||
|
||
private fun prefDataStore() = prefDataStore!! | ||
|
||
fun init(appContext: Context) { | ||
FlakerRetrofitDependencyContainer.init(FlakerDataDependencyContainer(appContext)) | ||
networkRequestRepo = FlakerRetrofitDependencyContainer.networkRequestRepo() | ||
prefDataStore = FlakerRetrofitDependencyContainer.prefDataStore() | ||
} | ||
|
||
val flakerViewModelFactory: ViewModelProvider.Factory = viewModelFactory { | ||
initializer { | ||
val savedStateHandle = createSavedStateHandle() | ||
FlakerViewModel(networkRequestRepo(), prefDataStore(), savedStateHandle) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.