Recents searching is now paginated

This commit is contained in:
Jays2Kings 2021-04-13 14:12:09 -04:00
parent 77e8ac4b00
commit 5b840161e7
2 changed files with 14 additions and 11 deletions

View File

@ -378,18 +378,18 @@ class RecentsController(bundle: Bundle? = null) :
adapter.removeAllScrollableHeaders()
adapter.updateItems(recents)
adapter.onLoadMoreComplete(null)
if (!hasNewItems || presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL || presenter.query.isNotEmpty() ||
if (!hasNewItems || presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL ||
recents.isEmpty()
) {
loadNoMore()
} else if (hasNewItems && presenter.viewType != RecentsPresenter.VIEW_TYPE_GROUP_ALL && presenter.query.isEmpty()) {
} else if (hasNewItems && presenter.viewType != RecentsPresenter.VIEW_TYPE_GROUP_ALL) {
resetProgressItem()
}
if (recents.isEmpty()) {
binding.recentsEmptyView.show(
if (presenter.query.isEmpty()) R.drawable.ic_history_off_24dp
if (!isSearching()) R.drawable.ic_history_off_24dp
else R.drawable.ic_search_off_24dp,
if (presenter.query.isNotEmpty()) R.string.no_results_found
if (isSearching()) R.string.no_results_found
else when (presenter.viewType) {
RecentsPresenter.VIEW_TYPE_ONLY_UPDATES -> R.string.no_recent_chapters
RecentsPresenter.VIEW_TYPE_ONLY_HISTORY -> R.string.no_recently_read_manga
@ -551,7 +551,7 @@ class RecentsController(bundle: Bundle? = null) :
val searchItem = menu.findItem(R.id.action_search)
val searchView = searchItem.actionView as SearchView
searchView.queryHint = view?.context?.getString(R.string.search_recents)
if (presenter.query.isNotEmpty()) {
if (isSearching()) {
searchItem.expandActionView()
searchView.setQuery(presenter.query, true)
searchView.clearFocus()
@ -559,7 +559,8 @@ class RecentsController(bundle: Bundle? = null) :
setOnQueryTextChangeListener(searchView) {
if (presenter.query != it) {
presenter.query = it ?: return@setOnQueryTextChangeListener false
loadNoMore()
// loadNoMore()
resetProgressItem()
refresh()
}
true
@ -662,8 +663,10 @@ class RecentsController(bundle: Bundle? = null) :
val view = view ?: return
if (presenter.finished ||
BackupRestoreService.isRunning(view.context.applicationContext) ||
presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL ||
presenter.query.isNotEmpty()
(
presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL &&
!isSearching()
)
) {
loadNoMore()
return

View File

@ -125,12 +125,12 @@ class RecentsPresenter(
val viewType = customViewType ?: viewType
val showRead = preferences.showReadInAllRecents().get() && !limit
val isUngrouped = viewType > VIEW_TYPE_GROUP_ALL && query.isEmpty()
val isUngrouped = viewType > VIEW_TYPE_GROUP_ALL || query.isNotEmpty()
val isCustom = customViewType != null
val isEndless = isUngrouped && !limit
val cReading = when {
query.isNotEmpty() || viewType <= VIEW_TYPE_UNGROUP_ALL -> {
viewType <= VIEW_TYPE_UNGROUP_ALL -> {
db.getAllRecentsTypes(
query,
showRead,
@ -265,7 +265,7 @@ class RecentsPresenter(
}
val newCount = itemCount + newItems.size
val hasNewItems = newItems.isNotEmpty()
if (updatePageCount && newCount < 25 && viewType != VIEW_TYPE_GROUP_ALL && query.isEmpty() && !limit) {
if (updatePageCount && newCount < 25 && (viewType != VIEW_TYPE_GROUP_ALL || query.isNotEmpty()) && !limit) {
runRecents(oldQuery, true, retryCount + (if (hasNewItems) 0 else 1), newCount)
return
}