mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Exclude manga from unknown sources from the library
This commit is contained in:
parent
af0cf9e52d
commit
f629db3c10
1 changed files with 10 additions and 9 deletions
|
@ -129,10 +129,8 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||||
return db.getLibraryMangas().asRxObservable()
|
return db.getLibraryMangas().asRxObservable()
|
||||||
.flatMap { mangas ->
|
.flatMap { mangas ->
|
||||||
Observable.from(mangas)
|
Observable.from(mangas)
|
||||||
.filter {
|
// Filter library by options
|
||||||
// Filter library by options
|
.filter { filterManga(it) }
|
||||||
filterLibrary(it)
|
|
||||||
}
|
|
||||||
.groupBy { it.category }
|
.groupBy { it.category }
|
||||||
.flatMap { group -> group.toList().map { Pair(group.key, it) } }
|
.flatMap { group -> group.toList().map { Pair(group.key, it) } }
|
||||||
.toMap({ it.first }, { it.second })
|
.toMap({ it.first }, { it.second })
|
||||||
|
@ -156,12 +154,15 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter library by preference
|
* Filters an entry of the library.
|
||||||
*
|
*
|
||||||
* @param manga from library
|
* @param manga a favorite manga from the database.
|
||||||
* @return filter status
|
* @return true if the entry is included, false otherwise.
|
||||||
*/
|
*/
|
||||||
fun filterLibrary(manga: Manga): Boolean {
|
fun filterManga(manga: Manga): Boolean {
|
||||||
|
// Filter out manga without source
|
||||||
|
val source = sourceManager.get(manga.source) ?: return false
|
||||||
|
|
||||||
val prefFilterDownloaded = preferences.filterDownloaded().getOrDefault()
|
val prefFilterDownloaded = preferences.filterDownloaded().getOrDefault()
|
||||||
val prefFilterUnread = preferences.filterUnread().getOrDefault()
|
val prefFilterUnread = preferences.filterUnread().getOrDefault()
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefFilterDownloaded) {
|
if (prefFilterDownloaded) {
|
||||||
val mangaDir = downloadManager.getAbsoluteMangaDirectory(sourceManager.get(manga.source)!!, manga)
|
val mangaDir = downloadManager.getAbsoluteMangaDirectory(source, manga)
|
||||||
|
|
||||||
if (mangaDir.exists()) {
|
if (mangaDir.exists()) {
|
||||||
for (file in mangaDir.listFiles()) {
|
for (file in mangaDir.listFiles()) {
|
||||||
|
|
Loading…
Reference in a new issue