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
diff --git a/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt b/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt
index 65c270a..ab5ba54 100644
--- a/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt
+++ b/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt
@@ -87,6 +87,14 @@
         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 @@
 
     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)