From 81d4a3cf686d631e557b317a556ba8818e91d564 Mon Sep 17 00:00:00 2001 From: jsericksk Date: Mon, 19 Feb 2024 17:32:02 -0300 Subject: [PATCH] Fix grid view in ChaptersSheet --- .../org/koitharu/kotatsu/reader/ui/ChaptersSheet.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ChaptersSheet.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ChaptersSheet.kt index f8bff285f..72a3cecb6 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ChaptersSheet.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ChaptersSheet.kt @@ -6,6 +6,8 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.FragmentManager import androidx.fragment.app.activityViewModels +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.LinearLayoutManager import dagger.hilt.android.AndroidEntryPoint import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.model.MangaHistory @@ -75,7 +77,8 @@ class ChaptersSheet : BaseAdaptiveSheet(), -1 } binding.recyclerView.addItemDecoration(TypedListSpacingDecoration(binding.recyclerView.context, true)) - binding.recyclerView.adapter = ChaptersAdapter(this, false).also { adapter -> + val chaptersInGridView = settings.chaptersGridView + binding.recyclerView.adapter = ChaptersAdapter(this, chaptersInGridView).also { adapter -> if (currentPosition >= 0) { val targetPosition = (currentPosition - 1).coerceAtLeast(0) val offset = @@ -87,6 +90,11 @@ class ChaptersSheet : BaseAdaptiveSheet(), adapter.items = chapters } } + binding.recyclerView.layoutManager = if (chaptersInGridView) { + GridLayoutManager(context, 4) + } else { + LinearLayoutManager(context) + } } override fun onItemClick(item: ChapterListItem, view: View) {