feat: 优化代码

pull/133/head
kunfei 5 years ago
parent e0f9525fc0
commit bc642e6979
  1. 1
      app/src/main/java/io/legado/app/constant/EventBus.kt
  2. 8
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  3. 9
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt

@ -20,6 +20,5 @@ object EventBus {
const val SHOW_RSS = "showRss"
const val WEB_SERVICE_STOP = "webServiceStop"
const val UP_DOWNLOAD = "upDownload"
const val UP_TABS = "upTabs"
const val SAVE_CONTENT = "saveContent"
}

@ -15,7 +15,6 @@ import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.BookGroup
import io.legado.app.lib.dialogs.alert
@ -25,10 +24,10 @@ import io.legado.app.lib.dialogs.okButton
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.book.arrange.ArrangeBookActivity
import io.legado.app.ui.book.group.GroupManageDialog
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.book.download.DownloadActivity
import io.legado.app.ui.book.group.GroupManageDialog
import io.legado.app.ui.book.local.ImportBookActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.dialog_bookshelf_config.view.*
@ -99,9 +98,6 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
TabLayoutMediator(tab_layout, view_pager_bookshelf) { tab, position ->
tab.text = bookGroups[position].groupName
}.attach()
observeEvent<Int>(EventBus.UP_TABS) {
tab_layout.getTabAt(it)?.select()
}
}
private fun initBookGroupData() {

@ -57,9 +57,6 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
}
initRecyclerView()
upRecyclerData()
observeEvent<String>(EventBus.UP_BOOK) {
booksAdapter.notification(it)
}
}
private fun initRecyclerView() {
@ -135,4 +132,10 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
return bookUrl in activityViewModel.updateList
}
override fun observeLiveBus() {
super.observeLiveBus()
observeEvent<String>(EventBus.UP_BOOK) {
booksAdapter.notification(it)
}
}
}
Loading…
Cancel
Save