Android

room 에서 @Ignore 사용하는 법

aucd29 2019. 3. 26. 11:08
단순하게 생성자쪽 인자에 넣으면 될줄 알았는데 아니네? 빌드 오류나서 찾아보니
https://github.com/googlesamples/android-architecture-components/issues/421
생성자 밖에 넣으라고 함 +_+)b

@Entity(tableName = "myFavorite")
data class MyFavorite (
    val name: String,
    val url: String     = "",
    val folder: String = "",
    val favType: Int    = T_DEFAULT,
    val date: Long     = System.currentTimeMillis(),
    @PrimaryKey(autoGenerate = true)
    val _id: Int        = 0
) : IRecyclerDiff, IRecyclerItem {
    @Ignore
    var pos: Int = 0


    companion object {
        const val T_DEFAULT = 0
        const val T_FOLDER = 1
    }

    override fun compare(item: IRecyclerDiff) = this._id == (item as MyFavorite)._id
    override fun type() = favType
}