Ensure that pinned_order is unique.

This commit is contained in:
Greyson Parrelli
2025-02-21 16:07:10 -05:00
committed by GitHub
parent 46e303ffca
commit 464ffbabdb
8 changed files with 223 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
package org.signal.core.util
import android.database.Cursor
import androidx.core.database.getIntOrNull
import androidx.core.database.getLongOrNull
import androidx.core.database.getStringOrNull
import java.util.Optional
@@ -21,6 +22,10 @@ fun Cursor.requireInt(column: String): Int {
return CursorUtil.requireInt(this, column)
}
fun Cursor.requireIntOrNull(column: String): Int? {
return this.getIntOrNull(this.getColumnIndexOrThrow(column))
}
fun Cursor.optionalInt(column: String): Optional<Int> {
return CursorUtil.getInt(this, column)
}
@@ -123,6 +128,16 @@ fun Cursor.readToSingleInt(defaultValue: Int = 0): Int {
}
}
fun Cursor.readToSingleIntOrNull(): Int? {
return use {
if (it.moveToFirst()) {
it.getIntOrNull(0)
} else {
null
}
}
}
fun Cursor.readToSingleBoolean(defaultValue: Boolean = false): Boolean {
return use {
if (it.moveToFirst()) {