Fix drawer items without folder having their feed icon not displaying and their unread count badge

This commit is contained in:
Shinokuni 2019-07-07 14:25:46 +02:00
parent ddfd9507a5
commit f574ccfd16
2 changed files with 16 additions and 8 deletions

View File

@ -85,7 +85,7 @@ public class DrawerManager {
ExpandableBadgeDrawerItem badgeDrawerItem = new ExpandableBadgeDrawerItem() ExpandableBadgeDrawerItem badgeDrawerItem = new ExpandableBadgeDrawerItem()
.withName(folder.getName()) .withName(folder.getName())
.withIdentifier(folder.getId()) .withIdentifier(folder.getId())
.withIcon(activity.getDrawable(R.drawable.ic_folder_grey)); .withIcon(R.drawable.ic_folder_grey);
List<IDrawerItem> secondaryDrawerItems = new ArrayList<>(); List<IDrawerItem> secondaryDrawerItems = new ArrayList<>();
int expandableUnreadCount = 0; int expandableUnreadCount = 0;
@ -134,12 +134,12 @@ public class DrawerManager {
} }
ProfileSettingDrawerItem profileSettingsItem = new ProfileSettingDrawerItem() ProfileSettingDrawerItem profileSettingsItem = new ProfileSettingDrawerItem()
.withName(activity.getString(R.string.account_settings)) .withName(R.string.account_settings)
.withIcon(R.drawable.ic_account) .withIcon(R.drawable.ic_account)
.withIdentifier(ACCOUNT_SETTINGS_ID); .withIdentifier(ACCOUNT_SETTINGS_ID);
ProfileSettingDrawerItem addAccountSettingsItem = new ProfileSettingDrawerItem() ProfileSettingDrawerItem addAccountSettingsItem = new ProfileSettingDrawerItem()
.withName(activity.getString(R.string.add_account)) .withName(R.string.add_account)
.withIcon(R.drawable.ic_add_account_grey) .withIcon(R.drawable.ic_add_account_grey)
.withIdentifier(ADD_ACCOUNT_ID); .withIdentifier(ADD_ACCOUNT_ID);
@ -182,6 +182,8 @@ public class DrawerManager {
@Override @Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
secondaryDrawerItem.withIcon(resource); secondaryDrawerItem.withIcon(resource);
drawer.updateItem(secondaryDrawerItem);
} }
@Override @Override
@ -195,14 +197,14 @@ public class DrawerManager {
private void addDefaultPlaces() { private void addDefaultPlaces() {
PrimaryDrawerItem articles = new PrimaryDrawerItem() PrimaryDrawerItem articles = new PrimaryDrawerItem()
.withName(activity.getString(R.string.articles)) .withName(R.string.articles)
.withIcon(activity.getDrawable(R.drawable.ic_rss_feed_grey)) .withIcon(R.drawable.ic_rss_feed_grey)
.withSelectable(true) .withSelectable(true)
.withIdentifier(ARTICLES_ITEM_ID); .withIdentifier(ARTICLES_ITEM_ID);
PrimaryDrawerItem toReadLater = new PrimaryDrawerItem() PrimaryDrawerItem toReadLater = new PrimaryDrawerItem()
.withName(activity.getString(R.string.read_later)) .withName(R.string.read_later)
.withIcon(activity.getDrawable(R.drawable.ic_read_later_grey)) .withIcon(R.drawable.ic_read_later_grey)
.withSelectable(true) .withSelectable(true)
.withIdentifier(READ_LATER_ID); .withIdentifier(READ_LATER_ID);

View File

@ -148,7 +148,13 @@ public class MainViewModel extends AndroidViewModel {
Folder noFolder = new Folder("no folder"); Folder noFolder = new Folder("no folder");
noFolder.setId(0); noFolder.setId(0);
foldersWithFeeds.put(noFolder, db.feedDao().getFeedsWithoutFolder(currentAccount.getId()));
List<Feed> feedsWithoutFolder = db.feedDao().getFeedsWithoutFolder(currentAccount.getId());
for (Feed feed : feedsWithoutFolder) {
feed.setUnreadCount(db.itemDao().getUnreadCount(feed.getId()));
}
foldersWithFeeds.put(noFolder, feedsWithoutFolder);
emitter.onSuccess(foldersWithFeeds); emitter.onSuccess(foldersWithFeeds);
}); });