|
|
|
@ -171,6 +171,7 @@ class DetailsViewModel(
|
|
|
|
branch: String?,
|
|
|
|
branch: String?,
|
|
|
|
): List<ChapterListItem> {
|
|
|
|
): List<ChapterListItem> {
|
|
|
|
val result = ArrayList<ChapterListItem>(chapters.size)
|
|
|
|
val result = ArrayList<ChapterListItem>(chapters.size)
|
|
|
|
|
|
|
|
val dateFormat = settings.dateFormat()
|
|
|
|
val currentIndex = chapters.indexOfFirst { it.id == currentId }
|
|
|
|
val currentIndex = chapters.indexOfFirst { it.id == currentId }
|
|
|
|
val firstNewIndex = chapters.size - newCount
|
|
|
|
val firstNewIndex = chapters.size - newCount
|
|
|
|
for (i in chapters.indices) {
|
|
|
|
for (i in chapters.indices) {
|
|
|
|
@ -185,7 +186,8 @@ class DetailsViewModel(
|
|
|
|
i < currentIndex -> ChapterExtra.READ
|
|
|
|
i < currentIndex -> ChapterExtra.READ
|
|
|
|
else -> ChapterExtra.UNREAD
|
|
|
|
else -> ChapterExtra.UNREAD
|
|
|
|
},
|
|
|
|
},
|
|
|
|
isMissing = false
|
|
|
|
isMissing = false,
|
|
|
|
|
|
|
|
dateFormat = dateFormat,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
@ -202,6 +204,7 @@ class DetailsViewModel(
|
|
|
|
val result = ArrayList<ChapterListItem>(sourceChapters.size)
|
|
|
|
val result = ArrayList<ChapterListItem>(sourceChapters.size)
|
|
|
|
val currentIndex = sourceChapters.indexOfFirst { it.id == currentId }
|
|
|
|
val currentIndex = sourceChapters.indexOfFirst { it.id == currentId }
|
|
|
|
val firstNewIndex = sourceChapters.size - newCount
|
|
|
|
val firstNewIndex = sourceChapters.size - newCount
|
|
|
|
|
|
|
|
val dateFormat = settings.dateFormat()
|
|
|
|
for (i in sourceChapters.indices) {
|
|
|
|
for (i in sourceChapters.indices) {
|
|
|
|
val chapter = sourceChapters[i]
|
|
|
|
val chapter = sourceChapters[i]
|
|
|
|
if (chapter.branch != branch) {
|
|
|
|
if (chapter.branch != branch) {
|
|
|
|
@ -215,7 +218,8 @@ class DetailsViewModel(
|
|
|
|
i < currentIndex -> ChapterExtra.READ
|
|
|
|
i < currentIndex -> ChapterExtra.READ
|
|
|
|
else -> ChapterExtra.UNREAD
|
|
|
|
else -> ChapterExtra.UNREAD
|
|
|
|
},
|
|
|
|
},
|
|
|
|
isMissing = false
|
|
|
|
isMissing = false,
|
|
|
|
|
|
|
|
dateFormat = dateFormat,
|
|
|
|
) ?: chapter.toListItem(
|
|
|
|
) ?: chapter.toListItem(
|
|
|
|
extra = when {
|
|
|
|
extra = when {
|
|
|
|
i >= firstNewIndex -> ChapterExtra.NEW
|
|
|
|
i >= firstNewIndex -> ChapterExtra.NEW
|
|
|
|
@ -223,13 +227,14 @@ class DetailsViewModel(
|
|
|
|
i < currentIndex -> ChapterExtra.READ
|
|
|
|
i < currentIndex -> ChapterExtra.READ
|
|
|
|
else -> ChapterExtra.UNREAD
|
|
|
|
else -> ChapterExtra.UNREAD
|
|
|
|
},
|
|
|
|
},
|
|
|
|
isMissing = true
|
|
|
|
isMissing = true,
|
|
|
|
|
|
|
|
dateFormat = dateFormat,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chaptersMap.isNotEmpty()) { // some chapters on device but not online source
|
|
|
|
if (chaptersMap.isNotEmpty()) { // some chapters on device but not online source
|
|
|
|
result.ensureCapacity(result.size + chaptersMap.size)
|
|
|
|
result.ensureCapacity(result.size + chaptersMap.size)
|
|
|
|
chaptersMap.values.mapTo(result) {
|
|
|
|
chaptersMap.values.mapTo(result) {
|
|
|
|
it.toListItem(ChapterExtra.UNREAD, false)
|
|
|
|
it.toListItem(ChapterExtra.UNREAD, false, dateFormat)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.sortBy { it.chapter.number }
|
|
|
|
result.sortBy { it.chapter.number }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|