From d361f41b35c1cdb4b2e0fa5f9979df24a90aeb1b Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 24 Mar 2020 02:47:40 -0400 Subject: [PATCH] Searching chapters collapses manga header Fixed fade in of chapters on first load of manga details --- .../ui/catalogue/CatalogueController.kt | 2 +- .../tachiyomi/ui/manga/MangaDetailsAdapter.kt | 4 +-- .../ui/manga/MangaDetailsController.kt | 4 +++ .../tachiyomi/ui/manga/MangaHeaderHolder.kt | 35 +++++++++++++++---- app/src/main/res/layout/manga_header_item.xml | 9 ++++- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt index b05e9cfd7c..6229806756 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt @@ -34,13 +34,13 @@ import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController import eu.kanade.tachiyomi.util.view.scrollViewWith import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener import eu.kanade.tachiyomi.widget.preference.SourceLoginDialog +import kotlin.math.max import kotlinx.android.parcel.Parcelize import kotlinx.android.synthetic.main.catalogue_main_controller.* import kotlinx.android.synthetic.main.extensions_bottom_sheet.* import kotlinx.android.synthetic.main.main_activity.* import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import kotlin.math.max /** * This controller shows and manages the different catalogues enabled by the user. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt index f4000e1231..abd876b0c9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt @@ -52,10 +52,10 @@ class MangaDetailsAdapter( fun performFilter() { val s = getFilter(String::class.java) if (s.isNullOrBlank()) { - updateDataSet(items, true) + updateDataSet(items, itemCount != 0) } else { updateDataSet(items.filter { it.name.contains(s, true) || - it.scanlator?.contains(s, true) == true }) + it.scanlator?.contains(s, true) == true }, itemCount != 0) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index dddb22d4f2..045dafb061 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -576,6 +576,10 @@ class MangaDetailsController : BaseController, setOnQueryTextChangeListener(searchView) { query = it ?: "" + if (query.isNotEmpty()) { + (recycler.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder)?.collaspe() + } else (recycler.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder)?.expand() + adapter?.setFilter(query) adapter?.performFilter() true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index 3f0e148b38..3f8d8c98c3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -20,11 +20,12 @@ import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.gone +import eu.kanade.tachiyomi.util.view.invisible import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visibleIf -import java.util.Locale import kotlinx.android.synthetic.main.manga_header_item.* +import java.util.Locale class MangaHeaderHolder( private val view: View, @@ -103,11 +104,13 @@ class MangaHeaderHolder( .no_description) manga_summary.post { - if ((manga_summary.lineCount < 3 && manga.genre.isNullOrBlank()) || - less_button.visibility == View.VISIBLE) { - more_button_group.gone() - } else - more_button_group.visible() + if (sub_item_group.visibility != View.GONE) { + if ((manga_summary.lineCount < 3 && manga.genre.isNullOrBlank()) || less_button.visibility == View.VISIBLE) { + more_button_group.gone() + } else more_button_group.visible() + } + if (adapter.hasFilter()) collaspe() + else expand() } manga_summary_label.text = itemView.context.getString(R.string.about_this, itemView.context.getString( @@ -252,6 +255,26 @@ class MangaHeaderHolder( } } + fun collaspe() { + sub_item_group.gone() + if (more_button.visibility == View.VISIBLE || more_button.visibility == View.INVISIBLE) + more_button_group.invisible() + else { + less_button.gone() + manga_genres_tags.gone() + } + } + + fun expand() { + sub_item_group.visible() + if (more_button.visibility == View.VISIBLE || more_button.visibility == View.INVISIBLE) + more_button_group.visible() + else { + less_button.visible() + manga_genres_tags.visible() + } + } + override fun onLongClick(view: View?): Boolean { super.onLongClick(view) return false diff --git a/app/src/main/res/layout/manga_header_item.xml b/app/src/main/res/layout/manga_header_item.xml index 9e4f434533..3353055ac5 100644 --- a/app/src/main/res/layout/manga_header_item.xml +++ b/app/src/main/res/layout/manga_header_item.xml @@ -274,6 +274,13 @@ android:layout_height="wrap_content" app:constraint_referenced_ids="more_button,more_bg_gradient,more_bg_solid" /> + +