Load MMS parts lazily, display single image if available

This commit is contained in:
Moez Bhatti
2018-01-08 19:18:27 -05:00
parent 9ae7775052
commit 5c13f9b86e
8 changed files with 141 additions and 13 deletions
@@ -21,6 +21,7 @@ package data.model
import android.content.ContentUris
import android.net.Uri
import android.provider.Telephony.*
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
@@ -73,6 +74,7 @@ open class Message : RealmObject() {
var mmsStatus: Int = 0
var subject: String = ""
var textContentType: String = ""
var parts: RealmList<MmsPart> = RealmList()
fun getUri(): Uri {
val baseUri = if (isMms()) Mms.CONTENT_URI else Sms.CONTENT_URI
+21 -6
View File
@@ -18,11 +18,26 @@
*/
package data.model
import android.net.Uri
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class MmsPart : RealmObject() {
@PrimaryKey var id: Long = 0
var messageId: Long = 0
var type: String = ""
var data: String? = null
var text: String? = null
var image: String? = null
fun isImage()
= "image/jpeg" == type
|| "image/bmp" == type
|| "image/gif" == type
|| "image/jpg" == type
|| "image/png" == type
fun isText() = "text/plain" == type
class MmsPart {
var name = ""
var mimeType = ""
var data: ByteArray? = null
var path: Uri? = null
}