Adding Exercises

Written by: Quincy Williams

This week, I focused on adding the feature of the user being able to add their own exercises to the application!

We ran into some issues with how we wanted to achieve this due to the fact that we were able to determine that the way that we were initially loading the app, was fine on newer devices, but on older devices, there was a performance issue that slowed down the device's capability to smoothly run the app. Before we made an adjustment to improve exercise loading, we would have each activity that needed to use our local assets, load them manually into an array list and then manipulate the array list afterwards. After our improvements, our exercises are now loaded at the start of the app and performance was greatly increased.

With the performance improvement, this allowed for me to be able to add the functionality for uses to be able to add exercises to the application. We did this by updating the user class, which is what now loads our local assets into an array list and we also created a second array list that will specifically house the custom exercises that users add. The user is then saved and both array lists are combined into one and that array list is what is used to show the users the exercises when they select a category.

The main issue that I ran into with this functionality was the data that was required to create a new exercise. With how we loaded our local assets, we made it very particular with how the data is read in other portions of the app, so there were some fields that are required in order for the functionality to work. Mainly, the ID, as the ID for each exercise is what is used for filtering, loading the exercise in the exercise lists, and for when we show the details for the exercise once it is selected. I was able to find a way accommodate this by having the app check the array list for the custom exercises and increment an integer variable that will hold the id until that id value is not found and that will be the id that is saved.


I was also able to implement regex into some of the fields that are then loaded into string arrays that will get passed into the application and some input validation for each field that will store all of the applicable data and then store the data into the added exercise array list that the data will be loaded from.



Comments