use of it.niedermann.owncloud.notes.persistence.entity.CategoryWithNotesCount in project nextcloud-notes by stefan-niedermann.
the class MainViewModelTest method fromCategoriesWithNotesCount_only_deep_category_without_favorites.
@Test
public void fromCategoriesWithNotesCount_only_deep_category_without_favorites() throws InvocationTargetException, IllegalAccessException {
// noinspection unchecked
final var navigationItems = (List<NavigationItem>) fromCategoriesWithNotesCount.invoke(null, context, "Bar/abc", List.of(new CategoryWithNotesCount(1, "Bar/abc/def", 5)), 0, 0);
assertNotNull(navigationItems);
assertEquals(3, navigationItems.size());
assertEquals(ENavigationCategoryType.RECENT, navigationItems.get(0).type);
assertEquals(ENavigationCategoryType.FAVORITES, navigationItems.get(1).type);
assertEquals("Bar", navigationItems.get(2).label);
}
use of it.niedermann.owncloud.notes.persistence.entity.CategoryWithNotesCount in project nextcloud-notes by stefan-niedermann.
the class DisplayUtils method convertToCategoryNavigationItem.
public static NavigationItem.CategoryNavigationItem convertToCategoryNavigationItem(@NonNull Context context, @NonNull CategoryWithNotesCount counter) {
final var res = context.getResources();
final var englishRes = getEnglishResources(context);
final String category = counter.getCategory().replaceAll("\\s+", "");
int icon = NavigationAdapter.ICON_FOLDER;
for (Map.Entry<Integer, Collection<Integer>> replacement : SPECIAL_CATEGORY_REPLACEMENTS.entrySet()) {
if (Stream.concat(replacement.getValue().stream().map(res::getString), replacement.getValue().stream().map(englishRes::getString)).map(str -> str.replaceAll("\\s+", "")).anyMatch(r -> r.equalsIgnoreCase(category))) {
icon = replacement.getKey();
break;
}
}
return new NavigationItem.CategoryNavigationItem("category:" + counter.getCategory(), counter.getCategory(), counter.getTotalNotes(), icon, counter.getAccountId(), counter.getCategory());
}
Aggregations