Nav: First iteration integrating Appyx
This commit is contained in:
parent
4c88d8e3c2
commit
2de26a30d5
28 changed files with 566 additions and 280 deletions
|
|
@ -2,6 +2,8 @@ package io.element.android.x.di
|
|||
|
||||
import com.squareup.anvil.annotations.ContributesTo
|
||||
import io.element.android.x.matrix.Matrix
|
||||
import io.element.android.x.node.LoggedInFlowNode
|
||||
import io.element.android.x.node.RootFlowNode
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
@ContributesTo(AppScope::class)
|
||||
|
|
@ -9,4 +11,4 @@ interface AppBindings {
|
|||
fun coroutineScope(): CoroutineScope
|
||||
fun matrix(): Matrix
|
||||
fun sessionComponentsOwner(): SessionComponentsOwner
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,18 @@ package io.element.android.x.di
|
|||
import android.content.Context
|
||||
import io.element.android.x.core.di.bindings
|
||||
import io.element.android.x.matrix.MatrixClient
|
||||
import io.element.android.x.matrix.core.SessionId
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import javax.inject.Inject
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
class SessionComponentsOwner @Inject constructor(@ApplicationContext private val context: Context) {
|
||||
|
||||
private val sessionComponents = ConcurrentHashMap<String, SessionComponent>()
|
||||
private val sessionComponents = ConcurrentHashMap<SessionId, SessionComponent>()
|
||||
var activeSessionComponent: SessionComponent? = null
|
||||
private set
|
||||
|
||||
fun setActive(sessionId: String) {
|
||||
fun setActive(sessionId: SessionId) {
|
||||
val sessionComponent = sessionComponents[sessionId]
|
||||
if (activeSessionComponent != sessionComponent) {
|
||||
activeSessionComponent = sessionComponent
|
||||
|
|
@ -35,7 +36,7 @@ class SessionComponentsOwner @Inject constructor(@ApplicationContext private val
|
|||
}
|
||||
}
|
||||
|
||||
fun release(sessionId: String) {
|
||||
fun release(sessionId: SessionId) {
|
||||
val sessionComponent = sessionComponents.remove(sessionId)
|
||||
if (activeSessionComponent == sessionComponent) {
|
||||
activeSessionComponent = null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue