Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a8d4f51 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Move updating layoutParams outside of dispatchDraw()

* LayoutParams are more single states and don't need to
be updated on each cycle of drawing
* Curious if this might also fix b/323128163

Fixes: 323128163
Test: Used logging, no more infinite calls to dispatchDraw()
Flag: None
Change-Id: Ic7211b26a7365e3fbbeef3768e4d6d9254e14ee7
parent 4638d4c8
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -87,6 +87,14 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr
        appPairBackground = AppPairIconBackground(context, this)
        appPairBackground.setBounds(0, 0, backgroundSize.toInt(), backgroundSize.toInt())
        applyIcons(parentIcon.info.contents)

        // Center the drawable area in the larger icon canvas
        val lp: LayoutParams = layoutParams as LayoutParams
        lp.gravity = Gravity.CENTER_HORIZONTAL
        lp.topMargin = outerPadding.toInt()
        lp.height = backgroundSize.toInt()
        lp.width = backgroundSize.toInt()
        layoutParams = lp
    }

    /** Sets up app pair member icons for drawing. */
@@ -125,15 +133,6 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr

    override fun dispatchDraw(canvas: Canvas) {
        super.dispatchDraw(canvas)

        // Center the drawable area in the larger icon canvas
        val lp: LayoutParams = layoutParams as LayoutParams
        lp.gravity = Gravity.CENTER_HORIZONTAL
        lp.topMargin = outerPadding.toInt()
        lp.height = backgroundSize.toInt()
        lp.width = backgroundSize.toInt()
        layoutParams = lp

        // Draw background
        appPairBackground.draw(canvas)