For a bit of context, I am making a todo App using SQLite and a third party calendar library kizitonwose in Kotlin.
It has kinda been a pain to use mainly because I am fairly new to Kotlin. Basically, a user creates tasks that display Title,Description,StartDate,EndDate and Modified which all use LocalDate.
However, when I try to populate a recycle view, all the items in the database get merged into 1 and I cannot fathom why...
override fun onBindViewHolder(holder: CalendarTaskViewHolder, position: Int) {
val dates = calendarTasks.keys.toList()
val date = dates[position]
if (date == selectedDate) {
val tasks = calendarTasks[date] ?: emptyList()
// Display tasks for the selected date
tasks.forEachIndexed { index, task ->
holder.titleTextView.append(task.taskTitle)
holder.descriptionTextView.append(task.taskDescription)
// Format start and end dates
val dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy")
val formattedStartDate = task.startTime.format(dateFormatter)
val formattedEndDate = task.endTime.format(dateFormatter)
holder.startDate.append(formattedStartDate)
holder.endDate.append(formattedEndDate)
if (index < tasks.size - 1) {
holder.titleTextView.append("\n")
holder.descriptionTextView.append("\n")
holder.startDate.append("\n")
holder.endDate.append("\n")
}
}
} else {
holder.titleTextView.text = ""
holder.descriptionTextView.text = ""
holder.startDate.text = ""
holder.endDate.text = ""
}
holder.itemView.isSelected = position == selectedItemPosition
}
Honestly I have been so stuck with this for weeks now and I have contemplated messaging the actual creator of the calendar hahaha.
For anyone wondering I was trying to mimic Example 3 from the Sample>View in the github. However instead of creating an event using a dialog box, I wanted to retrieve events(tasks) from the database and import them in the calendar matching the startdate with the dates but its frying my brain.
If anyone can help or give some advice I would be very happy. If you need anything else let me know its my first time sending a question.
image of recycleView displaying all tasks in one
I tried using some ChatGPT to try and debug the program but honestly it just gives me a messy response that creates more errors...