mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-02 06:50:08 +00:00
Compare commits
No commits in common. "a1bf43def9deecfc7f1ad7274d54d889a1ea2399" and "afe5a72c6f143d7abdd60366ac7a4448cef8f672" have entirely different histories.
a1bf43def9
...
afe5a72c6f
@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
## 0.9.20
|
## 0.9.20
|
||||||
|
|
||||||
* `Repos`:
|
|
||||||
* `Common`:
|
|
||||||
* Fixes in `OneToManyAndroidRepo`
|
|
||||||
* New `CursorIterator`
|
|
||||||
|
|
||||||
## 0.9.19
|
## 0.9.19
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
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,12 +143,7 @@ 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(
|
selectDistinct(tableName, columns = valueColumnArray, selection = "$idColumnName=?", selectionArgs = arrayOf(k.keyAsString()), limit = FirstPagePagination(1).limitClause()).use {
|
||||||
tableName,
|
|
||||||
columns = valueColumnArray,
|
|
||||||
selection = "$idColumnName=?",
|
|
||||||
selectionArgs = arrayOf(k.keyAsString())
|
|
||||||
).use {
|
|
||||||
it.count
|
it.count
|
||||||
}
|
}
|
||||||
}.toLong()
|
}.toLong()
|
||||||
|
Loading…
Reference in New Issue
Block a user