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