-
Notifications
You must be signed in to change notification settings - Fork 47
Fix: Gallery crash when clicking null images in replies #110
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
Conversation
- Add validation in GalleryActivity.open() to check for null/invalid images before opening gallery - Add null safety checks in GalleryAdapter to handle null image objects - Add null checks in getCurrentImage() and menu actions to prevent NPE - Add ProGuard rules to keep ImagesInfo classes from being obfuscated - Show "图片不存在" toast when attempting to open gallery with invalid images This fixes the crash that occurred only in release builds when clicking on images in reply lists that had null or invalid image data. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this 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 that occurs when clicking on images with null or invalid data in reply lists, specifically affecting release builds due to ProGuard obfuscation issues with the Fruit HTML parsing library.
- Adds comprehensive null safety validation before opening the gallery
- Implements defensive programming in gallery adapter and activity methods
- Adds ProGuard rules to prevent obfuscation of ImagesInfo classes
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| GalleryActivity.java | Adds validation in open() method and null checks in image handling methods |
| GalleryAdapter.java | Adds bounds checking and null safety in getItem() and instantiateItem() methods |
| proguard-rules.pro | Adds keep rules for ImagesInfo classes to prevent obfuscation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| private ImagesInfo.Images.Image getItem(int postion) { | ||
| if (mImagesInfo == null || mImagesInfo.getImages() == null || | ||
| postion < 0 || postion >= mImagesInfo.getImages().size()) { | ||
| return null; | ||
| } | ||
| return mImagesInfo.getImages().get(postion); |
Copilot
AI
Sep 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter name has a typo: 'postion' should be 'position'.
| private ImagesInfo.Images.Image getItem(int postion) { | |
| if (mImagesInfo == null || mImagesInfo.getImages() == null || | |
| postion < 0 || postion >= mImagesInfo.getImages().size()) { | |
| return null; | |
| } | |
| return mImagesInfo.getImages().get(postion); | |
| private ImagesInfo.Images.Image getItem(int position) { | |
| if (mImagesInfo == null || mImagesInfo.getImages() == null || | |
| position < 0 || position >= mImagesInfo.getImages().size()) { | |
| return null; | |
| } | |
| return mImagesInfo.getImages().get(position); |
| private ImagesInfo.Images.Image getItem(int postion) { | ||
| if (mImagesInfo == null || mImagesInfo.getImages() == null || | ||
| postion < 0 || postion >= mImagesInfo.getImages().size()) { | ||
| return null; | ||
| } | ||
| return mImagesInfo.getImages().get(postion); |
Copilot
AI
Sep 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name has a typo: 'postion' should be 'position' (appears twice in this condition).
| private ImagesInfo.Images.Image getItem(int postion) { | |
| if (mImagesInfo == null || mImagesInfo.getImages() == null || | |
| postion < 0 || postion >= mImagesInfo.getImages().size()) { | |
| return null; | |
| } | |
| return mImagesInfo.getImages().get(postion); | |
| private ImagesInfo.Images.Image getItem(int position) { | |
| if (mImagesInfo == null || mImagesInfo.getImages() == null || | |
| position < 0 || position >= mImagesInfo.getImages().size()) { | |
| return null; | |
| } | |
| return mImagesInfo.getImages().get(position); |
- Version code: 237 - Includes gallery crash fix from PR #110
- Version code: 237 - Includes gallery crash fix from PR #110
Summary
Problem
The app crashed with a
NullPointerExceptionwhen users clicked on images in reply lists that had null or invalid image data. This only occurred in release builds because ProGuard was obfuscating theImagesInfoclasses, breaking the Fruit HTML parsing library's reflection mechanism.Solution
GalleryActivity.open(): Checks if images are valid before opening galleryGalleryAdapter: Handles null image objects gracefullyImagesInfoclasses from being obfuscatedTesting
Related Issues
Fixes crash reported when clicking images in reply lists
🤖 Generated with Claude Code