From d03aa92e0ac24cfb0a71cf8f8bbdbc6d302c0050 Mon Sep 17 00:00:00 2001 From: Xiaowen Lei Date: Mon, 13 Jun 2022 16:59:52 +0000 Subject: [PATCH] Avoid recreating views in SmartSpaceComplicationViewHolder. Also fixed the length of ComplicationHostViewController.TAG (30 -> 23). Note: we'll still get multiple instances of the same type of view, when updateComplications is called multiple times. Bug: 231251252 Bug: 235625099 Test: on device via added logging Change-Id: Ia80650dea1cdac7b19b34034b8dc41916134cace --- .../com/android/systemui/dreams/SmartSpaceComplication.java | 5 +++++ .../dreams/complication/ComplicationHostViewController.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/dreams/SmartSpaceComplication.java b/packages/SystemUI/src/com/android/systemui/dreams/SmartSpaceComplication.java index 7666eb84acac0..486fc893732ff 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/SmartSpaceComplication.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/SmartSpaceComplication.java @@ -89,6 +89,7 @@ public class SmartSpaceComplication implements Complication { } private static class SmartSpaceComplicationViewHolder implements ViewHolder { + private View mView = null; private static final int SMARTSPACE_COMPLICATION_WEIGHT = 10; private final DreamSmartspaceController mSmartSpaceController; private final Context mContext; @@ -102,12 +103,16 @@ public class SmartSpaceComplication implements Complication { @Override public View getView() { + if (mView != null) { + return mView; + } final FrameLayout smartSpaceContainer = new FrameLayout(mContext); smartSpaceContainer.addView( mSmartSpaceController.buildAndConnectView(smartSpaceContainer), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + mView = smartSpaceContainer; return smartSpaceContainer; } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java index 4c0154faeb5a4..c1173aea8b15a 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java @@ -44,7 +44,7 @@ import javax.inject.Named; * a {@link ComplicationLayoutEngine}. */ public class ComplicationHostViewController extends ViewController { - public static final String TAG = "ComplicationHostViewController"; + public static final String TAG = "ComplicationHostVwCtrl"; private final ComplicationLayoutEngine mLayoutEngine; private final LifecycleOwner mLifecycleOwner;