mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Add Filter by Completed for library (#941)
* issue 938 added filter by completed manga status * changed to use existing string fixed space issue in method in presenter
This commit is contained in:
		@@ -74,7 +74,9 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
 | 
			
		||||
 | 
			
		||||
        private val unread = Item.CheckboxGroup(R.string.action_filter_unread, this)
 | 
			
		||||
 | 
			
		||||
        override val items = listOf(downloaded, unread)
 | 
			
		||||
        private val completed = Item.CheckboxGroup(R.string.completed, this)
 | 
			
		||||
 | 
			
		||||
        override val items = listOf(downloaded, unread, completed)
 | 
			
		||||
 | 
			
		||||
        override val header = Item.Header(R.string.action_filter)
 | 
			
		||||
 | 
			
		||||
@@ -83,6 +85,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
 | 
			
		||||
        override fun initModels() {
 | 
			
		||||
            downloaded.checked = preferences.filterDownloaded().getOrDefault()
 | 
			
		||||
            unread.checked = preferences.filterUnread().getOrDefault()
 | 
			
		||||
            completed.checked = preferences.filterCompleted().getOrDefault()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        override fun onItemClicked(item: Item) {
 | 
			
		||||
@@ -91,6 +94,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
 | 
			
		||||
            when (item) {
 | 
			
		||||
                downloaded -> preferences.filterDownloaded().set(item.checked)
 | 
			
		||||
                unread -> preferences.filterUnread().set(item.checked)
 | 
			
		||||
                completed -> preferences.filterCompleted().set(item.checked)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            adapter.notifyItemChanged(item)
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
 | 
			
		||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
 | 
			
		||||
import eu.kanade.tachiyomi.source.LocalSource
 | 
			
		||||
import eu.kanade.tachiyomi.source.SourceManager
 | 
			
		||||
import eu.kanade.tachiyomi.source.model.SManga
 | 
			
		||||
import eu.kanade.tachiyomi.source.online.HttpSource
 | 
			
		||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
 | 
			
		||||
import eu.kanade.tachiyomi.util.combineLatest
 | 
			
		||||
@@ -101,6 +102,8 @@ class LibraryPresenter(
 | 
			
		||||
 | 
			
		||||
        val filterUnread = preferences.filterUnread().getOrDefault()
 | 
			
		||||
 | 
			
		||||
        val filterCompleted = preferences.filterCompleted().getOrDefault()
 | 
			
		||||
 | 
			
		||||
        val filterFn: (Manga) -> Boolean = f@ { manga ->
 | 
			
		||||
            // Filter out manga without source.
 | 
			
		||||
            val source = sourceManager.get(manga.source) ?: return@f false
 | 
			
		||||
@@ -110,6 +113,10 @@ class LibraryPresenter(
 | 
			
		||||
                return@f false
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (filterCompleted && manga.status != SManga.COMPLETED) {
 | 
			
		||||
                return@f false
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Filter when the download directory doesn't exist or is null.
 | 
			
		||||
            if (filterDownloaded) {
 | 
			
		||||
                // Get the directories for the source of the manga.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user