Inline extension functions that only had one caller
@@ -79,12 +79,12 @@ class K9BackendFolder(
localFolder.destroyMessages(localMessages)
}
- override fun getMoreMessages(): BackendFolder.MoreMessages {
+ override fun getMoreMessages(): MoreMessages {
val moreMessages = database.getString(column = "more_messages") ?: "unknown"
return moreMessages.toMoreMessages()
}
- override fun setMoreMessages(moreMessages: BackendFolder.MoreMessages) {
+ override fun setMoreMessages(moreMessages: MoreMessages) {
database.setString(column = "more_messages", value = moreMessages.toDatabaseValue())
}
@@ -244,12 +244,23 @@ class K9BackendFolder(
}
override fun getFolderExtraString(name: String): String? {
- return database.getStringOrNull(
- table = "folder_extra_values",
- column = "value_text",
- selection = "name = ? AND folder_id = ?",
- selectionArgs = *arrayOf(name, databaseId)
+ return database.execute(false) { db ->
+ val cursor = db.query(
+ "folder_extra_values",
+ arrayOf("value_text"),
+ "name = ? AND folder_id = ?",
+ arrayOf(name, databaseId),
+ null, null, null
)
+
+ cursor.use {
+ if (it.moveToFirst()) {
+ it.getStringOrNull(0)
+ } else {
+ null
+ }
+ }
+ }
}
override fun setFolderExtraString(name: String, value: String) {
@@ -264,12 +275,23 @@ class K9BackendFolder(
}
override fun getFolderExtraNumber(name: String): Long? {
- return database.getLongOrNull(
- table = "folder_extra_values",
- column = "value_integer",
- selection = "name = ? AND folder_id = ?",
- selectionArgs = *arrayOf(name, databaseId)
+ return database.execute(false) { db ->
+ val cursor = db.query(
+ "folder_extra_values",
+ arrayOf("value_integer"),
+ "name = ? AND folder_id = ?",
+ arrayOf(name, databaseId),
+ null, null, null
)
+
+ cursor.use {
+ if (it.moveToFirst()) {
+ it.getLongOrNull(0)
+ } else {
+ null
+ }
+ }
+ }
}
override fun setFolderExtraNumber(name: String, value: Long) {
@@ -301,24 +323,6 @@ class K9BackendFolder(
}
}
- private fun LockableDatabase.getStringOrNull(
- table: String = "folders",
- column: String,
- selection: String = "id = ?",
- vararg selectionArgs: String = arrayOf(databaseId)
- ): String? {
- return execute(false) { db ->
- val cursor = db.query(table, arrayOf(column), selection, selectionArgs, null, null, null)
- cursor.use {
- if (it.moveToFirst()) {
- it.getStringOrNull(0)
- } else {
- null
- }
- }
- }
- }
-
private fun LockableDatabase.setString(
table: String = "folders",
column: String,
@@ -347,24 +351,6 @@ class K9BackendFolder(
}
}
- private fun LockableDatabase.getLongOrNull(
- table: String = "folders",
- column: String,
- selection: String = "id = ?",
- vararg selectionArgs: String = arrayOf(databaseId)
- ): Long? {
- return execute(false) { db ->
- val cursor = db.query(table, arrayOf(column), selection, selectionArgs, null, null, null)
- cursor.use {
- if (it.moveToFirst()) {
- it.getLongOrNull(0)
- } else {
- null
- }
- }
- }
- }
-
private fun LockableDatabase.setLong(
table: String = "folders",
column: String,
