Improved isSearchAllowed calls.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako 2022-12-19 21:59:41 +01:00
parent fd906da12e
commit abe77ce8ae
4 changed files with 5 additions and 8 deletions

View file

@ -306,7 +306,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
private void updateSearchVisibility()
{
if (!isSearchAllowed() || isEmpty())
if (isEmpty() || !isSearchAllowed())
{
UiUtils.hide(mSearchContainer);
}
@ -645,7 +645,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
inflater.inflate(R.menu.option_menu_bookmarks, menu);
MenuItem itemSearch = menu.findItem(R.id.bookmarks_search);
itemSearch.setVisible(isSearchAllowed() && !isEmpty());
itemSearch.setVisible(!isEmpty() && isSearchAllowed());
}
@Override
@ -655,7 +655,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
boolean visible = !mSearchMode && !isEmpty();
MenuItem itemSearch = menu.findItem(R.id.bookmarks_search);
itemSearch.setVisible(isSearchAllowed() && visible);
itemSearch.setVisible(visible && isSearchAllowed());
MenuItem itemMore = menu.findItem(R.id.bookmarks_more);
if (mLastSortTimestamp != 0)

View file

@ -35,7 +35,6 @@ NS_SWIFT_NAME(BookmarksManager)
- (void)loadBookmarks;
- (BOOL)isCategoryNotEmpty:(MWMMarkGroupID)groupId;
- (BOOL)isSearchAllowed:(MWMMarkGroupID)groupId;
- (void)prepareForSearch:(MWMMarkGroupID)groupId;
- (NSString *)getCategoryName:(MWMMarkGroupID)groupId;
- (uint64_t)getCategoryMarksCount:(MWMMarkGroupID)groupId;

View file

@ -195,10 +195,6 @@ static BookmarkManager::SortingType convertSortingTypeToCore(MWMBookmarksSorting
(self.bm.GetUserMarkIds(groupId).size() + self.bm.GetTrackIds(groupId).size());
}
- (BOOL)isSearchAllowed:(MWMMarkGroupID)groupId {
return self.bm.IsSearchAllowed(groupId);
}
- (void)prepareForSearch:(MWMMarkGroupID)groupId {
self.bm.PrepareForSearch(groupId);
}

View file

@ -1518,6 +1518,8 @@ bool BookmarkManager::IsSearchAllowed(kml::MarkGroupId groupId) const
indexedBookmarksCount += it->second->GetUserMarks().size();
}
/// @todo This function is actually called on Android only. Probably, there was some problems
/// with indexing large sets of bookmarks, but iOS works good at the same time?
auto const bookmarksCount = GetUserMarkIds(groupId).size();
auto const maxCount = searchAPI.GetMaximumPossibleNumberOfBookmarksToIndex();
return indexedBookmarksCount + bookmarksCount <= maxCount;