Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BottomSheet] Recycle the TypedArray after usage #4032

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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