Sort chapters by upload date (#3180)

* Added sorting by upload date

Spanish 'strings' contains the proper translation for the new feature.

* Added missing sorting cases handling

Previous commit missed some cases resulting in errors at runtime

* Implemented review changes

Shorter UI text and >= date comparison instead of >
This commit is contained in:
arkon
2020-05-17 10:18:49 -04:00
committed by GitHub
9 changed files with 36 additions and 5 deletions
@@ -35,3 +35,12 @@ class ChapterLoadByNumber {
return chapters.sortedBy { it.chapter_number }
}
}
/**
* Load strategy using the chapter upload date. This ordering ignores scanlators
*/
class ChapterLoadByUploadDate() {
fun get(allChapters: List<Chapter>): List<Chapter> {
return allChapters.sortedBy { it.date_upload }
}
}
@@ -129,6 +129,7 @@ class ReaderPresenter(
when (manga.sorting) {
Manga.SORTING_SOURCE -> ChapterLoadBySource().get(chaptersForReader)
Manga.SORTING_NUMBER -> ChapterLoadByNumber().get(chaptersForReader, selectedChapter)
Manga.SORTING_UPLOAD_DATE -> ChapterLoadByUploadDate().get(chaptersForReader)
else -> error("Unknown sorting method")
}.map(::ReaderChapter)
}