Skip to content
This repository was archived by the owner on Feb 3, 2020. It is now read-only.

Commit 060c79c

Browse files
Merge pull request #111 from recruit-lifestyle/feature/fix_null_cutout
Fix #110
2 parents 5c967b3 + 787a529 commit 060c79c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

library/src/main/java/jp/co/recruit_lifestyle/android/floatingview/FloatingViewManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import android.view.HapticFeedbackConstants;
3333
import android.view.MotionEvent;
3434
import android.view.View;
35+
import android.view.WindowInsets;
3536
import android.view.WindowManager;
3637
import android.widget.FrameLayout;
3738

@@ -616,8 +617,14 @@ public static Rect findCutoutSafeArea(@NonNull Activity activity) {
616617
return safeInsetRect;
617618
}
618619

620+
// Fix: getDisplayCutout() on a null object reference (issue #110)
621+
final WindowInsets windowInsets = activity.getWindow().getDecorView().getRootWindowInsets();
622+
if (windowInsets == null) {
623+
return safeInsetRect;
624+
}
625+
619626
// set safeInsetRect
620-
final DisplayCutout displayCutout = activity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
627+
final DisplayCutout displayCutout = windowInsets.getDisplayCutout();
621628
if (displayCutout != null) {
622629
safeInsetRect.set(displayCutout.getSafeInsetLeft(), displayCutout.getSafeInsetTop(), displayCutout.getSafeInsetRight(), displayCutout.getSafeInsetBottom());
623630
}

0 commit comments

Comments
 (0)