Skip to content

Commit

Permalink
Add null check rootView to fix issue #6367 (#6510)
Browse files Browse the repository at this point in the history
Fix for issue #6367
  • Loading branch information
lehcar09 authored Nov 13, 2024
1 parent c737e21 commit 9ae2606
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,12 @@ public synchronized void onActivityResumed(Activity activity) {
final boolean isExperimentTTIDEnabled = configResolver.getIsExperimentTTIDEnabled();
if (isExperimentTTIDEnabled) {
View rootView = activity.findViewById(android.R.id.content);
rootView.getViewTreeObserver().addOnDrawListener(onDrawCounterListener);
FirstDrawDoneListener.registerForNextDraw(rootView, this::recordOnDrawFrontOfQueue);
PreDrawListener.registerForNextDraw(
rootView, this::recordPreDraw, this::recordPreDrawFrontOfQueue);
if (rootView != null) {
rootView.getViewTreeObserver().addOnDrawListener(onDrawCounterListener);
FirstDrawDoneListener.registerForNextDraw(rootView, this::recordOnDrawFrontOfQueue);
PreDrawListener.registerForNextDraw(
rootView, this::recordPreDraw, this::recordPreDrawFrontOfQueue);
}
}

if (onResumeTime != null) { // An activity already called onResume()
Expand Down Expand Up @@ -444,7 +446,9 @@ public void onActivityPaused(Activity activity) {
return;
}
View rootView = activity.findViewById(android.R.id.content);
rootView.getViewTreeObserver().removeOnDrawListener(onDrawCounterListener);
if (rootView != null) {
rootView.getViewTreeObserver().removeOnDrawListener(onDrawCounterListener);
}
}

@Override
Expand Down

0 comments on commit 9ae2606

Please sign in to comment.