From c08a526ca860e7ef43a3c6868b8ae2208a261aa0 Mon Sep 17 00:00:00 2001 From: atbest Date: Thu, 23 May 2019 01:36:35 -0400 Subject: [PATCH] Updated entities --- .../java/io/legado/app/data/entities/Book.kt | 13 ++++++------- .../io/legado/app/data/entities/Chapter.kt | 6 +++--- .../legado/app/data/entities/ReplaceRule.kt | 19 ++++++++++--------- .../io/legado/app/data/entities/Source.kt | 8 +++++--- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index d9879a223..e207f8c03 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -19,15 +19,14 @@ data class Book(@PrimaryKey var type: Int = 0, // 0: 文本读物, 1: 有声读物 var group: Int = 0, // 自定义分组索引号 var tocUrl: String = "", // 目录页Url (toc=table of Contents) - var latestChapterName: String? = null, // 最新章节 - var lastCheckTime: Long? = null, // 最近一次更新书籍信息的时间 - var hasNewChapter: Boolean = false, // 最近一次更新书籍信息时是否发现新章节 - var latestChapterTime: Long? = null, // 最近一次发现新章节的时间 - var latestCheckCount: Int = 0, // 最近一次发现新章节的数量 + var latestChapterTitle: String? = null, // 最新章节标题 + var latestChapterTime: Long = 0, // 最新章节标题更新时间 + var lastCheckTime: Long = 0, // 最近一次更新书籍信息的时间 + var lastCheckCount: Int = 0, // 最近一次发现新章节的数量 var totalChapterNum: Int = 0, // 书籍目录总数 - var durChapterName: String = "", // 当前章节名称 + var durChapterTitle: String = "", // 当前章节名称 var durChapterIndex: Int = 0, // 当前章节索引 - var durChapterMark: Int = 0, // 当前阅读的进度(首行字符的索引位置) + var durChapterPos: Int = 0, // 当前阅读的进度(首行字符的索引位置) var durChapterTime: Long = 0, // 最近一次阅读书籍的时间(打开正文的时间) var canUpdate: Boolean = true, // 刷新书架时更新书籍信息 var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息) diff --git a/app/src/main/java/io/legado/app/data/entities/Chapter.kt b/app/src/main/java/io/legado/app/data/entities/Chapter.kt index fa359a582..724ae6258 100644 --- a/app/src/main/java/io/legado/app/data/entities/Chapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/Chapter.kt @@ -17,12 +17,12 @@ import kotlinx.android.parcel.Parcelize onDelete = ForeignKey.CASCADE))]) // 删除书籍时自动删除章节 data class Chapter(@PrimaryKey var url: String = "", // 章节地址 - var name: String = "", // 章节标题 + var title: String = "", // 章节标题 var bookUrl: String = "", // 书籍地址 var index: Int = 0, // 章节序号 var resourceUrl: String? = null, // 音频真实URL var tag: String? = null, // - var start: Long? = null, // 章节起始地址 - var end: Long? = null // 章节终止地址 + var start: Long? = null, // 章节起始位置 + var end: Long? = null // 章节终止位置 ) : Parcelable diff --git a/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt index 9c6d6b5b6..fdfa41d3f 100644 --- a/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt @@ -9,15 +9,16 @@ import kotlinx.android.parcel.Parcelize @Parcelize @Entity(tableName = "replace_rules", indices = [(Index(value = ["id"]))]) -data class ReplaceRule(@PrimaryKey - val id: Int = 0, - val summary: String? = null, - val pattern: String? = null, - val replacement: String? = null, - val scope: String? = null, - val isEnabled: Boolean? = null, - val isRegex: Boolean? = null, - val order: Int = 0 +data class ReplaceRule( + @PrimaryKey(autoGenerate = true) + val id: Int = 0, + val summary: String? = null, + val pattern: String? = null, + val replacement: String? = null, + val scope: String? = null, + val isEnabled: Boolean? = null, + val isRegex: Boolean? = null, + val order: Int = 0 ) : Parcelable diff --git a/app/src/main/java/io/legado/app/data/entities/Source.kt b/app/src/main/java/io/legado/app/data/entities/Source.kt index 5bac00ac0..1c6cfcf18 100644 --- a/app/src/main/java/io/legado/app/data/entities/Source.kt +++ b/app/src/main/java/io/legado/app/data/entities/Source.kt @@ -1,6 +1,7 @@ package io.legado.app.data.entities import android.os.Parcelable +import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.Index import androidx.room.PrimaryKey @@ -8,11 +9,12 @@ import kotlinx.android.parcel.Parcelize @Parcelize @Entity(tableName = "sources", - indices = [(Index(value = ["id"]))]) -data class Source(@PrimaryKey + indices = [(Index(value = ["sourceId"]))]) +data class Source(@PrimaryKey(autoGenerate = true) + @ColumnInfo(name = "sourceId") var id: Int = 0, // 编号 - var host: String = "", // 地址,包括 http/https var name: String = "", // 名称 + var origin: String = "", // 地址,包括 http/https var type: Int = 0, // 类型,0 文本,1 音频 var group: String? = null, // 分组 var header: String? = null, // header