From 0c0525722ae0e4fc5f831a631c12fb86bb37d01c Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 10 Sep 2021 16:55:40 +0800 Subject: [PATCH] =?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/ui/main/MainViewModel.kt | 2 ++ .../legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt | 7 +++++++ .../app/ui/main/bookshelf/style1/BookshelfFragment1.kt | 5 ----- .../app/ui/main/bookshelf/style2/BookshelfFragment2.kt | 5 ----- app/src/main/res/menu/main_bookshelf.xml | 6 ++++++ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index a42a921c3..d09238e35 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -3,6 +3,7 @@ package io.legado.app.ui.main import android.app.Application import io.legado.app.base.BaseViewModel import io.legado.app.constant.AppConst +import io.legado.app.constant.AppLog import io.legado.app.constant.BookType import io.legado.app.constant.EventBus import io.legado.app.data.appDb @@ -90,6 +91,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) { ) CacheBook.start(context, book.bookUrl, book.durChapterIndex, endIndex) }.onError(upTocPool) { + AppLog.addLog("${book.name} 更新目录失败 error: ${it.localizedMessage}", it) it.printOnDebug() }.onFinally(upTocPool) { synchronized(this) { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt index deaa097c6..dd75f9f9f 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.main.bookshelf import android.annotation.SuppressLint +import android.view.Menu import android.view.MenuItem import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels @@ -13,6 +14,7 @@ import io.legado.app.databinding.DialogBookshelfConfigBinding import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert +import io.legado.app.ui.about.AppLogDialog import io.legado.app.ui.book.arrange.ArrangeBookActivity import io.legado.app.ui.book.cache.CacheActivity import io.legado.app.ui.book.group.GroupManageDialog @@ -51,6 +53,10 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment importBookshelfAlert(groupId) + R.id.menu_log -> AppLogDialog.show(childFragmentManager) } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt index 9f1bc218a..ea279792a 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt @@ -3,7 +3,6 @@ package io.legado.app.ui.main.bookshelf.style1 import android.os.Bundle -import android.view.Menu import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.SearchView @@ -58,10 +57,6 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf), initBookGroupData() } - override fun onCompatCreateOptionsMenu(menu: Menu) { - menuInflater.inflate(R.menu.main_bookshelf, menu) - } - private val selectedGroup: BookGroup get() = bookGroups[tabLayout.selectedTabPosition] diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt index a78178258..cd3dd8076 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt @@ -2,7 +2,6 @@ package io.legado.app.ui.main.bookshelf.style2 import android.annotation.SuppressLint import android.os.Bundle -import android.view.Menu import android.view.View import androidx.appcompat.widget.SearchView import androidx.core.view.isGone @@ -58,10 +57,6 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), initBooksData() } - override fun onCompatCreateOptionsMenu(menu: Menu) { - menuInflater.inflate(R.menu.main_bookshelf, menu) - } - private fun initRecyclerView() { ATH.applyEdgeEffectColor(binding.rvBookshelf) binding.refreshLayout.setColorSchemeColors(accentColor) diff --git a/app/src/main/res/menu/main_bookshelf.xml b/app/src/main/res/menu/main_bookshelf.xml index 78d754fcc..854a657b9 100644 --- a/app/src/main/res/menu/main_bookshelf.xml +++ b/app/src/main/res/menu/main_bookshelf.xml @@ -64,4 +64,10 @@ android:title="@string/import_bookshelf" app:showAsAction="never" /> + + \ No newline at end of file