Unable to display events
madhall opened this issue · 0 comments
madhall commented
Hi,
I have been able to display the view and get events from the DB to display on the calendar for the month and year asked for by the listener but nothing is being displayed onScreen
Can you please have a look at the code? to see why there is no events being shown,
Events timings are in timestamp and I am converting them and initializing the calendar with them to pass on as event start and end times
private fun getEvents(newYear: Int, newMonth: Int): ArrayList<WeekViewEvent?>{
//Creating default events array for display in view
val dispEventsArray = ArrayList<WeekViewEvent?>()
dispEventsArray.clear()
val calendar = java.util.Calendar.getInstance()
lifecycle.coroutineScope.launch(Dispatchers.Default) {
val db = AppDatabase.getDatabase(requireActivity())
val events = db.eventsDao().getMnthlyEvents(newMonth,newYear)
val calendarStart = ArrayList<java.util.Calendar?>()
val calendarEnd = ArrayList<java.util.Calendar?>()
var count = 0
for (event in events) {
var cal1 = Calendar.getInstance()
var cal2 = Calendar.getInstance()
cal1.timeInMillis = event.eventStart
cal2.timeInMillis = event.eventEnd
calendarStart.add(cal1)
calendarEnd.add(cal2)
val tmpEvent = WeekViewEvent(event.eventId,event.eventTitle,event.eventLocation,calendarStart[count],calendarEnd[count])
tmpEvent.isAllDay = event.eventAllDay
tmpEvent.color = resources.getColor(R.color.colorLightOther)
dispEventsArray.add(tmpEvent)
count += 1
}
}
return ArrayList(dispEventsArray)
}