Merge pull request #416 from KKL369/master

push
pull/441/head
kunfei 4 years ago committed by GitHub
commit d44eca2927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt

@ -1,5 +1,6 @@
package io.legado.app.ui.book.search package io.legado.app.ui.book.search
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
@ -57,7 +58,12 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
initSearchView() initSearchView()
initOtherView() initOtherView()
initLiveData() initLiveData()
initIntent() receiptIntent(intent)
}
override fun onNewIntent(data: Intent?) {
super.onNewIntent(data)
receiptIntent(data)
} }
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
@ -195,8 +201,8 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
}) })
} }
private fun initIntent() { private fun receiptIntent(intent: Intent? = null) {
intent.getStringExtra("key")?.let { intent?.getStringExtra("key")?.let {
search_view.setQuery(it, true) search_view.setQuery(it, true)
} ?: let { } ?: let {
search_view.requestFocus() search_view.requestFocus()

@ -23,9 +23,7 @@ import io.legado.app.ui.audio.AudioPlayActivity
import io.legado.app.ui.book.info.BookInfoActivity import io.legado.app.ui.book.info.BookInfoActivity
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.main.MainViewModel
import io.legado.app.utils.getPrefInt import io.legado.app.utils.*
import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.observeEvent
import kotlinx.android.synthetic.main.fragment_books.* import kotlinx.android.synthetic.main.fragment_books.*
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import kotlin.math.max import kotlin.math.max
@ -142,7 +140,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
} }
override fun openBookInfo(book: Book) { override fun openBookInfo(book: Book) {
context?.startActivity<BookInfoActivity>( startActivity<BookInfoActivity>(
Pair("name", book.name), Pair("name", book.name),
Pair("author", book.author) Pair("author", book.author)
) )

Loading…
Cancel
Save