fix(nearby): Prevent crash in offline search caused by null map boundaries #6579
+19
−2
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
Fixes #6469
What changes did you make and why?
This pull request addresses a critical application crash (
NullPointerException) that was triggered when users attempted an action requiring location data (like taking a picture from the "Nearby" tab) while the device was offline or had a severely flaky internet connection.The root cause was that the
NearbyParentFragmentPresenterattempted to fetch map boundary coordinates (screenBottomLeftandscreenTopRight) from the map view. When offline, these coordinates were often uninitialized and returned null. This null value was then passed down to the Java data source method, leading to a crash when code attempted to call.getLatitude()on the null object.The solution ensures robust handling of the offline/uninitialized state:
screenBottomLeftandscreenTopRightwithin thehandleMapScrolledoffline logic. If the map boundaries are null, the local place search job is now gracefully exited, preventing the null values from ever reaching the data layer.fetchPlacesmethod. If either map boundary input is null, it now returns an empty list immediately instead of risking aNullPointerExceptionon the map boundary processing logicc.Tests performed (required)
Tested ProDebug on Redmi Note 13 Pro 5g with API level 35.
Screenshots (for UI changes only)
N/A (This is a code stability fix, not a UI change)