From 604b4ec01e6ac0bb1709cb2c428b2babbd518297 Mon Sep 17 00:00:00 2001 From: Jobobby04 Date: Wed, 30 Sep 2020 17:52:24 -0400 Subject: [PATCH] Fix expanding tags on E-Hentai and similar manga --- .../ui/manga/info/MangaInfoItemAdapter.kt | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoItemAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoItemAdapter.kt index 6bc3c846f..f564b7aa1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoItemAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoItemAdapter.kt @@ -3,7 +3,9 @@ package eu.kanade.tachiyomi.ui.manga.info import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible +import androidx.core.view.updateLayoutParams import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import eu.davidea.flexibleadapter.FlexibleAdapter @@ -28,9 +30,9 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.launch import reactivecircus.flowbinding.android.view.clicks import reactivecircus.flowbinding.android.view.longClicks -import uy.kohesive.injekt.api.get class MangaInfoItemAdapter( private val controller: MangaController, @@ -88,6 +90,15 @@ class MangaInfoItemAdapter( binding.genreGroups.layoutManager = LinearLayoutManager(itemView.context) binding.genreGroups.adapter = mangaTagsInfoAdapter + // SY --> + mangaTagsInfoAdapter?.mItemClickListener = FlexibleAdapter.OnItemClickListener { _, _ -> + scope.launch { + toggleMangaInfo() + } + false + } + // SY <-- + setMangaInfo(manga, source) } @@ -110,9 +121,16 @@ class MangaInfoItemAdapter( manga.description } + // SY --> if (binding.mangaSummaryText.text == "meta") { - binding.mangaSummaryText.isVisible = false + binding.mangaSummaryText.text = "" + binding.mangaSummaryText.maxLines = 1 + binding.mangaInfoToggleLess.updateLayoutParams { + topToBottom = -1 + bottomToBottom = binding.mangaSummaryText.id + } } + // SY <-- // Update genres list if (!manga.genre.isNullOrBlank()) { @@ -169,14 +187,14 @@ class MangaInfoItemAdapter( } private fun toggleMangaInfo() { - val isCurrentlyExpanded = binding.mangaSummaryText.maxLines != 2 + val isCurrentlyExpanded = binding.mangaSummaryText.maxLines != 2 /* SY --> */ && binding.mangaSummaryText.maxLines != 1 /* SY <-- */ binding.mangaInfoToggleMoreScrim.isVisible = isCurrentlyExpanded binding.mangaInfoToggleMore.isVisible = isCurrentlyExpanded binding.mangaInfoToggleLess.isVisible = !isCurrentlyExpanded binding.mangaSummaryText.maxLines = if (isCurrentlyExpanded) { - 2 + /* SY --> */ if (binding.mangaSummaryText.text.isBlank()) 1 else /* SY <-- */ 2 } else { Int.MAX_VALUE }