Body Metrics Pt. 2/ Rest Timer

Written by: Quincy Williams

This week, I focused on creating the rest timer activity and finishing up the body metrics activity for the RepAdvisor app.

For the rest timer, I ran into the issue of what was the best way to make the timer easy to use for the user, and this created a few different design issues and a lot of refactoring until I was able to find a simple way to handle how the user can set the timer. The user will be able to set the value of time that they want to rest via an edit text field that they can use a button to fill in the timer value. This will occur via a conversion in the timer java class that will take the users value and convert it to milliseconds and report out as a time based on what the user entered.


The updateCountDownText function will handle making sure the timer is set to what the user expects when it is set, paused and stopped. There are other background functions that are in play as well but this function is what makes sure everything stays formatted. There is still some issue to work out with the user setting seconds in the edit text field that I will need to make adjustments on. I will hope to provide progress on that soon, along with some suggestions from the team as to what we can do to improve the activities usefulness.

I also created a few ImageViews, that are treated as buttons, and played with the visibility of them so that way when the timer was running or not running, the app would only show what was needed to be seen and the view would not be too cluttered.

Demo of the Rest Timer activity


For the body metrics activity, I was able to get out some of the kinks with the storing the values that the user would enter for their metrics and be able have them returned to the user when they leave that activity or when they close the application.

I was able to solve this using the shared preferences object in Android Studio. With this object, you can set a key and value pair and those values can be held and recalled at a later time to be stored to specific fields. 


The main part of the issue that I was having was where to apply the changes to the code. After doing some research on how Android Studio handles specific events when moving from one activity to another and when closing the application and I was able to determine that Android Studio calls two separate functions when changing activities and when closing the application, onStop and onDestroy, respectively. Once I was able to override those two functions and attach a debugger to them, I was able to confirm this and then add the needed code that will return the key/value pairs from the shared preferences object when the activity is loaded, via the onStart function.

onStop() function using shared preferences


onStart() function using shared preferences


onDestroy() function using shared preferences



Comments