mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Ensure that pinned_order is unique.
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user