add sort by chapter number in download queue (#4337)

* add sort by chapter number in download queue

* Bigest, smallest chapter download

* grouped
This commit is contained in:
Riztard Lanthorn 2021-01-24 01:10:57 +07:00 committed by GitHub
parent 86b9d7e843
commit a083e1f71a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 4 deletions

View File

@ -157,6 +157,17 @@ class DownloadController :
val downloads = items.mapNotNull { it.download } val downloads = items.mapNotNull { it.download }
presenter.reorder(downloads) presenter.reorder(downloads)
} }
R.id.bigest, R.id.smallest -> {
val adapter = adapter ?: return false
val items = adapter.currentItems.sortedBy { it.download.chapter.chapter_number }
.toMutableList()
if (item.itemId == R.id.bigest) {
items.reverse()
}
adapter.updateDataSet(items)
val downloads = items.mapNotNull { it.download }
presenter.reorder(downloads)
}
} }
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)
} }

View File

@ -8,11 +8,31 @@
app:showAsAction="never"> app:showAsAction="never">
<menu> <menu>
<item <item
android:id="@+id/newest" android:id="@+id/action_sort_date"
android:title="@string/action_newest" /> android:title="@string/action_order_by_upload_date"
app:showAsAction="never">
<menu>
<item
android:id="@+id/newest"
android:title="@string/action_newest" />
<item
android:id="@+id/oldest"
android:title="@string/action_oldest" />
</menu>
</item>
<item <item
android:id="@+id/oldest" android:id="@+id/action_sort_chapter"
android:title="@string/action_oldest" /> android:title="@string/action_order_by_chapter_number"
app:showAsAction="never">
<menu>
<item
android:id="@+id/bigest"
android:title="@string/action_bigest" />
<item
android:id="@+id/smallest"
android:title="@string/action_smallest" />
</menu>
</item>
</menu> </menu>
</item> </item>

View File

@ -103,8 +103,12 @@
<string name="action_sort">Sort</string> <string name="action_sort">Sort</string>
<string name="action_sort_descending">Descending</string> <string name="action_sort_descending">Descending</string>
<string name="action_reorganize_by">Reorder</string> <string name="action_reorganize_by">Reorder</string>
<string name="action_order_by_upload_date">By upload date</string>
<string name="action_order_by_chapter_number">By chapter number</string>
<string name="action_newest">Newest</string> <string name="action_newest">Newest</string>
<string name="action_oldest">Oldest</string> <string name="action_oldest">Oldest</string>
<string name="action_bigest">Bigest</string>
<string name="action_smallest">Smallest</string>
<string name="action_move_to_top">Move to top</string> <string name="action_move_to_top">Move to top</string>
<string name="action_move_to_bottom">Move to bottom</string> <string name="action_move_to_bottom">Move to bottom</string>
<string name="action_install">Install</string> <string name="action_install">Install</string>