- // The parent view is `null` because it will be assigned by `AlertDialog`.
- dialogBuilder.setView(layoutInflater.inflate(R.layout.download_image_dialog, null));
-
- // Set an `onClick()` listener on the negative button.
- dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // Do nothing if `Cancel` is clicked.
- }
+
+ // Set the icon according to the theme.
+ if (darkTheme) {
+ dialogBuilder.setIcon(R.drawable.images_enabled_dark);
+ } else {
+ dialogBuilder.setIcon(R.drawable.images_enabled_light);
+ }
+
+ // Remove the incorrect lint warning below that `getActivity() might be null.
+ assert getActivity() != null;
+
+ // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`.
+ dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.download_image_dialog, null));
+
+ // Set an listener on the negative button.
+ dialogBuilder.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> {
+ // Do nothing if `Cancel` is clicked.