|
|
@ -6,8 +6,6 @@ import android.view.MenuItem |
|
|
|
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 |
|
|
|
import androidx.paging.LivePagedListBuilder |
|
|
|
|
|
|
|
import androidx.paging.PagedList |
|
|
|
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
@ -15,7 +13,6 @@ import io.legado.app.R |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.SearchKeyword |
|
|
|
import io.legado.app.data.entities.SearchKeyword |
|
|
|
import io.legado.app.data.entities.SearchShow |
|
|
|
|
|
|
|
import io.legado.app.help.IntentDataHelp |
|
|
|
import io.legado.app.help.IntentDataHelp |
|
|
|
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 |
|
|
@ -32,6 +29,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
|
|
|
|
|
|
|
|
class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_search), |
|
|
|
class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_search), |
|
|
|
|
|
|
|
SearchViewModel.CallBack, |
|
|
|
BookAdapter.CallBack, |
|
|
|
BookAdapter.CallBack, |
|
|
|
HistoryKeyAdapter.CallBack, |
|
|
|
HistoryKeyAdapter.CallBack, |
|
|
|
SearchAdapter.CallBack { |
|
|
|
SearchAdapter.CallBack { |
|
|
@ -43,7 +41,6 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
private lateinit var bookAdapter: BookAdapter |
|
|
|
private lateinit var bookAdapter: BookAdapter |
|
|
|
private lateinit var historyKeyAdapter: HistoryKeyAdapter |
|
|
|
private lateinit var historyKeyAdapter: HistoryKeyAdapter |
|
|
|
private lateinit var loadMoreView: LoadMoreView |
|
|
|
private lateinit var loadMoreView: LoadMoreView |
|
|
|
private var searchBookData: LiveData<PagedList<SearchShow>>? = null |
|
|
|
|
|
|
|
private var historyData: LiveData<List<SearchKeyword>>? = null |
|
|
|
private var historyData: LiveData<List<SearchKeyword>>? = null |
|
|
|
private var bookData: LiveData<List<Book>>? = null |
|
|
|
private var bookData: LiveData<List<Book>>? = null |
|
|
|
private var menu: Menu? = null |
|
|
|
private var menu: Menu? = null |
|
|
@ -51,6 +48,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
private var groups = hashSetOf<String>() |
|
|
|
private var groups = hashSetOf<String>() |
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
|
|
|
|
viewModel.callBack = this |
|
|
|
initRecyclerView() |
|
|
|
initRecyclerView() |
|
|
|
initSearchView() |
|
|
|
initSearchView() |
|
|
|
initOtherView() |
|
|
|
initOtherView() |
|
|
@ -150,16 +148,6 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
private fun initData() { |
|
|
|
searchBookData?.removeObservers(this) |
|
|
|
|
|
|
|
searchBookData = LivePagedListBuilder( |
|
|
|
|
|
|
|
App.db.searchBookDao().observeShow( |
|
|
|
|
|
|
|
viewModel.searchKey, |
|
|
|
|
|
|
|
viewModel.startTime |
|
|
|
|
|
|
|
), 30 |
|
|
|
|
|
|
|
).build() |
|
|
|
|
|
|
|
searchBookData?.observe(this, Observer { |
|
|
|
|
|
|
|
//ToDo |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
App.db.bookSourceDao().liveGroupEnabled().observe(this, Observer { |
|
|
|
App.db.bookSourceDao().liveGroupEnabled().observe(this, Observer { |
|
|
|
groups.clear() |
|
|
|
groups.clear() |
|
|
|
it.map { group -> |
|
|
|
it.map { group -> |
|
|
|