mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-26 12:08:45 +00:00
fixes in reverse extension
This commit is contained in:
parent
64b0184a17
commit
ff905e1491
@ -11,12 +11,16 @@ import dev.inmo.micro_utils.pagination.*
|
|||||||
* @return Reversed version of this [Pagination]
|
* @return Reversed version of this [Pagination]
|
||||||
*/
|
*/
|
||||||
fun Pagination.reverse(objectsCount: Long): SimplePagination {
|
fun Pagination.reverse(objectsCount: Long): SimplePagination {
|
||||||
if (firstIndex > objectsCount) {
|
val resultSize = minOf(size, objectsCount.toInt())
|
||||||
return Pagination(objectsCount.toInt(), size)
|
return when {
|
||||||
}
|
firstIndex > objectsCount -> Pagination(calculatePage(resultSize, resultSize), resultSize)
|
||||||
val firstIndex = (objectsCount - firstIndex - size).toInt()
|
size > objectsCount -> FirstPagePagination(resultSize)
|
||||||
return Pagination(
|
else -> {
|
||||||
|
val firstIndex = (objectsCount - firstIndex - resultSize).toInt()
|
||||||
|
Pagination(
|
||||||
firstIndex,
|
firstIndex,
|
||||||
size
|
resultSize
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user