This file contains hidden or 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
| class ConnectivityObserver(private val context: Context) { | |
| private val connectivityManager = context | |
| .getSystemService(ConnectivityManager::class.java) | |
| private val connectionFlow = callbackFlow { | |
| val callback = object : ConnectivityManager.NetworkCallback() { | |
| override fun onCapabilitiesChanged( | |
| network: Network, | |
| networkCapabilities: NetworkCapabilities | |
| ) { |
This file contains hidden or 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
| class ConnectivityObserver(private val context: Context) { | |
| private val connectivityManager = context | |
| .getSystemService(ConnectivityManager::class.java) as ConnectivityManager | |
| private val connectionFlow = callbackFlow { | |
| val callback = object : ConnectivityManager.NetworkCallback() { | |
| override fun onAvailable(network: Network) { | |
| super.onAvailable(network) | |
| trySend(true) |
This file contains hidden or 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
| import androidx.compose.runtime.Composable | |
| import androidx.compose.runtime.DisposableEffect | |
| import androidx.compose.runtime.State | |
| import androidx.compose.runtime.mutableStateOf | |
| import androidx.compose.runtime.remember | |
| import androidx.compose.ui.platform.LocalLifecycleOwner | |
| import androidx.lifecycle.DefaultLifecycleObserver | |
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleOwner | |
| import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers |
This file contains hidden or 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
| plugins { | |
| // ... | |
| } | |
| android { | |
| // ... | |
| } | |
| dependencies { | |
| // ... |
This file contains hidden or 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
| [versions] | |
| kotlin = "1.9.22" | |
| agp = "8.2.0" | |
| dagger = "2.50" | |
| anvil = "2.4.8" | |
| [plugins] | |
| android-application = { id = "com.android.application", version.ref = "agp" } | |
| kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } | |
| kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } |
This file contains hidden or 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
| @SingleIn(AppScope::class) | |
| class UserSessionManager @Inject constructor(private val app: App) { | |
| private var _userCoroutineScope: UserCoroutineScope? = null | |
| private val userCoroutineScope: CoroutineScope | |
| get() = createUserCoroutineScope() | |
| fun resetSession() { | |
| _userCoroutineScope?.cancel() |
This file contains hidden or 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
| class UserCoroutineScope( | |
| private val parentScope: CoroutineScope | |
| ) : CoroutineScope by parentScope |
This file contains hidden or 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
| @SingleIn(UserScope::class) | |
| @MergeSubcomponent(UserScope::class) | |
| interface UserComponent { | |
| @Subcomponent.Factory | |
| interface Factory { | |
| fun create( | |
| @BindsInstance userSession: UserSession, | |
| @BindsInstance userCoroutineScope: UserCoroutineScope, | |
| ): UserComponent |
This file contains hidden or 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
| @SingleIn(AppScope::class) | |
| class UserSessionManager @Inject constructor(private val app: App) { | |
| private var _userCoroutineScope: UserCoroutineScope? = null | |
| private val userCoroutineScope: CoroutineScope | |
| get() = createUserCoroutineScope() | |
| fun resetSession() { | |
| _userCoroutineScope?.cancel() |
This file contains hidden or 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
| class App : Application() { | |
| @Inject lateinit var userSessionManager: UserSessionManager | |
| val appComponent: AppComponent by lazy { | |
| DaggerAppComponent | |
| .factory() | |
| .create(this) | |
| } |
NewerOlder