Update JankStats to 1.0.0-alpha03

Accomodating API changes along the way.
pull/219/head
Ben Weiss 2 years ago
parent 4a0fbf99b2
commit 6dc17126da
No known key found for this signature in database
GPG Key ID: 8424F9C1E763A74C

@ -24,9 +24,6 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import java.util.concurrent.Executor
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asExecutor
@Module
@InstallIn(ActivityComponent::class)
@ -47,17 +44,11 @@ object JankStatsModule {
return activity.window
}
@Provides
fun providesDefaultExecutor(): Executor {
return Dispatchers.Default.asExecutor()
}
@Provides
fun providesJankStats(
window: Window,
executor: Executor,
frameListener: JankStats.OnFrameListener
): JankStats {
return JankStats.createAndTrack(window, executor, frameListener)
return JankStats.createAndTrack(window, frameListener)
}
}

@ -143,7 +143,7 @@ class NiaAppState(
private fun NavigationTrackingSideEffect(navController: NavHostController) {
JankMetricDisposableEffect(navController) { metricsHolder ->
val listener = NavController.OnDestinationChangedListener { _, destination, _ ->
metricsHolder.state?.addState("Navigation", destination.route.toString())
metricsHolder.state?.putState("Navigation", destination.route.toString())
}
navController.addOnDestinationChangedListener(listener)

@ -26,7 +26,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.platform.LocalView
import androidx.metrics.performance.PerformanceMetricsState
import androidx.metrics.performance.PerformanceMetricsState.MetricsStateHolder
import androidx.metrics.performance.PerformanceMetricsState.Holder
import kotlinx.coroutines.CoroutineScope
/**
@ -35,11 +35,11 @@ import kotlinx.coroutines.CoroutineScope
* @see PerformanceMetricsState.getForHierarchy
*/
@Composable
fun rememberMetricsStateHolder(): MetricsStateHolder {
fun rememberMetricsStateHolder(): Holder {
val localView = LocalView.current
return remember(localView) {
PerformanceMetricsState.getForHierarchy(localView)
PerformanceMetricsState.getHolderForHierarchy(localView)
}
}
@ -51,7 +51,7 @@ fun rememberMetricsStateHolder(): MetricsStateHolder {
@Composable
fun JankMetricEffect(
vararg keys: Any?,
reportMetric: suspend CoroutineScope.(state: MetricsStateHolder) -> Unit
reportMetric: suspend CoroutineScope.(state: Holder) -> Unit
) {
val metrics = rememberMetricsStateHolder()
LaunchedEffect(metrics, *keys) {
@ -66,7 +66,7 @@ fun JankMetricEffect(
@Composable
fun JankMetricDisposableEffect(
vararg keys: Any?,
reportMetric: DisposableEffectScope.(state: MetricsStateHolder) -> DisposableEffectResult
reportMetric: DisposableEffectScope.(state: Holder) -> DisposableEffectResult
) {
val metrics = rememberMetricsStateHolder()
DisposableEffect(metrics, *keys) {
@ -80,7 +80,7 @@ fun TrackScrollJank(scrollableState: ScrollableState, stateName: String) {
snapshotFlow { scrollableState.isScrollInProgress }.collect { isScrollInProgress ->
metricsHolder.state?.apply {
if (isScrollInProgress) {
addState(stateName, "Scrolling=true")
putState(stateName, "Scrolling=true")
} else {
removeState(stateName)
}

@ -69,7 +69,7 @@ fun InterestsRoute(
)
JankMetricDisposableEffect(tabState) { metricsHolder ->
metricsHolder.state?.addState("Interests:TabState", "currentIndex:${tabState.currentIndex}")
metricsHolder.state?.putState("Interests:TabState", "currentIndex:${tabState.currentIndex}")
onDispose {
metricsHolder.state?.removeState("Interests:TabState")

@ -15,7 +15,7 @@ androidxHiltNavigationCompose = "1.0.0"
androidxLifecycle = "2.6.0-alpha01"
androidxMacroBenchmark = "1.1.0"
androidxNavigation = "2.5.0"
androidxMetrics = "1.0.0-alpha01"
androidxMetrics = "1.0.0-alpha03"
androidxProfileinstaller = "1.2.0-rc01"
androidxSavedState = "1.1.0"
androidxStartup = "1.1.1"

Loading…
Cancel
Save