@ -1,7 +1,6 @@
package io.legado.app.ui.search
package io.legado.app.ui.search
import android.os.Bundle
import android.os.Bundle
import android.view.View
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.SearchView
import androidx.lifecycle.LiveData
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.Observer
@ -14,11 +13,13 @@ import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.SearchShow
import io.legado.app.data.entities.SearchShow
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.ui.bookinfo.BookInfoActivity
import io.legado.app.utils.getViewModel
import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_search.*
import kotlinx.android.synthetic.main.activity_search.*
import kotlinx.android.synthetic.main.view_search.*
import kotlinx.android.synthetic.main.view_search.*
import org.jetbrains.anko.startActivity
class SearchActivity : VMBaseActivity < SearchViewModel > ( R . layout . activity _search ) {
class SearchActivity : VMBaseActivity < SearchViewModel > ( R . layout . activity _search ) , SearchAdapter . CallBack {
override val viewModel : SearchViewModel
override val viewModel : SearchViewModel
get ( ) = getViewModel ( SearchViewModel :: class . java )
get ( ) = getViewModel ( SearchViewModel :: class . java )
@ -66,6 +67,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_search)
private fun initRecyclerView ( ) {
private fun initRecyclerView ( ) {
ATH . applyEdgeEffectColor ( rv _search _list )
ATH . applyEdgeEffectColor ( rv _search _list )
adapter = SearchAdapter ( )
adapter = SearchAdapter ( )
adapter . callBack = this
rv _search _list . layoutManager = LinearLayoutManager ( this )
rv _search _list . layoutManager = LinearLayoutManager ( this )
rv _search _list . adapter = adapter
rv _search _list . adapter = adapter
}
}
@ -76,4 +78,11 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_search)
searchBookData ?. observe ( this , Observer { adapter . submitList ( it ) } )
searchBookData ?. observe ( this , Observer { adapter . submitList ( it ) } )
}
}
override fun showBookInfo ( name : String , author : String ? ) {
viewModel . getSearchBook ( name , author ) { searchBook ->
searchBook ?. let {
startActivity < BookInfoActivity > ( Pair ( " searchBookUrl " , it . bookUrl ) )
}
}
}
}
}