mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 21:58:53 +01:00
Add conversations to Realm as they're read from ContentProvider
This commit is contained in:
@@ -34,25 +34,23 @@ internal object SyncManager {
|
|||||||
|
|
||||||
fun dumpColumns(context: Context) {
|
fun dumpColumns(context: Context) {
|
||||||
|
|
||||||
val conversations = ArrayList<Conversation>()
|
|
||||||
val cursor = context.contentResolver.query(CONVERSATIONS_CONTENT_PROVIDER, ALL_THREADS_PROJECTION, null, null, "date desc")
|
val cursor = context.contentResolver.query(CONVERSATIONS_CONTENT_PROVIDER, ALL_THREADS_PROJECTION, null, null, "date desc")
|
||||||
|
|
||||||
while (cursor.moveToNext()) conversations.add(Conversation(
|
Realm.getDefaultInstance().executeTransaction {
|
||||||
cursor.getLong(ID),
|
while (cursor.moveToNext())
|
||||||
cursor.getLong(DATE),
|
it.insertOrUpdate(Conversation(
|
||||||
cursor.getInt(MESSAGE_COUNT),
|
cursor.getLong(ID),
|
||||||
cursor.getInt(RECIPIENT_IDS),
|
cursor.getLong(DATE),
|
||||||
cursor.getString(SNIPPET) ?: "",
|
cursor.getInt(MESSAGE_COUNT),
|
||||||
cursor.getString(SNIPPET_CS) ?: "",
|
cursor.getInt(RECIPIENT_IDS),
|
||||||
cursor.getInt(READ),
|
cursor.getString(SNIPPET) ?: "",
|
||||||
cursor.getInt(ERROR),
|
cursor.getString(SNIPPET_CS) ?: "",
|
||||||
cursor.getInt(HAS_ATTACHMENT)))
|
cursor.getInt(READ),
|
||||||
|
cursor.getInt(ERROR),
|
||||||
|
cursor.getInt(HAS_ATTACHMENT)))
|
||||||
|
}
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
Realm.getDefaultInstance().executeTransaction {
|
|
||||||
it.insert(conversations)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user