mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 16:23:50 +00:00
Compare commits
5 Commits
27fc3f93e0
...
6b2298c752
Author | SHA1 | Date | |
---|---|---|---|
6b2298c752 | |||
a1bf43def9 | |||
15e9254e00 | |||
afe5a72c6f | |||
750a8b9ecf |
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.9.20
|
||||||
|
|
||||||
|
* `Repos`:
|
||||||
|
* `Common`:
|
||||||
|
* Fixes in `OneToManyAndroidRepo`
|
||||||
|
* New `CursorIterator`
|
||||||
|
|
||||||
## 0.9.19
|
## 0.9.19
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.9.19
|
version=0.9.20
|
||||||
android_code_version=109
|
android_code_version=110
|
||||||
|
@ -6,7 +6,7 @@ import dev.inmo.micro_utils.pagination.*
|
|||||||
* Example:
|
* 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_|`
|
* * `|__f__l_|` will be transformed to `|_f__l__|`
|
||||||
*
|
*
|
||||||
* @return Reversed version of this [Pagination]
|
* @return Reversed version of this [Pagination]
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package dev.inmo.micro_utils.repos
|
||||||
|
|
||||||
|
import android.database.Cursor
|
||||||
|
|
||||||
|
class CursorIterator(
|
||||||
|
private val c: Cursor
|
||||||
|
) : Iterator<Cursor> {
|
||||||
|
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)
|
@ -143,7 +143,12 @@ class OneToManyAndroidRepo<Key, Value>(
|
|||||||
}.toLong()
|
}.toLong()
|
||||||
|
|
||||||
override suspend fun count(k: Key): Long = helper.blockingReadableTransaction {
|
override suspend fun count(k: Key): Long = helper.blockingReadableTransaction {
|
||||||
selectDistinct(tableName, columns = valueColumnArray, selection = "$idColumnName=?", selectionArgs = arrayOf(k.keyAsString()), limit = FirstPagePagination(1).limitClause()).use {
|
selectDistinct(
|
||||||
|
tableName,
|
||||||
|
columns = valueColumnArray,
|
||||||
|
selection = "$idColumnName=?",
|
||||||
|
selectionArgs = arrayOf(k.keyAsString())
|
||||||
|
).use {
|
||||||
it.count
|
it.count
|
||||||
}
|
}
|
||||||
}.toLong()
|
}.toLong()
|
||||||
|
Loading…
Reference in New Issue
Block a user