0

I'm trying to re-design my app, but I'm not sure the best way to go about it.

I currently have an expandable list view with some workouts as the headers/parent items. Each workout has 4 child items, representing 4 weeks. When the user clicks a week, it sends them to a new activity that has 3 tab fragments(representing monday, wed, and friday). These fragments each have a recycler view, that is populated with data depending on what item is clicked (custom object). Here is a small example:

//RECYCLERVIEW
    final RecyclerView rv = (RecyclerView) view.findViewById(R.id.mRecyclerMon);
    rv.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    rv.setAdapter(new MyRecyclerAdapter(this.getActivity(), getMondayWorkout(), 1));

private ArrayList<Workout> getMondayWorkout() {
    ArrayList<Workout> workout = new ArrayList<>();
    switch (workout3) {
        case "w29w1": {
            Workout workouts = new Workout(getActivity().getString(R.string.benchpress), "50", "5", bench50, false);
            workout.add(workouts);
            workouts = new Workout(getActivity().getString(R.string.benchpress), "60", "4", bench60, false);
            workout.add(workouts);

That's just a small example. This works good, but I would like to make it easier to use. My idea is to have the user select a workout, then add each workout as an event to Caldroid calendar, and when they click that Workout (For example, Monday), the same view I was using before with the recycler view will be used. So far I believe I know how to do all this.

My question is, I'd like to implement a save feature. So when the user is done the Workout, it is saved to the corresponding day on Caldroid, and changes the bg colour of the day so the user knows it is complete. I'm just not sure how I can save the workout so the user can go back to that day and check it out, as right now the recycler view is always re-used, and re-uses the same arraylists, depending on what day they click. I would also like to add an option to take notes, which makes things even more complicated..

Basically I want it so when the user saves the workout they have done, it saves every part of that activity, the recycler view items (including the checkmark state), and the notes taken with that workout.

I have thought about using sqlite, but I'm not sure how exactly I would save the state of an ArrayList/recyclerview with custom objects into sqlite, then refer back to that after the item has been saved and the user clicks on a specific date

If anyone has any help at all, or can point me in the right direction, it is greatly appreciated! I have no idea where to even start! Thanks a lot!

LBJ33
  • 425
  • 11
  • 29

1 Answers1

0

You could just save the data in shared prefeerences and then make public getter fucntions to reuse them?

Ashish Kumar
  • 374
  • 4
  • 11
  • My worry with shared preferences is it could be a rather large amount of data, to save each arraylist(which contains 20+ items) for every workout they do. Over the course of a few months that could become a very large amount of data for shared pref I believe. – LBJ33 Aug 31 '16 at 19:07
  • I have thought about sqlite, but I'm not sure how exactly I would save the state of an ArrayList/recyclerview with custom objects into sqlite – LBJ33 Aug 31 '16 at 19:08
  • Yeah, so for huge data, you must go for sqlite db – Ashish Kumar Aug 31 '16 at 19:08
  • if you could use the object as it is, dump it as a string using Gson, save a type field with that, so that you could use it to cast to your corresponding model while repopulating. If you want a more enhanced thing, make tables for each of your model classes and then create functions which would fetch data from those tables and then return them to your desired format. – Ashish Kumar Aug 31 '16 at 19:12