-
Notifications
You must be signed in to change notification settings - Fork 818
refactor: added helper method #2666
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
Added Helper Method
Reviewer's Guide by SourceryThis pull request introduces a helper method, No diagrams generated as the changes look simple and do not need a visual representation. 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 @rahul31124 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider renaming
degreeStr
todegreeText
for consistency with the parameter name. - The helper method could be static since it doesn't access any instance members.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 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.
@@ -550,6 +478,33 @@ private void setReceivedData() { | |||
((TextView) servo4TimeLine.getChildAt(i).findViewById(R.id.timeline_box_degree_text)).setText(servoData.getDegree4() + getResources().getString(R.string.robotic_arm_degree_symbol)); | |||
} | |||
} | |||
private void processDegreeInput(EditText degreeText, SeekArc seekArc) { |
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.
suggestion (bug_risk): Review global state usage in processDegreeInput.
The method modifies a shared global variable 'degree' (and 'editEnter'). Ensure that this side effect is intentional and safe given the UI's handling, particularly if multiple text inputs could be manipulated concurrently.
Suggested implementation:
private int processDegreeInput(EditText degreeText, SeekArc seekArc, int currentDegree) {
int previousDegree = currentDegree;
String degreeStr = degreeText.getText().toString().trim();
if (degreeStr.isEmpty()) {
int newDegree = (currentDegree == 0) ? (int) (seekArc.getProgress() * 3.6) : previousDegree;
return newDegree;
} else {
try {
int newDegree = Integer.parseInt(degreeStr);
return newDegree;
} catch (NumberFormatException e) {
degreeText.setText(getResources().getString(R.string.zero));
seekArc.setProgress(0);
toastInvalidValueMessage();
return 0;
}
}
}
degree = processDegreeInput(degreeText4, seekArc4, degree);
Note:
- If there is similar global state usage for "editEnter" or other shared variables, refactor them likewise (e.g., pass them as method parameters or use local variables) so that state changes are explicit.
- Verify that all calling code is updated to use the returned degree value appropriately.
- Adjust any tests or related UI handling to reflect these changes.
Build successful. APKs to test: https://github.com/fossasia/pslab-android/actions/runs/14240361292/artifacts/2874233274 |
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.
LGTM @rahul31124 ! Thank you very much !
Added Helper Method
Fixes #2664 and Fixes #2665
Changes
Added Helper Method
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
Refactor degree input handling in RoboticArmActivity by introducing a helper method to fix issues #2664 and #2665, improving code maintainability and reducing redundancy.
Bug Fixes:
Enhancements: