mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Use some more core-ktx extensions
This commit is contained in:
parent
9e51d82154
commit
dd66c83c50
@ -5,6 +5,7 @@ import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import androidx.core.view.marginBottom
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class ExtensionDividerItemDecoration(context: Context) : RecyclerView.ItemDecoration() {
|
||||
@ -25,8 +26,7 @@ class ExtensionDividerItemDecoration(context: Context) : RecyclerView.ItemDecora
|
||||
if (holder is ExtensionHolder &&
|
||||
parent.getChildViewHolder(parent.getChildAt(i + 1)) is ExtensionHolder
|
||||
) {
|
||||
val params = child.layoutParams as RecyclerView.LayoutParams
|
||||
val top = child.bottom + params.bottomMargin
|
||||
val top = child.bottom + child.marginBottom
|
||||
val bottom = top + divider.intrinsicHeight
|
||||
val left = parent.paddingStart + holder.margin
|
||||
val right = parent.width - parent.paddingEnd - holder.margin
|
||||
|
@ -5,6 +5,7 @@ import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import androidx.core.view.marginBottom
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class SourceDividerItemDecoration(context: Context) : RecyclerView.ItemDecoration() {
|
||||
@ -25,8 +26,7 @@ class SourceDividerItemDecoration(context: Context) : RecyclerView.ItemDecoratio
|
||||
if (holder is SourceHolder &&
|
||||
parent.getChildViewHolder(parent.getChildAt(i + 1)) is SourceHolder
|
||||
) {
|
||||
val params = child.layoutParams as RecyclerView.LayoutParams
|
||||
val top = child.bottom + params.bottomMargin
|
||||
val top = child.bottom + child.marginBottom
|
||||
val bottom = top + divider.intrinsicHeight
|
||||
val left = parent.paddingStart + holder.margin
|
||||
val right = parent.width - parent.paddingEnd - holder.margin
|
||||
|
@ -11,6 +11,7 @@ import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import com.bluelinelabs.conductor.Conductor
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
@ -393,11 +394,11 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
||||
}
|
||||
|
||||
// Ensure the snackbar sits above the bottom nav
|
||||
val layoutParams = view.layoutParams as CoordinatorLayout.LayoutParams
|
||||
layoutParams.anchorId = binding.bottomNav.id
|
||||
layoutParams.anchorGravity = Gravity.TOP
|
||||
layoutParams.gravity = Gravity.TOP
|
||||
view.layoutParams = layoutParams
|
||||
view.updateLayoutParams<CoordinatorLayout.LayoutParams> {
|
||||
anchorId = binding.bottomNav.id
|
||||
anchorGravity = Gravity.TOP
|
||||
gravity = Gravity.TOP
|
||||
}
|
||||
}
|
||||
|
||||
// Manually handle dismiss delay since Snackbar.LENGTH_LONG is a too short
|
||||
|
@ -5,6 +5,7 @@ import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import androidx.core.view.marginBottom
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
/**
|
||||
@ -32,8 +33,7 @@ class ChapterDividerItemDecoration(context: Context) : RecyclerView.ItemDecorati
|
||||
val childCount = parent.childCount
|
||||
for (i in 1 until childCount) {
|
||||
val child = parent.getChildAt(i)
|
||||
val params = child.layoutParams as RecyclerView.LayoutParams
|
||||
val top = child.bottom + params.bottomMargin
|
||||
val top = child.bottom + child.marginBottom
|
||||
val bottom = top + divider.intrinsicHeight
|
||||
val left = parent.paddingStart
|
||||
val right = parent.width - parent.paddingEnd
|
||||
|
Loading…
Reference in New Issue
Block a user