Fix ResourceID validation check expression #5447
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
related issue : #5404
I changed three methods which have wrong expression
Resource IDs can be negative, but the functions were treating such IDs as invalid. Therefore, I improved the if statement logic to allow valid resource IDs that have negative values to pass through.
Motivation and Context
According to the referenced documentation, resource IDs can be negative, and while some legacy code assumes -1 to be an invalid resource ID, this is incorrect. The issue #5404 involves a method malfunctioning when using an image with a specific negative value as its resource ID, which was identified as a validation issue related to resourceID. The original code incorrectly assumed any negative value to be an invalid resource ID. However, I have refactored it using the correct validation logic as outlined in the android.content.res package.