File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
lib/java/com/google/android/material/navigation Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 5959import android .view .MenuItem ;
6060import android .view .View ;
6161import android .view .ViewTreeObserver .OnGlobalLayoutListener ;
62+ import com .google .android .material .internal .ContextUtils ;
6263import com .google .android .material .internal .NavigationMenu ;
6364import com .google .android .material .internal .NavigationMenuPresenter ;
6465import com .google .android .material .internal .ScrimInsetsFrameLayout ;
@@ -680,13 +681,12 @@ public void onGlobalLayout() {
680681 presenter .setBehindStatusBar (isBehindStatusBar );
681682 setDrawTopInsetForeground (isBehindStatusBar );
682683
683- Context context = getContext ();
684- if (context instanceof Activity && VERSION .SDK_INT >= VERSION_CODES .LOLLIPOP ) {
684+ Activity activity = ContextUtils . getActivity ( getContext () );
685+ if (activity != null && VERSION .SDK_INT >= VERSION_CODES .LOLLIPOP ) {
685686 boolean isBehindSystemNav =
686- ((Activity ) context ).findViewById (android .R .id .content ).getHeight ()
687- == getHeight ();
687+ activity .findViewById (android .R .id .content ).getHeight () == getHeight ();
688688 boolean hasNonZeroAlpha =
689- Color .alpha ((( Activity ) context ) .getWindow ().getNavigationBarColor ()) != 0 ;
689+ Color .alpha (activity .getWindow ().getNavigationBarColor ()) != 0 ;
690690
691691 setDrawBottomInsetForeground (isBehindSystemNav && hasNonZeroAlpha );
692692 }
You can’t perform that action at this time.
0 commit comments