From e4cf02fca762064e4aa7fd45012f57f819fd8551 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 31 Jul 2021 20:12:16 +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/MainActivity.kt | 5 +++++ .../app/ui/main/bookshelf/style2/BookshelfFragment2.kt | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 6ea3825dd..e2baa8fbd 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -136,6 +136,11 @@ class MainActivity : VMBaseActivity(), binding.viewPagerMain.currentItem = 0 return true } + (fragmentMap[getFragmentId(0)] as? BookshelfFragment2)?.let { + if (it.back()) { + return true + } + } if (System.currentTimeMillis() - exitTime > 2000) { toastOnUi(R.string.double_click_exit) exitTime = System.currentTimeMillis() 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 fc5e34ddd..68d7a4bb4 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 @@ -140,6 +140,15 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), } } + fun back(): Boolean { + if (groupId != AppConst.bookGroupNoneId) { + groupId = AppConst.bookGroupNoneId + initBooksData() + return true + } + return false + } + override fun onQueryTextSubmit(query: String?): Boolean { SearchActivity.start(requireContext(), query) return false