From 6a10d276f15222fb5cf577fb32076fb86e2638a7 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 18 Oct 2020 17:52:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=98=85=E8=AF=BB=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=8E=92=E5=BA=8F?= 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 | 8 ++++++++ app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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 7e8acb854..dc144493b 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -10,6 +10,7 @@ import io.legado.app.App import io.legado.app.constant.AppConst import io.legado.app.data.dao.* import io.legado.app.data.entities.* +import java.util.* @Database( @@ -46,7 +47,14 @@ abstract class AppDatabase: RoomDatabase() { .build() private val dbCallback = object : Callback() { + + override fun onCreate(db: SupportSQLiteDatabase) { + super.onCreate(db) + db.setLocale(Locale.CHINESE) + } + override fun onOpen(db: SupportSQLiteDatabase) { + db.setLocale(Locale.CHINESE) db.execSQL( """ insert into book_groups(groupId, groupName, 'order', show) select ${AppConst.bookGroupAllId}, '全部', -10, 1 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 index 3e964ea73..9363e2a56 100644 --- a/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt @@ -10,7 +10,7 @@ interface ReadRecordDao { @get:Query("select * from readRecord") val all: List - @get:Query("select bookName, sum(readTime) as readTime from readRecord group by bookName order by bookName") + @get:Query("select bookName, sum(readTime) as readTime from readRecord group by bookName order by bookName collate localized") val allShow: List @get:Query("select sum(readTime) from readRecord")