diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index f64daa72f..b0c1efba9 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -6,8 +6,6 @@ import android.view.MenuItem import androidx.appcompat.widget.SearchView import androidx.lifecycle.LiveData import androidx.lifecycle.Observer -import androidx.paging.LivePagedListBuilder -import androidx.paging.PagedList import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.App @@ -15,7 +13,6 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchKeyword -import io.legado.app.data.entities.SearchShow import io.legado.app.help.IntentDataHelp import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor @@ -32,6 +29,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.startActivity class SearchActivity : VMBaseActivity(R.layout.activity_book_search), + SearchViewModel.CallBack, BookAdapter.CallBack, HistoryKeyAdapter.CallBack, SearchAdapter.CallBack { @@ -43,7 +41,6 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se private lateinit var bookAdapter: BookAdapter private lateinit var historyKeyAdapter: HistoryKeyAdapter private lateinit var loadMoreView: LoadMoreView - private var searchBookData: LiveData>? = null private var historyData: LiveData>? = null private var bookData: LiveData>? = null private var menu: Menu? = null @@ -51,6 +48,7 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se private var groups = hashSetOf() override fun onActivityCreated(savedInstanceState: Bundle?) { + viewModel.callBack = this initRecyclerView() initSearchView() initOtherView() @@ -150,16 +148,6 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se } 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 { groups.clear() it.map { group -> diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index f43738c22..937349bec 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -16,6 +16,7 @@ import java.util.concurrent.Executors class SearchViewModel(application: Application) : BaseViewModel(application) { private var searchPool = Executors.newFixedThreadPool(16).asCoroutineDispatcher() private var task: Coroutine<*>? = null + var callBack: CallBack? = null var searchKey: String = "" var startTime: Long = 0 var searchPage = 0 @@ -105,4 +106,8 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { super.onCleared() searchPool.close() } + + interface CallBack { + + } }