Added sorting by upload date

Spanish 'strings' contains the proper translation for the new feature.
This commit is contained in:
Lautaro Martin Emanuel
2020-05-14 23:38:19 -03:00
parent a9d16fad34
commit ee8c71c14a
6 changed files with 21 additions and 5 deletions

View File

@ -78,7 +78,8 @@ interface Manga : SManga {
const val SORTING_SOURCE = 0x00000000
const val SORTING_NUMBER = 0x00000100
const val SORTING_MASK = 0x00000100
const val SORTING_UPLOAD_DATE = 0x00000200
const val SORTING_MASK = 0x00000300
const val DISPLAY_NAME = 0x00000000
const val DISPLAY_NUMBER = 0x00100000

View File

@ -196,11 +196,13 @@ class ChaptersController :
}
// Sorting mode submenu
if (presenter.manga.sorting == Manga.SORTING_SOURCE) {
menu.findItem(R.id.sort_by_source).isChecked = true
} else {
menu.findItem(R.id.sort_by_number).isChecked = true
val sortingItem = when (presenter.manga.sorting) {
Manga.SORTING_SOURCE -> R.id.sort_by_source
Manga.SORTING_NUMBER -> R.id.sort_by_number
Manga.SORTING_UPLOAD_DATE -> R.id.sort_by_upload_date
else -> throw NotImplementedError("Unimplemented sorting method")
}
menu.findItem(sortingItem).isChecked = true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -222,6 +224,10 @@ class ChaptersController :
item.isChecked = true
presenter.setSorting(Manga.SORTING_NUMBER)
}
R.id.sort_by_upload_date -> {
item.isChecked = true
presenter.setSorting(Manga.SORTING_UPLOAD_DATE)
}
R.id.download_next, R.id.download_next_5, R.id.download_next_10,
R.id.download_custom, R.id.download_unread, R.id.download_all

View File

@ -203,6 +203,10 @@ class ChaptersPresenter(
true -> { c1, c2 -> c2.chapter_number.compareTo(c1.chapter_number) }
false -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
}
Manga.SORTING_UPLOAD_DATE -> when (sortDescending()) {
true -> { c1, c2 -> c2.date_upload.compareTo(c1.date_upload) }
false -> { c1, c2 -> c1.date_upload.compareTo(c2.date_upload) }
}
else -> throw NotImplementedError("Unimplemented sorting method")
}
return observable.toSortedList(sortFunction)