mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 16:39:09 +01:00
Fixed start reading button showing with no chapters
And the more button now properly hides when there's no much of a description
This commit is contained in:
parent
3da64d8835
commit
33bda22f08
@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.invisible
|
||||
import eu.kanade.tachiyomi.util.view.isVisible
|
||||
import eu.kanade.tachiyomi.util.view.resetStrokeColor
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
@ -37,6 +38,9 @@ class MangaHeaderHolder(
|
||||
isTablet: Boolean = false
|
||||
) : BaseFlexibleViewHolder(view, adapter) {
|
||||
|
||||
var showReadingButton = true
|
||||
var showMoreButton = true
|
||||
|
||||
init {
|
||||
chapter_layout.setOnClickListener { adapter.delegate.showChapterFilter() }
|
||||
if (start_reading_button != null) {
|
||||
@ -139,20 +143,15 @@ class MangaHeaderHolder(
|
||||
if (manga.description.isNullOrBlank()) itemView.context.getString(R.string.no_description)
|
||||
else manga.description?.trim()
|
||||
|
||||
if (item.isLocked) sub_item_group.referencedIds =
|
||||
intArrayOf(R.id.manga_summary, R.id.manga_summary_label, R.id.button_layout)
|
||||
else sub_item_group.referencedIds = intArrayOf(
|
||||
R.id.start_reading_button,
|
||||
R.id.manga_summary,
|
||||
R.id.manga_summary_label,
|
||||
R.id.button_layout
|
||||
)
|
||||
|
||||
manga_summary.post {
|
||||
if (sub_item_group.visibility != View.GONE) {
|
||||
if ((manga_summary.lineCount < 3 && manga.genre.isNullOrBlank()) || less_button.visibility == View.VISIBLE) {
|
||||
manga_summary.setTextIsSelectable(true)
|
||||
more_button_group.gone()
|
||||
} else more_button_group.visible()
|
||||
showMoreButton = false
|
||||
} else {
|
||||
more_button_group.visible()
|
||||
}
|
||||
}
|
||||
if (adapter.hasFilter()) collapse()
|
||||
else expand()
|
||||
@ -200,7 +199,8 @@ class MangaHeaderHolder(
|
||||
|
||||
with(start_reading_button) {
|
||||
val nextChapter = presenter.getNextUnreadChapter()
|
||||
visibleIf(presenter.chapters.isNotEmpty() && !item.isLocked)
|
||||
visibleIf(presenter.chapters.isNotEmpty() && !item.isLocked && !adapter.hasFilter())
|
||||
showReadingButton = isVisible()
|
||||
isEnabled = (nextChapter != null)
|
||||
text = if (nextChapter != null) {
|
||||
val number = adapter.decimalFormat.format(nextChapter.chapter_number.toDouble())
|
||||
@ -292,6 +292,7 @@ class MangaHeaderHolder(
|
||||
|
||||
fun collapse() {
|
||||
sub_item_group.gone()
|
||||
start_reading_button.gone()
|
||||
if (more_button.visibility == View.VISIBLE || more_button.visibility == View.INVISIBLE)
|
||||
more_button_group.invisible()
|
||||
else {
|
||||
@ -302,11 +303,15 @@ class MangaHeaderHolder(
|
||||
|
||||
fun expand() {
|
||||
sub_item_group.visible()
|
||||
if (more_button.visibility == View.VISIBLE || more_button.visibility == View.INVISIBLE) more_button_group.visible()
|
||||
if (!showMoreButton) more_button_group.gone()
|
||||
else {
|
||||
less_button.visible()
|
||||
manga_genres_tags.visible()
|
||||
if (manga_summary.maxLines != Integer.MAX_VALUE) more_button_group.visible()
|
||||
else {
|
||||
less_button.visible()
|
||||
manga_genres_tags.visible()
|
||||
}
|
||||
}
|
||||
start_reading_button.visibleIf(showReadingButton)
|
||||
}
|
||||
|
||||
override fun onLongClick(view: View?): Boolean {
|
||||
|
@ -285,8 +285,7 @@
|
||||
android:id="@+id/sub_item_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="start_reading_button,
|
||||
manga_summary,manga_summary_label,button_layout" />
|
||||
app:constraint_referenced_ids="manga_summary,manga_summary_label,button_layout" />
|
||||
|
||||
<me.gujun.android.taggroup.TagGroup
|
||||
android:id="@+id/manga_genres_tags"
|
||||
@ -332,6 +331,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:text="@string/start_reading"
|
||||
|
Loading…
x
Reference in New Issue
Block a user