feat: 下载界面添加分组

pull/248/head 3.20.061820
gedoor 4 years ago
parent 2d27682660
commit 0eb6ce8c06
  1. 6
      app/src/main/java/io/legado/app/data/entities/Book.kt
  2. 2
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.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

@ -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()
}

@ -125,7 +125,7 @@ class DownloadActivity : VMBaseActivity<DownloadViewModel>(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 }

@ -198,7 +198,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(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) {

Loading…
Cancel
Save