Clicking tag now does a local search

This commit is contained in:
Jay 2019-11-24 22:06:50 -08:00
parent 898792ce8e
commit 84d1454f6e
3 changed files with 26 additions and 2 deletions

View File

@ -386,6 +386,10 @@ class LibraryController(
searchItem.fixExpand()
}
fun search(query:String) {
this.query = query
}
override fun onPrepareOptionsMenu(menu: Menu) {
val navView = navView ?: return

View File

@ -373,6 +373,11 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
actionMode = null
}
override fun onDetach(view: View) {
destroyActionModeIfNeeded()
super.onDetach(view)
}
override fun onMenuItemClick(position: Int, item: MenuItem) {
val chapter = adapter?.getItem(position) ?: return
val chapters = listOf(chapter)

View File

@ -44,6 +44,7 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.util.doOnApplyWindowInsets
@ -143,7 +144,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
.toString(), R.string.description)
}
//manga_genres_tags.setOnTagClickListener { tag -> performGlobalSearch(tag) }
manga_genres_tags.setOnTagClickListener { tag -> performLocalSearch(tag) }
manga_cover.longClicks().subscribeUntilDestroy {
copyToClipboard(view.context.getString(R.string.title), presenter.manga.title, R.string.manga_info_full_title_label)
@ -616,11 +617,25 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
*
* @param query the search query to pass to the search controller
*/
fun performGlobalSearch(query: String) {
private fun performGlobalSearch(query: String) {
val router = parentController?.router ?: return
router.pushController(CatalogueSearchController(query).withFadeTransaction())
}
/**
* Perform a local search using the provided query.
*
* @param query the search query to pass to the library controller
*/
private fun performLocalSearch(query: String) {
val router = parentController?.router ?: return
val firstController = router.backstack.first()?.controller()
if (firstController is LibraryController && router.backstack.size == 2) {
router.handleBack()
firstController.search(query)
}
}
/**
* Create shortcut using ShortcutManager.
*