mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-19 12:28:53 +01:00
sync all db data from single call, organize sync-related classes
This commit is contained in:
@@ -1,18 +1,35 @@
|
||||
package com.moez.QKSMS.model
|
||||
|
||||
import android.database.Cursor
|
||||
import com.moez.QKSMS.data.sync.ConversationColumns
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Conversation(
|
||||
open class Conversation() : RealmObject() {
|
||||
|
||||
@PrimaryKey var id: Long = 0,
|
||||
var date: Long = 0,
|
||||
var messageCount: Int = 0,
|
||||
var recipientIds: Int = 0,
|
||||
var snippet: String = "",
|
||||
var snippetCs: String = "",
|
||||
var read: Int = 0,
|
||||
var error: Int = 0,
|
||||
var hasAttachment: Int = 0
|
||||
@PrimaryKey var id: Long = 0
|
||||
var date: Long = 0
|
||||
var messageCount: Int = 0
|
||||
var recipientIds: Int = 0
|
||||
var snippet: String = ""
|
||||
var snippetCs: String = ""
|
||||
var read: Int = 0
|
||||
var error: Int = 0
|
||||
var hasAttachment: Int = 0
|
||||
|
||||
) : RealmObject()
|
||||
/**
|
||||
* Instantiates a Conversation from the Android SMS ContentProvider
|
||||
*/
|
||||
constructor(cursor: Cursor) : this() {
|
||||
id = cursor.getLong(ConversationColumns.ID)
|
||||
date = cursor.getLong(ConversationColumns.DATE)
|
||||
messageCount = cursor.getInt(ConversationColumns.MESSAGE_COUNT)
|
||||
recipientIds = cursor.getInt(ConversationColumns.RECIPIENT_IDS)
|
||||
snippet = cursor.getString(ConversationColumns.SNIPPET) ?: ""
|
||||
snippetCs = cursor.getString(ConversationColumns.SNIPPET_CS) ?: ""
|
||||
read = cursor.getInt(ConversationColumns.READ)
|
||||
error = cursor.getInt(ConversationColumns.ERROR)
|
||||
hasAttachment = cursor.getInt(ConversationColumns.HAS_ATTACHMENT)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,38 @@
|
||||
package com.moez.QKSMS.model
|
||||
|
||||
import android.database.Cursor
|
||||
import android.provider.Telephony
|
||||
import android.provider.Telephony.Mms
|
||||
import android.provider.Telephony.Sms
|
||||
import com.moez.QKSMS.data.sync.MessageColumns
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Message(
|
||||
open class Message() : RealmObject() {
|
||||
|
||||
@PrimaryKey var id: Long = 0,
|
||||
var threadId: Long = 0,
|
||||
var boxId: Int = 0,
|
||||
var type: String = "",
|
||||
var body: String = "",
|
||||
var errorType: Int = 0
|
||||
@PrimaryKey var id: Long = 0
|
||||
var threadId: Long = 0
|
||||
var boxId: Int = 0
|
||||
var type: String = ""
|
||||
var body: String = ""
|
||||
var errorType: Int = 0
|
||||
|
||||
) : RealmObject() {
|
||||
constructor(threadId: Long, cursor: Cursor, columnsMap: MessageColumns) : this() {
|
||||
this.threadId = threadId
|
||||
|
||||
id = cursor.getLong(columnsMap.msgId)
|
||||
type = cursor.getString(columnsMap.msgType)
|
||||
|
||||
val isMms = type == "mms"
|
||||
body = cursor.getString(columnsMap.smsBody) ?: ""
|
||||
errorType = cursor.getInt(columnsMap.mmsErrorType)
|
||||
|
||||
if (isMms) {
|
||||
boxId = cursor.getInt(columnsMap.mmsMessageBox)
|
||||
} else {
|
||||
boxId = cursor.getInt(columnsMap.smsType)
|
||||
}
|
||||
}
|
||||
|
||||
fun isMms(): Boolean = type == "mms"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user