mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-17 22:03:50 +00:00
commit
1f9302dc94
@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.4.30
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Klock`: `2.0.6` -> `2.0.7`
|
||||||
|
* `Pagination`:
|
||||||
|
* New variable `defaultPaginationPageSize` has been added to be able to change default pagination size
|
||||||
|
* Add new value `firstPageWithOneElementPagination`
|
||||||
|
|
||||||
## 0.4.29
|
## 0.4.29
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
@ -13,7 +13,7 @@ kotlin_exposed_version=0.29.1
|
|||||||
|
|
||||||
ktor_version=1.5.2
|
ktor_version=1.5.2
|
||||||
|
|
||||||
klockVersion=2.0.6
|
klockVersion=2.0.7
|
||||||
|
|
||||||
github_release_plugin_version=2.2.12
|
github_release_plugin_version=2.2.12
|
||||||
|
|
||||||
@ -44,5 +44,5 @@ dokka_version=1.4.20
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.4.29
|
version=0.4.30
|
||||||
android_code_version=33
|
android_code_version=34
|
||||||
|
@ -7,14 +7,17 @@ const val defaultMediumPageSize = 5
|
|||||||
const val defaultLargePageSize = 10
|
const val defaultLargePageSize = 10
|
||||||
const val defaultExtraLargePageSize = 15
|
const val defaultExtraLargePageSize = 15
|
||||||
|
|
||||||
|
var defaultPaginationPageSize = defaultMediumPageSize
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE", "FunctionName")
|
@Suppress("NOTHING_TO_INLINE", "FunctionName")
|
||||||
inline fun FirstPagePagination(size: Int = defaultMediumPageSize) =
|
inline fun FirstPagePagination(size: Int = defaultPaginationPageSize) =
|
||||||
SimplePagination(
|
SimplePagination(
|
||||||
page = 0,
|
page = 0,
|
||||||
size = size
|
size = size
|
||||||
)
|
)
|
||||||
|
|
||||||
val emptyPagination = Pagination(0, 0)
|
val emptyPagination = Pagination(0, 0)
|
||||||
|
val firstPageWithOneElementPagination = FirstPagePagination(1)
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun Pagination.nextPage() =
|
inline fun Pagination.nextPage() =
|
||||||
|
@ -36,6 +36,6 @@ class PaginatedIterable<T>(
|
|||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun <T> makeIterable(
|
inline fun <T> makeIterable(
|
||||||
noinline countGetter: () -> Long,
|
noinline countGetter: () -> Long,
|
||||||
pageSize: Int = defaultMediumPageSize,
|
pageSize: Int = defaultPaginationPageSize,
|
||||||
noinline paginationResultGetter: Pagination.() -> PaginationResult<T>
|
noinline paginationResultGetter: Pagination.() -> PaginationResult<T>
|
||||||
): Iterable<T> = PaginatedIterable(pageSize, countGetter, paginationResultGetter)
|
): Iterable<T> = PaginatedIterable(pageSize, countGetter, paginationResultGetter)
|
||||||
|
@ -18,6 +18,6 @@ val Pagination.asUrlQueryArrayParts
|
|||||||
val Map<String, String?>.extractPagination: Pagination
|
val Map<String, String?>.extractPagination: Pagination
|
||||||
get() = SimplePagination(
|
get() = SimplePagination(
|
||||||
get(paginationPageKey) ?.toIntOrNull() ?: 0,
|
get(paginationPageKey) ?.toIntOrNull() ?: 0,
|
||||||
get(paginationSizeKey) ?.toIntOrNull() ?: defaultMediumPageSize
|
get(paginationSizeKey) ?.toIntOrNull() ?: defaultPaginationPageSize
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import io.ktor.http.Parameters
|
|||||||
val Parameters.extractPagination: Pagination
|
val Parameters.extractPagination: Pagination
|
||||||
get() = SimplePagination(
|
get() = SimplePagination(
|
||||||
get("page") ?.toIntOrNull() ?: 0,
|
get("page") ?.toIntOrNull() ?: 0,
|
||||||
get("size") ?.toIntOrNull() ?: defaultMediumPageSize
|
get("size") ?.toIntOrNull() ?: defaultPaginationPageSize
|
||||||
)
|
)
|
||||||
|
|
||||||
val ApplicationCall.extractPagination: Pagination
|
val ApplicationCall.extractPagination: Pagination
|
||||||
|
Loading…
Reference in New Issue
Block a user