Skip to content

Commit

Permalink
Adds clarity and detail to the water intake remaining in MainActivity…
Browse files Browse the repository at this point in the history
…2.java
  • Loading branch information
LeSebring committed Oct 18, 2022
1 parent e89740b commit eddefc9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/src/main/java/com/example/deco3801project/MainActivity2.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ protected void onCreate(Bundle savedInstanceState) {

// The total amount of water to drink initially
TextView amountToDrink = findViewById(R.id.amountToDrink);
amountToDrink.setText(String.valueOf(pref.getInt("currentAmountLeftToDrink", 0)));
amountToDrink.setText(String.valueOf(pref.getInt("currentAmountLeftToDrink", 0))
.concat(" of ")
.concat(String.valueOf(pref.getInt("recommendedIntake", 0)))
.concat(" remaining"));

// The percentage of the amount left to drink
TextView amountToDrinkPercent = findViewById(R.id.amountToDrinkPercentage);
Expand Down Expand Up @@ -260,7 +263,10 @@ public void logIntakeHelper(int drink) {
TextView amountToDrinkPercent = findViewById(R.id.amountToDrinkPercentage);

// Update the TextViews' texts appropriately
amountToDrink.setText(String.valueOf(currentAmountLeftToDrink));
amountToDrink.setText(String.valueOf(currentAmountLeftToDrink)
.concat(" of ")
.concat(String.valueOf(pref.getInt("recommendedIntake", 0)))
.concat(" remaining"));
double percentageRemaining = calculateRemainingPercentage();
amountToDrinkPercent.setText(String.valueOf((int) percentageRemaining).concat("%"));
drinkInput.setText("");
Expand Down Expand Up @@ -343,7 +349,10 @@ private void resetWaterIntake() {
TextView amountToDrinkPercent = findViewById(R.id.amountToDrinkPercentage);

// Update the TextViews' texts appropriately
amountToDrink.setText(String.valueOf(recommendedIntake));
amountToDrink.setText(String.valueOf(recommendedIntake)
.concat(" of ")
.concat(String.valueOf(recommendedIntake))
.concat(" remaining"));
amountToDrinkPercent.setText(maxPercentage);
}

Expand Down

0 comments on commit eddefc9

Please sign in to comment.