cloudroam
2 天以前 9755d9eefb12f95fa45c785e526038e10c9c7115
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.example.firstapp.database.entity
 
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import com.example.firstapp.R
import kotlinx.parcelize.Parcelize
import java.util.Date
 
@Parcelize
@Entity(
    tableName = "Msg",
    indices = [
        Index(value = ["id"], unique = true)
    ]
)
data class Msg(
    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id") var id: Long,
    @ColumnInfo(name = "type", defaultValue = "sms") var type: String,
    @ColumnInfo(name = "from", defaultValue = "") var from: String,
    @ColumnInfo(name = "content", defaultValue = "") var content: String,
    @ColumnInfo(name = "sim_slot", defaultValue = "-1") var simSlot: Int = -1, //卡槽id:-1=获取失败、0=卡槽1、1=卡槽2
    @ColumnInfo(name = "sim_info", defaultValue = "") var simInfo: String = "",
    @ColumnInfo(name = "sub_id", defaultValue = "0") var subId: Int = 0,
    //通话类型:1.来电挂机 2.去电挂机 3.未接来电 4.来电提醒 5.来电接通 6.去电拨出
    @ColumnInfo(name = "call_type", defaultValue = "0") var callType: Int = 0,
    @ColumnInfo(name = "time") var time: Date = Date(),
    @ColumnInfo(name = "sms_timestamp", defaultValue = "0") var smsTimestamp: Long = 0,
) : Parcelable {
 
    val simImageId: Int
        get() {
            return when {
                type == "app" -> R.drawable.ic_app
                simSlot == 0 -> R.drawable.ic_sim1
                simSlot == 1 -> R.drawable.ic_sim2
                simInfo.isNotEmpty() && simInfo.replace("-", "").startsWith("SIM2") -> R.drawable.ic_sim2
                simInfo.isNotEmpty() && simInfo.replace("-", "").startsWith("SIM1") -> R.drawable.ic_sim1
                else -> R.drawable.ic_sim
            }
        }
 
}