Skip to content

Commit

Permalink
refactor: retrieve metrics holder
Browse files Browse the repository at this point in the history
  • Loading branch information
mlykotom committed Feb 1, 2022
1 parent fda2cd0 commit a164332
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration

private lateinit var jankStats: JankStats
private lateinit var metricsStateHolder: PerformanceMetricsState.MetricsStateHolder

// [START jank_frame_listener]
private val jankFrameListener = JankStats.OnFrameListener { frameData ->
Expand All @@ -62,7 +61,7 @@ class MainActivity : AppCompatActivity() {
setupUi()
// [END_EXCLUDE]
// metrics state holder can be retrieved regardless of JankStats initialization
metricsStateHolder = PerformanceMetricsState.getForHierarchy(binding.root)
val metricsStateHolder = PerformanceMetricsState.getForHierarchy(binding.root)

// initialize JankStats for current window
jankStats = JankStats.createAndTrack(
Expand Down Expand Up @@ -108,6 +107,7 @@ class MainActivity : AppCompatActivity() {

private fun setupNavigationState() {
// [START state_navigation]
val metricsStateHolder = PerformanceMetricsState.getForHierarchy(binding.root)
// add current navigation information into JankStats state
navController.addOnDestinationChangedListener { controller, destination, arguments ->
metricsStateHolder.state?.addState(
Expand Down

0 comments on commit a164332

Please sign in to comment.