From bcb4a0cb8d300d9e19f348e60c59856404516ae1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 21 Aug 2020 09:49:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/entities/ReadRecord.kt | 4 ++++ build.gradle | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/io/legado/app/data/entities/ReadRecord.kt diff --git a/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt new file mode 100644 index 000000000..6daee53f8 --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt @@ -0,0 +1,4 @@ +package io.legado.app.data.entities + +class ReadRecord { +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index f2d22610f..b9930dac3 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { repositories { google() jcenter() - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - maven { url 'http://s3.amazonaws.com/fabric-artifacts/public' } + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://s3.amazonaws.com/fabric-artifacts/public' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } maven { url 'https://maven.fabric.io/public' } maven { url 'https://plugins.gradle.org/m2/' } @@ -24,7 +24,7 @@ allprojects { repositories { google() jcenter() - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } maven { url "https://jitpack.io" } maven { url 'https://maven.google.com/' } maven { url 'https://github.com/psiegman/mvn-repo/raw/master/releases' } From c19057c52faf9d419de8adc5955e9e3c548c96d8 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 21 Aug 2020 10:09:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=85=E8=AF=BB?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/AppDatabase.kt | 4 ++-- .../java/io/legado/app/data/entities/ReadRecord.kt | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index 3e50aab3a..08b2265f5 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -18,8 +18,8 @@ import kotlinx.coroutines.launch entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class, ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, - RssStar::class, TxtTocRule::class], - version = 15, + RssStar::class, TxtTocRule::class, ReadRecord::class], + version = 16, exportSchema = true ) abstract class AppDatabase : RoomDatabase() { diff --git a/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt index 6daee53f8..cf16a08ab 100644 --- a/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt +++ b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt @@ -1,4 +1,11 @@ package io.legado.app.data.entities -class ReadRecord { -} \ No newline at end of file +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity +data class ReadRecord( + @PrimaryKey + val bookName: String = "", + val readTime: Long = 0L +) \ No newline at end of file From ff13fb6a69a8385b9c99ed8daa250cbf12dc1c6e Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 21 Aug 2020 14:02:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=85=E8=AF=BB?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/AppDatabase.kt | 2 +- .../io/legado/app/data/dao/ReadRecordDao.kt | 19 +++++++++++++++++++ .../io/legado/app/data/entities/ReadRecord.kt | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index 08b2265f5..f5d8d0927 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -19,7 +19,7 @@ import kotlinx.coroutines.launch ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, RssStar::class, TxtTocRule::class, ReadRecord::class], - version = 16, + version = 17, exportSchema = true ) abstract class AppDatabase : RoomDatabase() { diff --git a/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt b/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt new file mode 100644 index 000000000..0e1d2672e --- /dev/null +++ b/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt @@ -0,0 +1,19 @@ +package io.legado.app.data.dao + +import androidx.room.* +import io.legado.app.data.entities.ReadRecord + +@Dao +interface ReadRecordDao { + + @get:Query("select * from readRecord") + val all: List + + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg readRecord: ReadRecord) + + @Update + fun update(vararg record: ReadRecord) + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt index cf16a08ab..72e2bb0b2 100644 --- a/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt +++ b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt @@ -3,7 +3,7 @@ package io.legado.app.data.entities import androidx.room.Entity import androidx.room.PrimaryKey -@Entity +@Entity(tableName = "readRecord") data class ReadRecord( @PrimaryKey val bookName: String = "",