-
Notifications
You must be signed in to change notification settings - Fork 817
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
fix: accelerometer screen crash and ui #2656
base: development
Are you sure you want to change the base?
fix: accelerometer screen crash and ui #2656
Conversation
Reviewer's Guide by SourceryThis pull request addresses a crash in the accelerometer screen and improves UI visibility in landscape mode. A check was added to ensure the fragment is attached before accessing resources, preventing the crash. The UI was improved by wrapping the layout in a ScrollView and adjusting dimensions. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @rahul31124 - I've reviewed your changes - here's some feedback:
Overall Comments:
- The added null check
if (!isAdded()) return;
is a good defensive programming practice. - Consider using
requireContext()
instead ofgetContext()
to avoid null pointer exceptions.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Build successful. APKs to test: https://github.com/fossasia/pslab-android/actions/runs/13967870707/artifacts/2787558436 |
Bug Fixes
The accelerometer screen was crashing and not properly visible in landscape mode
Exception
java.lang.IllegalStateException: Fragment AccelerometerDataFragment{ddc3faf} (870ce858-bc85-4f8c-83b6-4f50b7359993) not attached to a context.
at androidx.fragment.app.Fragment.requireContext(Fragment.java:972)
at androidx.fragment.app.Fragment.getResources(Fragment.java:1036)
at androidx.fragment.app.Fragment.getString(Fragment.java:1058)
at io.pslab.fragment.AccelerometerDataFragment.visualizeData(AccelerometerDataFragment.java:429)
Changes
Added if (!isAdded()) return; check at the beginning of the visualizeData() method to ensure that the fragment is properly attached to the activity before attempting to access resources
Used ScrollView to ensure proper UI visibility in landscape mode
Screenshots / Recordings
Before

After
Accelerometer_After.mp4
Checklist:
strings.xml
,dimens.xml
andcolors.xml
without hard coding any value.strings.xml
,dimens.xml
orcolors.xml
.Summary by Sourcery
Fixes a crash in the accelerometer screen and improves UI visibility in landscape mode. The crash was due to the fragment not being attached to a context when accessing resources. This is fixed by adding a check to ensure the fragment is attached before accessing resources. The UI visibility is improved by using ScrollView.
Bug Fixes:
Enhancements: