I'm writing my first Android App. It's my first Java code either.
It's a simple Alarm Clock App.
My View is implemented as a Fragment holding a list (RecycleView) of Alarm Items. Each item displays time in 24H or Am/Pm format.
This fragment observes a corresponding list in the ViewModel: MutableLiveData<ArrayList<AlarmItem>> LiveAlarmList.
The repository also holds a corresponding array AND a copy of the setup parameters.
Now, my question is about the separation of concerns and about efficient processing: Assuming that the user may toggle between 24H/AMPM display. I assume that the Alarm entry in the repository should hold the data in a Display-agnostic format (Say, in milliseconds).
Question: Where do I perform the conversion (Milli to HH:MM)? Should it be done in the ViewModel? In this case it should hold a list of Items of different type (entries such asHour, Minute & AMPM in contrast to timeInMilli). This means that I cannot bubble up the observed method.
On the other hand, if I do use a universal Display-agnostic format, I will have to put logic in the Fragment to calculate the display format.
EDIT:
Question: Assuming the user can sort the list by different keys (Time of Alarm vs. Alphabetic order of Alarm Label) - does the sorting done at the repository and bubbles up to the Fragment or does the repository stays untouched while the sorting done in the ViewModel/Fragment.