[ADDED] Text number formatter for 2 decimal formatting. #81
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.
Added tests as well.
The unit mess is getting out of hands - #60
This pull request introduces a new utility function
formatUnit
for formatting numerical values with their respective units, and refactors existing code to use this new function. Additionally, it includes tests for the new utility function to ensure its correctness.Refactoring and Utility Function Addition:
app/src/main/java/dev/hossain/weatheralert/util/TextFormatter.kt
: AddedformatUnit
function to format float and double values with their units.app/src/main/java/dev/hossain/weatheralert/notification/Notification.kt
: Refactored thetriggerNotification
method to use the newformatUnit
function for consistent formatting of weather alert values. [1] [2]app/src/main/java/dev/hossain/weatheralert/ui/alertslist/CurrentAlertScreen.kt
: Updated theCurrentWeatherAlertPresenter
class to use theformatUnit
function for formatting threshold and current status values.Testing:
app/src/test/java/dev/hossain/weatheralert/util/TextFormatterTest.kt
: Added unit tests for theformatUnit
function to verify its behavior with various input values, including positive, negative, zero, and large numbers.Minor Changes:
app/src/main/java/dev/hossain/weatheralert/ui/alertslist/CurrentAlertScreen.kt
: ModifiedCurrentWeatherAlertsPreview
to update the sample alert note for better clarity.Notification.kt
andCurrentAlertScreen.kt
to include the newformatUnit
utility function. [1] [2]