-
Notifications
You must be signed in to change notification settings - Fork 808
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: crash when trying to read data from sensor #2615
Conversation
Reviewer's Guide by SourceryThis pull request addresses a crash that occurs when trying to read data from a sensor. The fix ensures that UI updates happen on the UI thread and adds a check to prevent crashes during orientation changes by verifying if sensor data was successfully acquired. Sequence diagram for sensor data reading and UI update flowsequenceDiagram
participant S as Sensor
participant SF as SensorDataFetch
participant UI as UI Thread
SF->>S: getSensorData()
alt Success
S-->>SF: return data
SF->>SF: isSensorDataAcquired = true
SF->>UI: runOnUiThread(updateUi)
UI->>UI: check isSensorDataAcquired
alt Data Acquired
UI->>UI: update sensor values
UI->>UI: update charts
end
else Failure
S-->>SF: return error
SF->>SF: isSensorDataAcquired = false
end
Class diagram showing AbstractSensorActivity and SensorDataFetch changesclassDiagram
class AbstractSensorActivity {
#class SensorDataFetch
}
class SensorDataFetch {
-boolean isSensorDataAcquired
#boolean isSensorDataAcquired()
#float getTimeElapsed()
#void execute()
#abstract boolean getSensorData()
#abstract void updateUi()
}
AbstractSensorActivity *-- SensorDataFetch
note for SensorDataFetch "Added isSensorDataAcquired flag
and made methods protected"
File-Level Changes
Assessment against linked issues
Possibly linked issues
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 @marcnause - I've reviewed your changes and they look great!
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/12848591628/artifacts/2451769405 |
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.
@marcnause LGTM! We're good to go with this one.
Fixes #2608
Changes
Screenshots / Recordings
N/A
Checklist:
strings.xml
,dimens.xml
andcolors.xml
without hard coding any value.strings.xml
,dimens.xml
orcolors.xml
.Summary by Sourcery
Bug Fixes: