mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-24 19:56:00 +00:00
Add logging for unread thread ids.
This commit is contained in:
committed by
Cody Henthorne
parent
359a39ddaf
commit
e69d944f11
@@ -3,8 +3,10 @@ package org.signal.core.util;
|
||||
import android.database.Cursor;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public final class CursorUtil {
|
||||
@@ -94,4 +96,12 @@ public final class CursorUtil {
|
||||
|
||||
return row.toString();
|
||||
}
|
||||
|
||||
public static @Nullable <T> T getAggregateOrDefault(@NonNull Cursor cursor, @Nullable T defaultValue, @NonNull Function<Integer, T> cursorColumnFn) {
|
||||
if (cursor.moveToFirst()) {
|
||||
return cursorColumnFn.apply(0);
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ object SqlUtil {
|
||||
/** The maximum number of arguments (i.e. question marks) allowed in a SQL statement. */
|
||||
private const val MAX_QUERY_ARGS = 999
|
||||
|
||||
@JvmField
|
||||
val COUNT = arrayOf("COUNT(*)")
|
||||
|
||||
@JvmStatic
|
||||
fun tableExists(db: SupportSQLiteDatabase, table: String): Boolean {
|
||||
db.query("SELECT name FROM sqlite_master WHERE type=? AND name=?", arrayOf("table", table)).use { cursor ->
|
||||
|
||||
Reference in New Issue
Block a user