Use generic for filterChapters to remove cast warning

This commit is contained in:
Jay 2020-08-09 16:13:56 -04:00
parent 23e7b380b0
commit 0670e00a09
2 changed files with 2 additions and 2 deletions

View File

@ -207,7 +207,7 @@ class MangaDetailsPresenter(
if (isLockedFromSearch) if (isLockedFromSearch)
return chapterList return chapterList
val chapters = chapterFilter.filterChapters(chapterList, manga) as List<ChapterItem> val chapters = chapterFilter.filterChapters(chapterList, manga)
val sortFunction: (Chapter, Chapter) -> Int = when (manga.sorting) { val sortFunction: (Chapter, Chapter) -> Int = when (manga.sorting) {
Manga.SORTING_SOURCE -> when (sortDescending()) { Manga.SORTING_SOURCE -> when (sortDescending()) {

View File

@ -10,7 +10,7 @@ import uy.kohesive.injekt.api.get
class ChapterFilter(val preferences: PreferencesHelper = Injekt.get(), val downloadManager: DownloadManager = Injekt.get()) { class ChapterFilter(val preferences: PreferencesHelper = Injekt.get(), val downloadManager: DownloadManager = Injekt.get()) {
// filters chapters based on the manga values // filters chapters based on the manga values
fun filterChapters(chapters: List<Chapter>, manga: Manga): List<Chapter> { fun <T : Chapter> filterChapters(chapters: List<T>, manga: Manga): List<T> {
val readEnabled = manga.readFilter == Manga.SHOW_READ val readEnabled = manga.readFilter == Manga.SHOW_READ
val unreadEnabled = manga.readFilter == Manga.SHOW_UNREAD val unreadEnabled = manga.readFilter == Manga.SHOW_UNREAD
val downloadEnabled = manga.downloadedFilter == Manga.SHOW_DOWNLOADED val downloadEnabled = manga.downloadedFilter == Manga.SHOW_DOWNLOADED