Skip to content

Conversation

obaidgini
Copy link
Contributor

PM-150

@obaidgini obaidgini requested a review from abolfazlimahdi April 9, 2025 13:47
@obaidgini obaidgini self-assigned this Apr 9, 2025
Copy link

sonarqubecloud bot commented Apr 9, 2025

Copy link
Contributor

@abolfazlimahdi abolfazlimahdi left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!

@zladzeyka zladzeyka requested a review from Copilot July 28, 2025 11:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a crash related to bitmap handling in the PhotoThumbnail class by adding null safety checks to prevent NullPointerException when working with bitmap objects.

  • Added null check for bitmap before accessing bitmap properties in rotation logic
  • Improved null safety in the setBitmapOrBlack method by extracting bitmap reference

@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.

Comment on lines 137 to 139
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants