pull/1319/head
gedoor 3 years ago
parent a006d667f5
commit 0c0525722a
  1. 2
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
  2. 7
      app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
  3. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt
  4. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
  5. 6
      app/src/main/res/menu/main_bookshelf.xml

@ -3,6 +3,7 @@ package io.legado.app.ui.main
import android.app.Application import android.app.Application
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.AppLog
import io.legado.app.constant.BookType import io.legado.app.constant.BookType
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.data.appDb import io.legado.app.data.appDb
@ -90,6 +91,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
) )
CacheBook.start(context, book.bookUrl, book.durChapterIndex, endIndex) CacheBook.start(context, book.bookUrl, book.durChapterIndex, endIndex)
}.onError(upTocPool) { }.onError(upTocPool) {
AppLog.addLog("${book.name} 更新目录失败 error: ${it.localizedMessage}", it)
it.printOnDebug() it.printOnDebug()
}.onFinally(upTocPool) { }.onFinally(upTocPool) {
synchronized(this) { synchronized(this) {

@ -1,6 +1,7 @@
package io.legado.app.ui.main.bookshelf package io.legado.app.ui.main.bookshelf
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels 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.databinding.DialogEditTextBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert 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.arrange.ArrangeBookActivity
import io.legado.app.ui.book.cache.CacheActivity import io.legado.app.ui.book.cache.CacheActivity
import io.legado.app.ui.book.group.GroupManageDialog import io.legado.app.ui.book.group.GroupManageDialog
@ -51,6 +53,10 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
abstract fun gotoTop() abstract fun gotoTop()
override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.main_bookshelf, menu)
}
override fun onCompatOptionsItemSelected(item: MenuItem) { override fun onCompatOptionsItemSelected(item: MenuItem) {
super.onCompatOptionsItemSelected(item) super.onCompatOptionsItemSelected(item)
when (item.itemId) { when (item.itemId) {
@ -78,6 +84,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
} }
} }
R.id.menu_import_bookshelf -> importBookshelfAlert(groupId) R.id.menu_import_bookshelf -> importBookshelfAlert(groupId)
R.id.menu_log -> AppLogDialog.show(childFragmentManager)
} }
} }

@ -3,7 +3,6 @@
package io.legado.app.ui.main.bookshelf.style1 package io.legado.app.ui.main.bookshelf.style1
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
@ -58,10 +57,6 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf),
initBookGroupData() initBookGroupData()
} }
override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.main_bookshelf, menu)
}
private val selectedGroup: BookGroup private val selectedGroup: BookGroup
get() = bookGroups[tabLayout.selectedTabPosition] get() = bookGroups[tabLayout.selectedTabPosition]

@ -2,7 +2,6 @@ package io.legado.app.ui.main.bookshelf.style2
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.View import android.view.View
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.core.view.isGone import androidx.core.view.isGone
@ -58,10 +57,6 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
initBooksData() initBooksData()
} }
override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.main_bookshelf, menu)
}
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.rvBookshelf) ATH.applyEdgeEffectColor(binding.rvBookshelf)
binding.refreshLayout.setColorSchemeColors(accentColor) binding.refreshLayout.setColorSchemeColors(accentColor)

@ -64,4 +64,10 @@
android:title="@string/import_bookshelf" android:title="@string/import_bookshelf"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_log"
android:icon="@drawable/ic_cfg_about"
android:title="@string/log"
app:showAsAction="never" />
</menu> </menu>
Loading…
Cancel
Save