mirror of
https://github.com/readrops/Readrops.git
synced 2024-12-26 16:43:09 +01:00
Use a null key for feeds without folders
This commit is contained in:
parent
ab86bcbcc2
commit
74447b1671
@ -39,6 +39,8 @@ android {
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
coreLibraryDesugaringEnabled true
|
||||
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
@ -56,6 +58,8 @@ dependencies {
|
||||
implementation project(':api')
|
||||
implementation project(':db')
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
|
||||
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.palette:palette:1.0.0'
|
||||
|
@ -19,6 +19,7 @@ import com.readrops.db.entities.account.AccountType;
|
||||
import com.readrops.api.services.SyncResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@ -132,7 +133,7 @@ public abstract class ARepository<T> {
|
||||
public Single<Map<Folder, List<Feed>>> getFoldersWithFeeds() {
|
||||
return Single.create(emitter -> {
|
||||
List<Folder> folders = database.folderDao().getFolders(account.getId());
|
||||
Map<Folder, List<Feed>> foldersWithFeeds = new TreeMap<>(Folder::compareTo);
|
||||
Map<Folder, List<Feed>> foldersWithFeeds = new TreeMap<>(Comparator.nullsLast(Folder::compareTo));
|
||||
|
||||
for (Folder folder : folders) {
|
||||
List<Feed> feeds = database.feedDao().getFeedsByFolder(folder.getId());
|
||||
@ -145,14 +146,13 @@ public abstract class ARepository<T> {
|
||||
foldersWithFeeds.put(folder, feeds);
|
||||
}
|
||||
|
||||
Folder noFolder = new Folder("no folder");
|
||||
|
||||
// feeds without folder
|
||||
List<Feed> feedsWithoutFolder = database.feedDao().getFeedsWithoutFolder(account.getId());
|
||||
for (Feed feed : feedsWithoutFolder) {
|
||||
feed.setUnreadCount(database.itemDao().getUnreadCount(feed.getId()));
|
||||
}
|
||||
|
||||
foldersWithFeeds.put(noFolder, feedsWithoutFolder);
|
||||
foldersWithFeeds.put(null, feedsWithoutFolder);
|
||||
|
||||
emitter.onSuccess(foldersWithFeeds);
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ public class DrawerManager {
|
||||
|
||||
for (Map.Entry<Folder, List<Feed>> entry : folderListMap.entrySet()) {
|
||||
Folder folder = entry.getKey();
|
||||
if (folder.getId() != 0) {
|
||||
if (folder != null) {
|
||||
// no identifier for badge items, but if needed, be aware of not getting conflicts
|
||||
// with secondary item identifiers (folder and feed ids can be the same)
|
||||
ExpandableBadgeDrawerItem badgeDrawerItem = new ExpandableBadgeDrawerItem()
|
||||
|
@ -66,6 +66,7 @@ public class AccountViewModel extends AndroidViewModel {
|
||||
return database.accountDao().getAccountCount();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Single<Map<Folder, List<Feed>>> getFoldersWithFeeds() {
|
||||
return repository.getFoldersWithFeeds();
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ public class MainViewModel extends AndroidViewModel {
|
||||
return repository.getFeedCount(currentAccount.getId());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Single<Map<Folder, List<Feed>>> getFoldersWithFeeds() {
|
||||
return repository.getFoldersWithFeeds();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user