From 0eb6ce8c062f8bb40fe867313c9dede1b30fa47b Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 20:41:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/entities/Book.kt | 6 +++++- .../main/java/io/legado/app/model/localBook/LocalBook.kt | 2 +- .../java/io/legado/app/ui/book/download/DownloadActivity.kt | 2 +- .../java/io/legado/app/ui/book/read/ReadBookActivity.kt | 2 +- 4 files changed, 8 insertions(+), 4 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 2889f1c99..104520ff3 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 @@ -56,10 +56,14 @@ data class Book( return origin == BookType.local } - fun isTxt(): Boolean { + fun isLocalTxt(): Boolean { return isLocalBook() && originName.endsWith(".txt", true) } + fun isOnLineTxt(): Boolean { + return !isLocalBook() && type == 0 + } + override fun equals(other: Any?): Boolean { if (other is Book) { return other.bookUrl == bookUrl diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index c5e7ffab5..9195c87a5 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -47,7 +47,7 @@ object LocalBook { fun deleteBook(book: Book, deleteOriginal: Boolean) { kotlin.runCatching { - if (book.isTxt()) { + if (book.isLocalTxt()) { val bookFile = FileUtils.getFile(AnalyzeTxtFile.cacheFolder, book.originName) bookFile.delete() } diff --git a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt index 6c8d63c26..6889e1052 100644 --- a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt @@ -125,7 +125,7 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow } booksLiveData?.observe(this, Observer { list -> val booksDownload = list.filter { - !it.isLocalBook() && it.isTxt() + it.isOnLineTxt() } val books = when (getPrefInt(PreferKey.bookshelfSort)) { 1 -> booksDownload.sortedByDescending { it.latestChapterTime } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index d5880a728..dcfaa88ee 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -198,7 +198,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo when (item.groupId) { R.id.menu_group_on_line -> item.isVisible = onLine R.id.menu_group_local -> item.isVisible = !onLine - R.id.menu_group_text -> item.isVisible = book.isTxt() + R.id.menu_group_text -> item.isVisible = book.isLocalTxt() R.id.menu_group_login -> item.isVisible = !ReadBook.webBook?.bookSource?.loginUrl.isNullOrEmpty() else -> if (item.itemId == R.id.menu_enable_replace) {