Skip to content

Commit

Permalink
[BottomSheet] Recycle the TypedArray after usage
Browse files Browse the repository at this point in the history
Resolves #4032

GIT_ORIGIN_REV_ID=f9ac4cf68c6ef7cd41d0bbdca2c7d09b0f99f5d9
PiperOrigin-RevId: 633632973
  • Loading branch information
pubiqq authored and dsn5ft committed May 15, 2024
1 parent 9b6ceac commit a89e38c
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,38 +90,33 @@ public class BottomSheetDialog extends AppCompatDialog {

public BottomSheetDialog(@NonNull Context context) {
this(context, 0);

edgeToEdgeEnabled =
getContext()
.getTheme()
.obtainStyledAttributes(new int[] {R.attr.enableEdgeToEdge})
.getBoolean(0, false);
initialize();
}

public BottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
super(context, getThemeResId(context, theme));
// We hide the title bar for any style configuration. Otherwise, there will be a gap
// above the bottom sheet when it is expanded.
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

edgeToEdgeEnabled =
getContext()
.getTheme()
.obtainStyledAttributes(new int[] {R.attr.enableEdgeToEdge})
.getBoolean(0, false);
initialize();
}

protected BottomSheetDialog(
@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
this.cancelable = cancelable;
initialize();
}

private void initialize() {
final TypedArray a = getContext()
.getTheme()
.obtainStyledAttributes(new int[] {R.attr.enableEdgeToEdge});

edgeToEdgeEnabled = a.getBoolean(0, false);

edgeToEdgeEnabled =
getContext()
.getTheme()
.obtainStyledAttributes(new int[] {R.attr.enableEdgeToEdge})
.getBoolean(0, false);
a.recycle();
}

@Override
Expand Down

0 comments on commit a89e38c

Please sign in to comment.