@@ -92,6 +92,7 @@ public class BottomSheetDialog extends AppCompatDialog {
9292 private EdgeToEdgeCallback edgeToEdgeCallback ;
9393 private boolean edgeToEdgeEnabled ;
9494 @ Nullable private MaterialBackOrchestrator backOrchestrator ;
95+ private List <Protection > protectionsList ;
9596
9697 public BottomSheetDialog (@ NonNull Context context ) {
9798 this (context , 0 );
@@ -291,8 +292,11 @@ public boolean getEdgeToEdgeEnabled() {
291292 * existing Protections. An empty list will clear the Protections.
292293 */
293294 public void setProtections (@ NonNull List <Protection > protections ) {
294- protectionLayout .setProtections (protections );
295- protectionLayout .setVisibility (protections .isEmpty () ? View .GONE : View .VISIBLE );
295+ protectionsList = protections ;
296+ if (protectionLayout != null ) {
297+ protectionLayout .setProtections (protections );
298+ protectionLayout .setVisibility (protections .isEmpty () ? View .GONE : View .VISIBLE );
299+ }
296300 }
297301
298302 /** Creates the container layout which must exist to find the behavior */
@@ -301,6 +305,9 @@ private FrameLayout ensureContainerAndBehavior() {
301305 container =
302306 (FrameLayout ) View .inflate (getContext (), R .layout .design_bottom_sheet_dialog , null );
303307 protectionLayout = (ProtectionLayout ) container .findViewById (R .id .protection_layout );
308+ if (protectionsList != null ) {
309+ setProtections (protectionsList );
310+ }
304311
305312 coordinator = (CoordinatorLayout ) container .findViewById (R .id .coordinator );
306313 bottomSheet = (FrameLayout ) container .findViewById (R .id .design_bottom_sheet );
0 commit comments