mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Add unread divider decoration to CFv2.
This commit is contained in:
committed by
Nicholas Tinsley
parent
2511ca17aa
commit
5731bf023a
@@ -1,6 +1,8 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import android.graphics.Canvas
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -71,3 +73,21 @@ fun View.getLifecycle(): Lifecycle? {
|
||||
ViewUtil.getActivityLifecycle(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun View.layoutIn(parent: View) {
|
||||
val widthSpec = View.MeasureSpec.makeMeasureSpec(parent.width, View.MeasureSpec.EXACTLY)
|
||||
val heightSpec = View.MeasureSpec.makeMeasureSpec(parent.height, View.MeasureSpec.UNSPECIFIED)
|
||||
val childWidth = ViewGroup.getChildMeasureSpec(widthSpec, parent.paddingLeft + parent.paddingRight, layoutParams.width)
|
||||
val childHeight = ViewGroup.getChildMeasureSpec(heightSpec, parent.paddingTop + parent.paddingBottom, layoutParams.height)
|
||||
measure(childWidth, childHeight)
|
||||
layout(0, 0, measuredWidth, measuredHeight)
|
||||
}
|
||||
|
||||
fun View.drawAsItemDecoration(canvas: Canvas, parent: View, child: View) {
|
||||
canvas.save()
|
||||
val left = parent.left
|
||||
val top = child.y.toInt() - height
|
||||
canvas.translate(left.toFloat(), top.toFloat())
|
||||
draw(canvas)
|
||||
canvas.restore()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user