From 750a8b9ecf2f2acd465ee58df1f0da5bf1b6140b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 12 Apr 2022 15:13:25 +0600 Subject: [PATCH 1/4] start 0.9.20 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 591beb46753..190b3f631d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.9.20 + ## 0.9.19 * `Versions`: diff --git a/gradle.properties b/gradle.properties index c9570b66ce6..fc33e33ef90 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.9.19 -android_code_version=109 +version=0.9.20 +android_code_version=110 From afe5a72c6f143d7abdd60366ac7a4448cef8f672 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 12 Apr 2022 15:32:25 +0600 Subject: [PATCH 2/4] small fix of docs --- .../inmo/micro_utils/pagination/utils/PaginationReversing.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/PaginationReversing.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/PaginationReversing.kt index a1b58660f1d..0609369ba25 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/PaginationReversing.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/PaginationReversing.kt @@ -6,7 +6,7 @@ import dev.inmo.micro_utils.pagination.* * Example: * * * `|__f__l_______________________|` will be transformed to `|_______________________f__l__|` - * * `|__f__l_|` will be transformed to `|__f__l_|` + * * `|__f__l_|` will be transformed to `|_f__l__|` * * @return Reversed version of this [Pagination] */ From 15e9254e007e4c8c14e221c5bda2172daeecd9a5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 13 Apr 2022 15:54:48 +0600 Subject: [PATCH 3/4] fixes in OneToManyAndroidRepo and adding of CursorIterator --- CHANGELOG.md | 5 ++++ .../inmo/micro_utils/repos/CursorIterator.kt | 27 +++++++++++++++++++ .../repos/onetomany/OneToManyAndroidRepo.kt | 8 +++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/CursorIterator.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 190b3f631d1..b8ddee40a15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## 0.9.20 +* `Repos`: + * `Common`: + * Fixes in `OneToManyAndroidRepo` + * New `CursorIterator` + ## 0.9.19 * `Versions`: diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/CursorIterator.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/CursorIterator.kt new file mode 100644 index 00000000000..9c7d21fcbcd --- /dev/null +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/CursorIterator.kt @@ -0,0 +1,27 @@ +package dev.inmo.micro_utils.repos + +import android.database.Cursor + +class CursorIterator( + private val c: Cursor +) : Iterator { + private var i = 0 + + init { + c.moveToFirst() + } + override fun hasNext(): Boolean { + return i < c.count + } + + override fun next(): Cursor { + i++ + return if (c.moveToNext()) { + c + } else { + throw NoSuchElementException() + } + } +} + +operator fun Cursor.iterator(): CursorIterator = CursorIterator(this) diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt index 1cc184fc2b4..96be3bd2f77 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt @@ -143,7 +143,13 @@ class OneToManyAndroidRepo( }.toLong() override suspend fun count(k: Key): Long = helper.blockingReadableTransaction { - selectDistinct(tableName, columns = valueColumnArray, selection = "$idColumnName=?", selectionArgs = arrayOf(k.keyAsString()), limit = FirstPagePagination(1).limitClause()).use { + select( + tableName, + columns = valueColumnArray, + selection = "$idColumnName=?", + selectionArgs = arrayOf(k.keyAsString()), + limit = FirstPagePagination(1).limitClause() + ).use { it.count } }.toLong() From a1bf43def9deecfc7f1ad7274d54d889a1ea2399 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 13 Apr 2022 16:01:13 +0600 Subject: [PATCH 4/4] upfixes --- .../inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt index 96be3bd2f77..31abcac4e61 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt @@ -143,12 +143,11 @@ class OneToManyAndroidRepo( }.toLong() override suspend fun count(k: Key): Long = helper.blockingReadableTransaction { - select( + selectDistinct( tableName, columns = valueColumnArray, selection = "$idColumnName=?", - selectionArgs = arrayOf(k.keyAsString()), - limit = FirstPagePagination(1).limitClause() + selectionArgs = arrayOf(k.keyAsString()) ).use { it.count }