Re-Implement the more button in global search
This commit is contained in:
parent
700fd61f34
commit
2d5ac20c46
@ -18,7 +18,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
|
|||||||
/**
|
/**
|
||||||
* Listen for more button clicks.
|
* Listen for more button clicks.
|
||||||
*/
|
*/
|
||||||
// val moreClickListener: OnMoreClickListener = controller
|
val moreClickListener: OnMoreClickListener = controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bundle where the view state of the holders is saved.
|
* Bundle where the view state of the holders is saved.
|
||||||
|
@ -11,16 +11,19 @@ import androidx.appcompat.widget.SearchView
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding
|
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.appcompat.QueryTextEvent
|
import reactivecircus.flowbinding.appcompat.QueryTextEvent
|
||||||
import reactivecircus.flowbinding.appcompat.queryTextEvents
|
import reactivecircus.flowbinding.appcompat.queryTextEvents
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controller shows and manages the different search result in global search.
|
* This controller shows and manages the different search result in global search.
|
||||||
@ -31,7 +34,13 @@ open class GlobalSearchController(
|
|||||||
protected val initialQuery: String? = null,
|
protected val initialQuery: String? = null,
|
||||||
protected val extensionFilter: String? = null
|
protected val extensionFilter: String? = null
|
||||||
) : NucleusController<GlobalSearchControllerBinding, GlobalSearchPresenter>(),
|
) : NucleusController<GlobalSearchControllerBinding, GlobalSearchPresenter>(),
|
||||||
GlobalSearchCardAdapter.OnMangaClickListener {
|
GlobalSearchCardAdapter.OnMangaClickListener,
|
||||||
|
GlobalSearchAdapter.OnMoreClickListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application preferences.
|
||||||
|
*/
|
||||||
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter containing search results grouped by lang.
|
* Adapter containing search results grouped by lang.
|
||||||
@ -190,4 +199,16 @@ open class GlobalSearchController(
|
|||||||
fun onMangaInitialized(source: CatalogueSource, manga: Manga) {
|
fun onMangaInitialized(source: CatalogueSource, manga: Manga) {
|
||||||
getHolder(source)?.setImage(manga)
|
getHolder(source)?.setImage(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onMoreClick(source: CatalogueSource) {
|
||||||
|
openCatalogue(source, BrowseSourceController(source, presenter.query))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a catalogue with the given controller.
|
||||||
|
*/
|
||||||
|
private fun openCatalogue(source: CatalogueSource, controller: BrowseSourceController) {
|
||||||
|
preferences.lastUsedCatalogueSource().set(source.id)
|
||||||
|
router.pushController(controller.withFadeTransaction())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
|
import kotlinx.android.synthetic.main.global_search_controller_card.more
|
||||||
import kotlinx.android.synthetic.main.global_search_controller_card.progress
|
import kotlinx.android.synthetic.main.global_search_controller_card.progress
|
||||||
import kotlinx.android.synthetic.main.global_search_controller_card.recycler
|
import kotlinx.android.synthetic.main.global_search_controller_card.recycler
|
||||||
import kotlinx.android.synthetic.main.global_search_controller_card.source_card
|
import kotlinx.android.synthetic.main.global_search_controller_card.source_card
|
||||||
@ -31,6 +32,12 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
|||||||
// Set layout horizontal.
|
// Set layout horizontal.
|
||||||
recycler.layoutManager = LinearLayoutManager(view.context, LinearLayoutManager.HORIZONTAL, false)
|
recycler.layoutManager = LinearLayoutManager(view.context, LinearLayoutManager.HORIZONTAL, false)
|
||||||
recycler.adapter = mangaAdapter
|
recycler.adapter = mangaAdapter
|
||||||
|
more.setOnClickListener {
|
||||||
|
val item = adapter.getItem(bindingAdapterPosition)
|
||||||
|
if (item != null) {
|
||||||
|
adapter.moreClickListener.onMoreClick(item.source)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user