|
|
|
|
@ -40,7 +40,6 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
|
|
|
|
|
private var allSessions = mutableListOf<Session>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var filter: Filter? = null |
|
|
|
|
set(value) { |
|
|
|
|
field = value |
|
|
|
|
@ -49,7 +48,7 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
defineSessions() // all sessions |
|
|
|
|
defineSessions() |
|
|
|
|
refreshData() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -60,9 +59,6 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
this.pendingSessions = requestNewQuery().isNull("startDate").findAll() |
|
|
|
|
.sort("creationDate", Sort.DESCENDING) |
|
|
|
|
|
|
|
|
|
// Timber.d(">>> startedSessions count = ${startedSessions.size}") |
|
|
|
|
// Timber.d(">>> pendingSessions count = ${pendingSessions.size}") |
|
|
|
|
|
|
|
|
|
// listeners |
|
|
|
|
this.startedSessions.addChangeListener { _, _ -> |
|
|
|
|
refreshData() |
|
|
|
|
@ -162,13 +158,9 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
} else { |
|
|
|
|
// Else, return the formatted date |
|
|
|
|
sortedHeaders[position]?.getMonthAndYear() ?: throw PAIllegalStateException("Null date should not happen there") |
|
|
|
|
|
|
|
|
|
// val realmHeaderPosition = sortedHeaders.keys.indexOf(position) |
|
|
|
|
// distinctHeaders[realmHeaderPosition]?.startDate?.getMonthAndYear() ?: throw PAIllegalStateException("Null date should not happen there") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
throw PAIllegalStateException("Any position should always have a header, position = $position") |
|
|
|
|
// return NULL_TEXT |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun sessionIdForPosition(position: Int): String? { |
|
|
|
|
@ -189,7 +181,6 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Timber.d("getSessionForPosition = ${position}, headersBefore = $headersBefore") |
|
|
|
|
return allSessions[position - headersBefore] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -202,10 +193,6 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
allSessions.addAll(this.pendingSessions) |
|
|
|
|
allSessions.addAll(this.startedSessions) |
|
|
|
|
|
|
|
|
|
// allSessions.forEach { |
|
|
|
|
// Timber.d(">>> startdate = ${it.startDate}, creationDate = ${it.creationDate}") |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
val headersPositions = HashMap<Int, Date?>() |
|
|
|
|
|
|
|
|
|
val start = System.currentTimeMillis() |
|
|
|
|
@ -217,7 +204,6 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
|
|
|
|
|
// Add headers if the date doesn't exist yet |
|
|
|
|
for ((index, session) in allSessions.withIndex()) { |
|
|
|
|
// Timber.d("/// $index > date = ${session.startDate}") |
|
|
|
|
|
|
|
|
|
val startDate = session.startDate |
|
|
|
|
if (startDate == null) { |
|
|
|
|
@ -225,7 +211,6 @@ class FeedSessionRowRepresentableAdapter( |
|
|
|
|
} else { |
|
|
|
|
calendar.time = startDate |
|
|
|
|
if (checkHeaderCondition(calendar, previousYear, previousMonth)) { |
|
|
|
|
// Timber.d("ADDS HEADER for position= ${index + headersPositions.size}, date = ${session.startDate}") |
|
|
|
|
headersPositions[index + headersPositions.size] = startDate |
|
|
|
|
previousYear = calendar.get(Calendar.YEAR) |
|
|
|
|
previousMonth = calendar.get(Calendar.MONTH) |
|
|
|
|
|