Fixed showing all drafts (#537)

This commit is contained in:
Agnieszka C 2022-12-30 11:55:05 +01:00
parent bf85cd147d
commit 06436ccf58
1 changed files with 8 additions and 5 deletions

View File

@ -789,11 +789,14 @@ fun Context.getAllDrafts(): HashMap<Long, String?> {
val projection = arrayOf(Sms.BODY, Sms.THREAD_ID) val projection = arrayOf(Sms.BODY, Sms.THREAD_ID)
try { try {
queryCursor(uri, projection) { cursor -> val cursor = contentResolver.query(uri, projection, null, null, null)
cursor.use { cursor?.use {
val threadId = cursor.getLongValue(Sms.THREAD_ID) while (it.moveToNext()) {
val draft = cursor.getStringValue(Sms.BODY) ?: return@queryCursor val threadId = it.getLongValue(Sms.THREAD_ID)
drafts[threadId] = draft val draft = it.getStringValue(Sms.BODY)
if (draft != null) {
drafts[threadId] = draft
}
} }
} }
} catch (e: Exception) { } catch (e: Exception) {