|
|
@ -7,7 +7,6 @@ import android.view.View.GONE |
|
|
|
import android.view.View.VISIBLE |
|
|
|
import android.view.View.VISIBLE |
|
|
|
import androidx.appcompat.widget.SearchView |
|
|
|
import androidx.appcompat.widget.SearchView |
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
import androidx.lifecycle.Observer |
|
|
|
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import com.google.android.flexbox.FlexboxLayoutManager |
|
|
|
import com.google.android.flexbox.FlexboxLayoutManager |
|
|
@ -176,17 +175,17 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun initLiveData() { |
|
|
|
private fun initLiveData() { |
|
|
|
App.db.bookSourceDao().liveGroupEnabled().observe(this, Observer { |
|
|
|
App.db.bookSourceDao().liveGroupEnabled().observe(this, { |
|
|
|
groups.clear() |
|
|
|
groups.clear() |
|
|
|
it.map { group -> |
|
|
|
it.map { group -> |
|
|
|
groups.addAll(group.splitNotBlank(",", ";")) |
|
|
|
groups.addAll(group.splitNotBlank(",", ";")) |
|
|
|
} |
|
|
|
} |
|
|
|
upGroupMenu() |
|
|
|
upGroupMenu() |
|
|
|
}) |
|
|
|
}) |
|
|
|
viewModel.searchBookLiveData.observe(this, Observer { |
|
|
|
viewModel.searchBookLiveData.observe(this, { |
|
|
|
upSearchItems(it) |
|
|
|
upSearchItems(it) |
|
|
|
}) |
|
|
|
}) |
|
|
|
viewModel.isSearchLiveData.observe(this, Observer { |
|
|
|
viewModel.isSearchLiveData.observe(this, { |
|
|
|
if (it) { |
|
|
|
if (it) { |
|
|
|
startSearch() |
|
|
|
startSearch() |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -254,7 +253,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
rv_bookshelf_search.gone() |
|
|
|
rv_bookshelf_search.gone() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
bookData = App.db.bookDao().liveDataSearch(key) |
|
|
|
bookData = App.db.bookDao().liveDataSearch(key) |
|
|
|
bookData?.observe(this, Observer { |
|
|
|
bookData?.observe(this, { |
|
|
|
if (it.isEmpty()) { |
|
|
|
if (it.isEmpty()) { |
|
|
|
tv_book_show.gone() |
|
|
|
tv_book_show.gone() |
|
|
|
rv_bookshelf_search.gone() |
|
|
|
rv_bookshelf_search.gone() |
|
|
@ -272,7 +271,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
App.db.searchKeywordDao().liveDataSearch(key) |
|
|
|
App.db.searchKeywordDao().liveDataSearch(key) |
|
|
|
} |
|
|
|
} |
|
|
|
historyData?.observe(this, Observer { |
|
|
|
historyData?.observe(this, { |
|
|
|
historyKeyAdapter.setItems(it) |
|
|
|
historyKeyAdapter.setItems(it) |
|
|
|
if (it.isEmpty()) { |
|
|
|
if (it.isEmpty()) { |
|
|
|
tv_clear_history.invisible() |
|
|
|
tv_clear_history.invisible() |
|
|
|