Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ private void resetImageView(@NonNull final ImageView imageView) {

private static void setBitmapOrBlack(@NonNull final ImageView imageView,
@Nullable final ThumbnailBitmap stackBitmap) {
if (stackBitmap != null) {
imageView.setImageBitmap(stackBitmap.getRotatedBitmap());
Bitmap bitmap = (stackBitmap != null) ? stackBitmap.getRotatedBitmap() : null;
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces a potential issue where getRotatedBitmap() could return null (if the underlying bitmap is null), but the original logic assumed it would always return a valid bitmap when stackBitmap is not null. The null check should be performed after calling getRotatedBitmap() to handle cases where the method returns null.

Copilot uses AI. Check for mistakes.
if (bitmap != null) {
imageView.setImageBitmap(bitmap);
} else {
imageView.setImageBitmap(null);
imageView.setBackgroundColor(Color.BLACK);
Expand All @@ -132,7 +133,7 @@ static class ThumbnailBitmap {
}

final Bitmap getRotatedBitmap() {
if (rotatedBitmap == null) {
if (rotatedBitmap == null && bitmap != null) {
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
Comment on lines 137 to 139
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null check for bitmap should be performed before calling bitmap.getWidth() and bitmap.getHeight() on line 139. If bitmap becomes null between this check and the createBitmap call, it will still cause a NullPointerException.

Suggested change
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
Bitmap localBitmap = bitmap; // Store a local reference to ensure consistency
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
rotatedBitmap = Bitmap.createBitmap(localBitmap, 0, 0, localBitmap.getWidth(), localBitmap.getHeight(), matrix, true);

Copilot uses AI. Check for mistakes.
Expand Down
Loading