Implement long click global search for tags

This commit is contained in:
Jobobby04 2020-05-04 00:06:20 -04:00
parent d4659ffaae
commit 46478546a8
2 changed files with 7 additions and 3 deletions

View File

@ -395,8 +395,8 @@ class MangaInfoController(private val fromSource: Boolean = false) :
// Update genres list
if (!manga.genre.isNullOrBlank()) {
binding.mangaGenresTagsCompactChips.setChips(manga.getGenres(), this::performSearch)
binding.mangaGenresTagsFullChips.setChips(manga.getGenres(), this::performSearch)
binding.mangaGenresTagsCompactChips.setChips(manga.getGenres(), this::performSearch, this::performGlobalSearch)
binding.mangaGenresTagsFullChips.setChips(manga.getGenres(), this::performSearch, this::performGlobalSearch)
} else {
binding.mangaGenresTagsWrapper.gone()
}

View File

@ -104,13 +104,17 @@ fun ExtendedFloatingActionButton.shrinkOnScroll(recycler: RecyclerView) {
* @param items List of strings that are shown as individual chips.
* @param onClick Optional on click listener for each chip.
*/
fun ChipGroup.setChips(items: List<String>?, onClick: (item: String) -> Unit = {}) {
fun ChipGroup.setChips(items: List<String>?, onClick: (item: String) -> Unit = {}, onLongClick: (item: String) -> Unit = {}) {
removeAllViews()
items?.forEach { item ->
val chip = Chip(context).apply {
text = item
setOnClickListener { onClick(item) }
setOnLongClickListener {
onLongClick(item)
false
}
}
addView(chip)