LTR support on recycler item dividers

This commit is contained in:
Jay 2020-04-26 01:16:19 -04:00
parent d47a8c6ed9
commit cd7e4efa5e
3 changed files with 14 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import android.graphics.Rect
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.view.View import android.view.View
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.isLTR
class ExtensionDividerItemDecoration(context: Context) : androidx.recyclerview.widget.RecyclerView.ItemDecoration() { class ExtensionDividerItemDecoration(context: Context) : androidx.recyclerview.widget.RecyclerView.ItemDecoration() {
@ -27,8 +28,9 @@ class ExtensionDividerItemDecoration(context: Context) : androidx.recyclerview.w
val params = child.layoutParams as androidx.recyclerview.widget.RecyclerView.LayoutParams val params = child.layoutParams as androidx.recyclerview.widget.RecyclerView.LayoutParams
val top = child.bottom + params.bottomMargin val top = child.bottom + params.bottomMargin
val bottom = top + divider.intrinsicHeight val bottom = top + divider.intrinsicHeight
val left = parent.paddingStart + 12.dpToPx val left = parent.paddingStart + if (parent.context.resources.isLTR) 12.dpToPx else 0
val right = parent.width - parent.paddingEnd val right =
parent.width - parent.paddingEnd - if (!parent.context.resources.isLTR) 12.dpToPx else 0
divider.setBounds(left, top, right, bottom) divider.setBounds(left, top, right, bottom)
divider.draw(c) divider.draw(c)

View File

@ -6,6 +6,7 @@ import android.graphics.Rect
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.view.View import android.view.View
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.isLTR
class MangaDetailsDivider(context: Context) : androidx.recyclerview.widget.RecyclerView.ItemDecoration() { class MangaDetailsDivider(context: Context) : androidx.recyclerview.widget.RecyclerView.ItemDecoration() {
@ -29,8 +30,9 @@ class MangaDetailsDivider(context: Context) : androidx.recyclerview.widget.Recyc
child.layoutParams as androidx.recyclerview.widget.RecyclerView.LayoutParams child.layoutParams as androidx.recyclerview.widget.RecyclerView.LayoutParams
val top = child.bottom + params.bottomMargin val top = child.bottom + params.bottomMargin
val bottom = top + divider.intrinsicHeight val bottom = top + divider.intrinsicHeight
val left = parent.paddingStart + 12.dpToPx val left = parent.paddingStart + if (parent.context.resources.isLTR) 12.dpToPx else 0
val right = parent.width - parent.paddingEnd val right =
parent.width - parent.paddingEnd - if (!parent.context.resources.isLTR) 12.dpToPx else 0
divider.setBounds(left, top, right, bottom) divider.setBounds(left, top, right, bottom)
divider.draw(c) divider.draw(c)

View File

@ -6,6 +6,7 @@ import android.graphics.Rect
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.view.View import android.view.View
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.isLTR
class RecentMangaDivider(context: Context) : androidx.recyclerview.widget.RecyclerView.ItemDecoration() { class RecentMangaDivider(context: Context) : androidx.recyclerview.widget.RecyclerView.ItemDecoration() {
@ -25,11 +26,13 @@ class RecentMangaDivider(context: Context) : androidx.recyclerview.widget.Recycl
if (holder is RecentMangaHolder && if (holder is RecentMangaHolder &&
parent.getChildViewHolder(parent.getChildAt(i + 1)) is RecentMangaHolder parent.getChildViewHolder(parent.getChildAt(i + 1)) is RecentMangaHolder
) { ) {
val params = child.layoutParams as androidx.recyclerview.widget.RecyclerView.LayoutParams val params =
child.layoutParams as androidx.recyclerview.widget.RecyclerView.LayoutParams
val top = child.bottom + params.bottomMargin val top = child.bottom + params.bottomMargin
val bottom = top + divider.intrinsicHeight val bottom = top + divider.intrinsicHeight
val left = parent.paddingStart + 12.dpToPx val left = parent.paddingStart + if (parent.context.resources.isLTR) 12.dpToPx else 0
val right = parent.width - parent.paddingEnd val right =
parent.width - parent.paddingEnd - if (!parent.context.resources.isLTR) 12.dpToPx else 0
divider.setBounds(left, top, right, bottom) divider.setBounds(left, top, right, bottom)
divider.draw(c) divider.draw(c)