Fix #373 and a few crashes

This commit is contained in:
len
2016-12-31 16:19:32 +01:00
parent a7192e866f
commit 3a1699f0b3
6 changed files with 31 additions and 11 deletions
@@ -293,9 +293,12 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
*
* @param mangas the list of manga.
*/
fun getCommonCategories(mangas: List<Manga>): Collection<Category> = mangas.toSet()
.map { db.getCategoriesForManga(it).executeAsBlocking() }
.reduce { set1: Iterable<Category>, set2 -> set1.intersect(set2) }
fun getCommonCategories(mangas: List<Manga>): Collection<Category> {
if (mangas.isEmpty()) return emptyList()
return mangas.toSet()
.map { db.getCategoriesForManga(it).executeAsBlocking() }
.reduce { set1: Iterable<Category>, set2 -> set1.intersect(set2) }
}
/**
* Remove the selected manga from the library.