Skip to content

Commit 673b991

Browse files
RUM-9508: more pr fixes
1 parent 1cb7d3d commit 673b991

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ androidXConstraintLayout = "2.0.4"
2020
androidXCore = "1.3.1"
2121
androidXFragment = "1.2.4"
2222
androidXLeanback = "1.0.0"
23+
androidXLifecycleRuntimeCompose = "2.8.7"
2324
androidXMetrics = "1.0.0-beta02"
2425
androidXMultidex = "2.0.1"
2526
androidXNavigation = "2.7.7"
@@ -145,6 +146,7 @@ androidXNavigationFragment = { module = "androidx.navigation:navigation-fragment
145146
androidXNavigationRuntime = { module = "androidx.navigation:navigation-runtime", version.ref = "androidXNavigation" }
146147
androidXRecyclerView = { module = "androidx.recyclerview:recyclerview", version.ref = "androidXRecyclerView" }
147148
androidXWorkManager = { module = "androidx.work:work-runtime", version.ref = "androidXWorkManager" }
149+
androidXLifecycleCompose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidXLifecycleRuntimeCompose" }
148150
daggerLib = { module = "com.google.dagger:dagger", version.ref = "dagger" }
149151
daggerCompiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }
150152
googleAccompanistAppCompatTheme = { module = "com.google.accompanist:accompanist-appcompat-theme", version.ref = "googleAccompanist" }

sample/benchmark/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ dependencies {
8787
implementation(libs.bundles.androidXNavigation)
8888
implementation(libs.androidXAppCompat)
8989
implementation(libs.androidXConstraintLayout)
90+
implementation(libs.androidXLifecycleCompose)
9091
implementation(libs.googleMaterial)
9192
implementation(libs.glideCore)
9293
implementation(libs.material3Android)

sample/benchmark/src/main/java/com/datadog/benchmark/sample/navigation/FragmentsNavigationManagerImpl.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,27 @@ private fun NavController.createNavGraph(scenario: SyntheticsScenario?): NavGrap
4747

4848
private fun createStartDestination(scenario: SyntheticsScenario?): String {
4949
return when (scenario) {
50-
SyntheticsScenario.SessionReplay, SyntheticsScenario.Upload -> SESSION_REPLAY_METERIAL_FRAGMENT_KEY
50+
null,
51+
SyntheticsScenario.SessionReplay,
52+
SyntheticsScenario.Upload -> SESSION_REPLAY_METERIAL_FRAGMENT_KEY
5153
SyntheticsScenario.SessionReplayCompose -> error("Using fragments for SessionReplayCompose scenario")
52-
SyntheticsScenario.Rum -> TODO("RUM-9510")
53-
SyntheticsScenario.Trace -> TODO("RUM-9509")
54-
null, SyntheticsScenario.LogsCustom -> LOGS_FRAGMENT_KEY
55-
SyntheticsScenario.LogsHeavyTraffic -> TODO("RUM-9508")
54+
SyntheticsScenario.LogsCustom -> LOGS_FRAGMENT_KEY
55+
SyntheticsScenario.Rum, // TODO RUM-9510
56+
SyntheticsScenario.Trace, // TODO RUM-9509
57+
SyntheticsScenario.LogsHeavyTraffic -> SESSION_REPLAY_METERIAL_FRAGMENT_KEY // TODO RUM-9508
5658
}
5759
}
5860

5961
private fun NavGraphBuilder.navGraph(scenario: SyntheticsScenario?) {
6062
return when (scenario) {
63+
null,
6164
SyntheticsScenario.SessionReplay,
6265
SyntheticsScenario.Upload -> navGraphSessionReplay()
6366
SyntheticsScenario.SessionReplayCompose -> error("Using fragments for SessionReplayCompose scenario")
64-
SyntheticsScenario.Rum -> TODO("RUM-9510")
65-
SyntheticsScenario.Trace -> TODO("RUM-9509")
66-
null, SyntheticsScenario.LogsCustom -> navGraphLogs()
67-
SyntheticsScenario.LogsHeavyTraffic -> TODO("RUM-9508")
67+
SyntheticsScenario.LogsCustom -> navGraphLogs()
68+
SyntheticsScenario.Rum, // TODO RUM-9510
69+
SyntheticsScenario.Trace, // TODO RUM-9509
70+
SyntheticsScenario.LogsHeavyTraffic -> navGraphSessionReplay() // TODO RUM-9508
6871
}
6972
}
7073

sample/benchmark/src/main/java/com/datadog/benchmark/sample/ui/logscustom/LogsFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import android.view.LayoutInflater
1111
import android.view.View
1212
import android.view.ViewGroup
1313
import androidx.compose.foundation.layout.fillMaxSize
14-
import androidx.compose.runtime.collectAsState
1514
import androidx.compose.runtime.getValue
1615
import androidx.compose.ui.Modifier
1716
import androidx.compose.ui.platform.ComposeView
1817
import androidx.fragment.app.Fragment
1918
import androidx.fragment.app.viewModels
2019
import androidx.lifecycle.ViewModelProvider
20+
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2121
import com.datadog.benchmark.sample.benchmarkActivityComponent
2222
import com.datadog.benchmark.sample.di.activity.ViewModel
2323
import javax.inject.Inject
@@ -35,7 +35,7 @@ internal class LogsFragment : Fragment() {
3535

3636
return ComposeView(requireContext()).apply {
3737
setContent {
38-
val states by viewModel.states().collectAsState()
38+
val states by viewModel.logsScreenState.collectAsStateWithLifecycle()
3939

4040
LogsScreen(
4141
modifier = Modifier.fillMaxSize(),

sample/benchmark/src/main/java/com/datadog/benchmark/sample/ui/logscustom/LogsScreenViewModel.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,18 @@ internal class LogsScreenViewModel(
8484

8585
private val actions: Channel<LogsScreenAction> = Channel(capacity = UNLIMITED)
8686

87-
private val statesPipeline: StateFlow<LogsScreenState> = actions
87+
private val _logsScreenState: StateFlow<LogsScreenState> = actions
8888
.receiveAsFlow()
8989
.scan(LogsScreenState.INITIAL, ::processAction)
9090
.flowOn(defaultDispatcher)
9191
.stateIn(scope = viewModelScope, started = SharingStarted.Lazily, initialValue = LogsScreenState.INITIAL)
9292

93+
val logsScreenState: StateFlow<LogsScreenState> = _logsScreenState
94+
9395
fun dispatch(action: LogsScreenAction) {
9496
actions.trySend(action)
9597
}
9698

97-
fun states(): StateFlow<LogsScreenState> {
98-
return statesPipeline
99-
}
100-
10199
private fun processAction(prev: LogsScreenState, action: LogsScreenAction): LogsScreenState {
102100
return when (action) {
103101
is LogsScreenAction.ChangeLogMessage -> prev.modifyConfig { copy(logMessage = action.newLogMessage) }

0 commit comments

Comments
 (0)