Added room database and book entity

This commit is contained in:
atbest 2019-05-22 06:09:40 -04:00
parent 53424f69a0
commit b40f9de603
2 changed files with 39 additions and 0 deletions

View File

@ -34,6 +34,12 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
implementation 'androidx.room:room-runtime:2.0.0'
kapt 'androidx.room:room-compiler:2.0.0'
implementation 'androidx.paging:paging-runtime:2.1.0'
def anko_version = '0.10.8'

View File

@ -0,0 +1,33 @@
package io.legado.app.data.entities
import android.os.Parcelable
import androidx.room.*
import kotlinx.android.parcel.Parcelize
import java.util.*
@Parcelize
@Entity(tableName = "books",
indices = [(Index(value = ["url"]))])
data class Book(@PrimaryKey
var url: String = "",
var name: String = "",
var tag: String = "",
var author: String? = null,
var coverUrl: String? = null,
var customCoverUrl: String? = null,
var introduction: String? = null,
var charset: String? = null,
var type: Int = 0, // 0: text, 1: audio
var latestChapterName: String? = null,
var lastUpdateTime: Date? = null,
var latestChapterTime: Date? = null,
var durChapterIndex: Int = 0,
var durChapterPage: Int = 0,
var totalChapterNum: Int = 0,
var hasNewChapter: Boolean = false,
var allowUpdate: Boolean = true
) : Parcelable {
fun getUnreadChapterNum() = Math.max(totalChapterNum - durChapterIndex - 1, 0)
}