Editing Exercises/Timer Improvements

Written by: Quincy Williams

This week, I continued to focus on finishing up the exercises functionality by introducing the ability for users to be able to edit exercises. This will allow for users to be able edit both loaded and added exercises and add the edited version back into their respective arraylist in the application.

With that being said, there were a few issues that I ran into with doing this. Once I was able to get the date from the exercise, by pulling its ID and gathering the data from the ID, the fields would be filled in a new activity with the data but when the data was saved and the exercise was opened in exercise details, the formatting functions that we using were causing the data to return in an unclean fashion. This would continue to happen every time the exercise was added.

To get around this, I was able to come up with a way to check for specific values in a string and use the replaceAll method to replace those specific strings with an empty string. After replacing values, I would then split the string by newlines, for the default exercises that are created from our local files, and split by periods for the custom exercises. This also required the need for adjusting how we formatted the strings as well, in particular the steps, so that way no matter how the fields were edited, they would return the same way every time the exercise was saved and reloaded in exercise details.



The second focus of this week was improving our timers UI and functionality to increase usability. There were a few issues that we ran into with saving variables dynamically when the countdown timer had already been started. We added three new buttons to the activity, one to add 30 seconds to the timer, one to subtract 30 seconds and the last to skip the timer all together and jump to the routines activity to continue exercising, if the user wanted to. 

When selecting one of the add or subtract time buttons, the value would update, along with the progress bars value, but the onTick() function in the countdown timer would reset back to its initial value and count from there. We were able to resolve this by essentially stopping the countdown timer and updating the the counters initial value to our new value by adding 30,000 or subtracting 30,000 milliseconds from the initial variable and then starting the timer again with the new value. This seamlessly allows for the timer to look like it is updating on the fly when the user wants to add or take away time. The progress bar was also updated to reflect that the progress of the bar should change based on how much time is left, and the progress bars max value is also increased, or decreased, if one of these options are selected as to ensure that the timer can never be set back to its full time unless completely stopped and a new time is entered.



Comments