From c466baaa25d5ab234286f361f14212074833bf48 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 12 Sep 2020 15:39:26 -0400 Subject: [PATCH] Remove list dividers --- .../details/ExtensionDetailsController.kt | 3 - .../details/SourcePreferencesController.kt | 3 - .../source/browse/BrowseSourceController.kt | 2 - .../tachiyomi/ui/manga/MangaController.kt | 2 - .../chapter/ChapterDividerItemDecoration.kt | 59 ------------------- .../ui/recent/updates/UpdatesController.kt | 2 - 6 files changed, 71 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDividerItemDecoration.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt index e7b5e25cd9..b5ff002906 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt @@ -20,8 +20,6 @@ import androidx.preference.PreferenceManager import androidx.preference.PreferenceScreen import androidx.preference.SwitchPreferenceCompat import androidx.recyclerview.widget.ConcatAdapter -import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.DividerItemDecoration.VERTICAL import androidx.recyclerview.widget.LinearLayoutManager import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.EmptyPreferenceDataStore @@ -92,7 +90,6 @@ class ExtensionDetailsController(bundle: Bundle? = null) : ExtensionDetailsHeaderAdapter(presenter), initPreferencesAdapter(context, extension) ) - binding.extensionPrefsRecycler.addItemDecoration(DividerItemDecoration(context, VERTICAL)) } private fun initPreferencesAdapter(context: Context, extension: Extension.Installed): PreferenceGroupAdapter { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt index 7867f6c1dc..fa26cd208d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesController.kt @@ -19,8 +19,6 @@ import androidx.preference.Preference import androidx.preference.PreferenceGroupAdapter import androidx.preference.PreferenceManager import androidx.preference.PreferenceScreen -import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.DividerItemDecoration.VERTICAL import androidx.recyclerview.widget.LinearLayoutManager import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.EmptyPreferenceDataStore @@ -86,7 +84,6 @@ class SourcePreferencesController(bundle: Bundle? = null) : binding.recycler.layoutManager = LinearLayoutManager(context) binding.recycler.adapter = PreferenceGroupAdapter(screen) - binding.recycler.addItemDecoration(DividerItemDecoration(context, VERTICAL)) } override fun onDestroyView(view: View) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index 118d9106f7..5b82616fdf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -10,7 +10,6 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.SearchView import androidx.core.view.isVisible -import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -216,7 +215,6 @@ open class BrowseSourceController(bundle: Bundle) : id = R.id.recycler layoutManager = LinearLayoutManager(context) layoutParams = RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) - addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL)) } } else { (binding.catalogueView.inflate(R.layout.source_recycler_autofit) as AutofitRecyclerView).apply { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index ec2159eb75..e7c7e1fdd1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -52,7 +52,6 @@ import eu.kanade.tachiyomi.ui.library.ChangeMangaCoverDialog import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.offsetAppbarHeight -import eu.kanade.tachiyomi.ui.manga.chapter.ChapterDividerItemDecoration import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersAdapter import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersSettingsSheet @@ -208,7 +207,6 @@ class MangaController : binding.recycler.adapter = ConcatAdapter(mangaInfoAdapter, chaptersHeaderAdapter, chaptersAdapter) binding.recycler.layoutManager = LinearLayoutManager(view.context) - binding.recycler.addItemDecoration(ChapterDividerItemDecoration(view.context)) binding.recycler.setHasFixedSize(true) chaptersAdapter?.fastScroller = binding.fastScroller diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDividerItemDecoration.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDividerItemDecoration.kt deleted file mode 100644 index 0a66f401ba..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDividerItemDecoration.kt +++ /dev/null @@ -1,59 +0,0 @@ -package eu.kanade.tachiyomi.ui.manga.chapter - -import android.content.Context -import android.graphics.Canvas -import android.graphics.Rect -import android.graphics.drawable.Drawable -import android.view.View -import androidx.core.view.forEach -import androidx.core.view.marginBottom -import androidx.recyclerview.widget.RecyclerView - -/** - * Mimics a DividerItemDecoration that doesn't draw between the first two items. - * - * Used in MangaController since the manga info header and chapters header are the first two - * items in the list using a ConcatAdapter. - */ -class ChapterDividerItemDecoration(context: Context) : RecyclerView.ItemDecoration() { - - private val divider: Drawable - - init { - val a = context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider)) - divider = a.getDrawable(0)!! - a.recycle() - } - - override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) { - if (parent.layoutManager == null) { - return - } - - canvas.save() - parent.forEach { - val top = it.bottom + it.marginBottom - val bottom = top + divider.intrinsicHeight - val left = parent.paddingStart - val right = parent.width - parent.paddingEnd - divider.setBounds(left, top, right, bottom) - divider.draw(canvas) - } - canvas.restore() - } - - override fun getItemOffsets( - outRect: Rect, - view: View, - parent: RecyclerView, - state: RecyclerView.State - ) { - val position = parent.getChildAdapterPosition(view) - - if (position == 0) { - outRect.setEmpty() - } else { - outRect.set(0, 0, 0, divider.intrinsicHeight) - } - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index 0b113f1341..4e69be6287 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -8,7 +8,6 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.view.ActionMode -import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.SelectableAdapter @@ -89,7 +88,6 @@ class UpdatesController : // Init RecyclerView and adapter val layoutManager = LinearLayoutManager(view.context) binding.recycler.layoutManager = layoutManager - binding.recycler.addItemDecoration(DividerItemDecoration(view.context, DividerItemDecoration.VERTICAL)) binding.recycler.setHasFixedSize(true) adapter = UpdatesAdapter(this@UpdatesController) binding.recycler.adapter = adapter