mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-26 03:58:45 +00:00
Compare commits
No commits in common. "6b2298c75255adc4b598dfc56972cf3d678d5c8d" and "27fc3f93e04137c5fd2a3a6e0e2be4f134a963f5" have entirely different histories.
6b2298c752
...
27fc3f93e0
@ -1,12 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## 0.9.20
|
||||
|
||||
* `Repos`:
|
||||
* `Common`:
|
||||
* Fixes in `OneToManyAndroidRepo`
|
||||
* New `CursorIterator`
|
||||
|
||||
## 0.9.19
|
||||
|
||||
* `Versions`:
|
||||
|
@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.9.20
|
||||
android_code_version=110
|
||||
version=0.9.19
|
||||
android_code_version=109
|
||||
|
@ -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]
|
||||
*/
|
||||
|
@ -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()
|
||||
|
||||
override suspend fun count(k: Key): Long = helper.blockingReadableTransaction {
|
||||
selectDistinct(
|
||||
tableName,
|
||||
columns = valueColumnArray,
|
||||
selection = "$idColumnName=?",
|
||||
selectionArgs = arrayOf(k.keyAsString())
|
||||
).use {
|
||||
selectDistinct(tableName, columns = valueColumnArray, selection = "$idColumnName=?", selectionArgs = arrayOf(k.keyAsString()), limit = FirstPagePagination(1).limitClause()).use {
|
||||
it.count
|
||||
}
|
||||
}.toLong()
|
||||
|
Loading…
Reference in New Issue
Block a user