'Data strucutre for weekly reminders

The data structure should have following properties:

  • weekly reminders
  • ability to chose the weekdays and time on each of those weekdays on which the reminders are received
  • delete a reminder on a specific weekday of a specific week
  • query reminders of a specific week(adjacent queries being faster will be better as next/previous week will be shown as the user scrolls

How to implement this kind of data structure and also how to save these to database.

Current implementation which does not support deleting reminder on a specific week

enum class RepetitionType{
    DOES_NOT_REPEAT,
    DAILY, WEEKLY, MONTHLY, YEARLY,
}

@Parcelize
class TimeForDaysOfWeek: HashMap<DayOfWeek, LocalTime>(), Parcelable


@Entity(tableName = "REMINDERS_TABLE")
data class ReminderEntity (
    @PrimaryKey
    val notificationId: Int = 1,
    val title: String,
    val description: String,

    val startTime: LocalDateTime,
    val duration: Long,

    val repeatType: RepetitionType,
    val timeForDaysOfWeek: TimeForDaysOfWeek,

    val foreverState: Boolean,
    val numberToShow: Int,
    val numberShown: Int
)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source