mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-12 21:42:49 +01:00
Reword download chapter number sorting options
This commit is contained in:
parent
a083e1f71a
commit
e288bf902b
@ -147,31 +147,26 @@ class DownloadController :
|
|||||||
presenter.clearQueue()
|
presenter.clearQueue()
|
||||||
}
|
}
|
||||||
R.id.newest, R.id.oldest -> {
|
R.id.newest, R.id.oldest -> {
|
||||||
val adapter = adapter ?: return false
|
reorderQueue({ it.download.chapter.date_upload }, item.itemId == R.id.newest)
|
||||||
val items = adapter.currentItems.sortedBy { it.download.chapter.date_upload }
|
|
||||||
.toMutableList()
|
|
||||||
if (item.itemId == R.id.newest) {
|
|
||||||
items.reverse()
|
|
||||||
}
|
|
||||||
adapter.updateDataSet(items)
|
|
||||||
val downloads = items.mapNotNull { it.download }
|
|
||||||
presenter.reorder(downloads)
|
|
||||||
}
|
}
|
||||||
R.id.bigest, R.id.smallest -> {
|
R.id.asc, R.id.desc -> {
|
||||||
val adapter = adapter ?: return false
|
reorderQueue({ it.download.chapter.chapter_number }, item.itemId == R.id.desc)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun <R : Comparable<R>> reorderQueue(selector: (DownloadItem) -> R, reverse: Boolean = false) {
|
||||||
|
val adapter = adapter ?: return
|
||||||
|
val items = adapter.currentItems.sortedBy(selector).toMutableList()
|
||||||
|
if (reverse) {
|
||||||
|
items.reverse()
|
||||||
|
}
|
||||||
|
adapter.updateDataSet(items)
|
||||||
|
val downloads = items.mapNotNull { it.download }
|
||||||
|
presenter.reorder(downloads)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the status of a download changes.
|
* Called when the status of a download changes.
|
||||||
*
|
*
|
||||||
|
@ -26,11 +26,11 @@
|
|||||||
app:showAsAction="never">
|
app:showAsAction="never">
|
||||||
<menu>
|
<menu>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/bigest"
|
android:id="@+id/asc"
|
||||||
android:title="@string/action_bigest" />
|
android:title="@string/action_asc" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/smallest"
|
android:id="@+id/desc"
|
||||||
android:title="@string/action_smallest" />
|
android:title="@string/action_desc" />
|
||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -107,8 +107,8 @@
|
|||||||
<string name="action_order_by_chapter_number">By chapter number</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_asc">Ascending</string>
|
||||||
<string name="action_smallest">Smallest</string>
|
<string name="action_desc">Descending</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>
|
||||||
|
Loading…
Reference in New Issue
Block a user