Add logging for unread thread ids.

This commit is contained in:
Alex Hart
2022-07-18 10:18:54 -03:00
committed by Cody Henthorne
parent 359a39ddaf
commit e69d944f11
4 changed files with 43 additions and 12 deletions

View File

@@ -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;
}
}
}

View File

@@ -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 ->