|
|
|
@ -22,6 +22,7 @@ import io.legado.app.data.appDb |
|
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
|
import io.legado.app.data.entities.SearchKeyword |
|
|
|
|
import io.legado.app.databinding.ActivityBookSearchBinding |
|
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
|
import io.legado.app.lib.theme.* |
|
|
|
|
import io.legado.app.ui.book.info.BookInfoActivity |
|
|
|
|
import io.legado.app.ui.book.source.manage.BookSourceActivity |
|
|
|
@ -71,6 +72,22 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel |
|
|
|
|
initOtherView() |
|
|
|
|
initData() |
|
|
|
|
receiptIntent(intent) |
|
|
|
|
viewModel.searchFinishCallback = { |
|
|
|
|
if (it) { |
|
|
|
|
val searchGroup = getPrefString("searchGroup") |
|
|
|
|
if (!searchGroup.isNullOrEmpty()) { |
|
|
|
|
alert(R.string.empty) { |
|
|
|
|
setMessage("${searchGroup}分组搜索结果为空,是否切换到全部分组") |
|
|
|
|
cancelButton() |
|
|
|
|
okButton { |
|
|
|
|
putPrefString("searchGroup", "") |
|
|
|
|
viewModel.searchKey = "" |
|
|
|
|
viewModel.search(searchView.query.toString()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onNewIntent(data: Intent?) { |
|
|
|
@ -126,6 +143,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel |
|
|
|
|
searchView.clearFocus() |
|
|
|
|
query?.let { |
|
|
|
|
viewModel.saveSearchKey(query) |
|
|
|
|
viewModel.searchKey = "" |
|
|
|
|
viewModel.search(it) |
|
|
|
|
} |
|
|
|
|
openOrCloseHistory(false) |
|
|
|
@ -235,7 +253,10 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel |
|
|
|
|
* 滚动到底部事件 |
|
|
|
|
*/ |
|
|
|
|
private fun scrollToBottom() { |
|
|
|
|
if (!viewModel.isLoading && viewModel.searchKey.isNotEmpty() && loadMoreView.hasMore) { |
|
|
|
|
if (viewModel.isSearchLiveData.value == false |
|
|
|
|
&& viewModel.searchKey.isNotEmpty() |
|
|
|
|
&& loadMoreView.hasMore |
|
|
|
|
) { |
|
|
|
|
viewModel.search("") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -371,6 +392,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel |
|
|
|
|
viewModel.deleteHistory(searchKeyword) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
fun start(context: Context, key: String?) { |
|
|
|
|