|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package io.legado.app.ui.book.search |
|
|
|
|
|
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.Menu |
|
|
|
|
import android.view.MenuItem |
|
|
|
@ -30,6 +31,7 @@ import kotlinx.coroutines.launch |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
|
import org.jetbrains.anko.startActivityForResult |
|
|
|
|
import java.text.Collator |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -50,6 +52,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
|
private var menu: Menu? = null |
|
|
|
|
private var precisionSearchMenuItem: MenuItem? = null |
|
|
|
|
private var groups = linkedSetOf<String>() |
|
|
|
|
private val searchRequestCode = 69 |
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
|
ll_history.setBackgroundColor(backgroundColor) |
|
|
|
@ -57,7 +60,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
|
initSearchView() |
|
|
|
|
initOtherView() |
|
|
|
|
initLiveData() |
|
|
|
|
initIntent() |
|
|
|
|
receiptIntent(intent) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { |
|
|
|
@ -195,8 +198,13 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initIntent() { |
|
|
|
|
intent.getStringExtra("key")?.let { |
|
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
|
|
|
|
super.onActivityResult(requestCode, resultCode, data) |
|
|
|
|
receiptIntent(data) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun receiptIntent(data: Intent? = null) { |
|
|
|
|
data?.getStringExtra("key")?.let { |
|
|
|
|
search_view.setQuery(it, true) |
|
|
|
|
} ?: let { |
|
|
|
|
search_view.requestFocus() |
|
|
|
@ -313,7 +321,8 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
|
override fun showBookInfo(name: String, author: String) { |
|
|
|
|
viewModel.getSearchBook(name, author) { searchBook -> |
|
|
|
|
searchBook?.let { |
|
|
|
|
startActivity<BookInfoActivity>( |
|
|
|
|
startActivityForResult<BookInfoActivity>( |
|
|
|
|
searchRequestCode, |
|
|
|
|
Pair("name", it.name), |
|
|
|
|
Pair("author", it.author) |
|
|
|
|
) |
|
|
|
@ -325,7 +334,8 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
|
* 显示书籍详情 |
|
|
|
|
*/ |
|
|
|
|
override fun showBookInfo(book: Book) { |
|
|
|
|
startActivity<BookInfoActivity>( |
|
|
|
|
startActivityForResult<BookInfoActivity>( |
|
|
|
|
searchRequestCode, |
|
|
|
|
Pair("name", book.name), |
|
|
|
|
Pair("author", book.author) |
|
|
|
|
) |
|
|
|
|