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

Commit d03aa92e authored by Xiaowen Lei's avatar Xiaowen Lei
Browse files

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
parent 700595a1
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -89,6 +89,7 @@ public class SmartSpaceComplication implements Complication {
    }
    }


    private static class SmartSpaceComplicationViewHolder implements ViewHolder {
    private static class SmartSpaceComplicationViewHolder implements ViewHolder {
        private View mView = null;
        private static final int SMARTSPACE_COMPLICATION_WEIGHT = 10;
        private static final int SMARTSPACE_COMPLICATION_WEIGHT = 10;
        private final DreamSmartspaceController mSmartSpaceController;
        private final DreamSmartspaceController mSmartSpaceController;
        private final Context mContext;
        private final Context mContext;
@@ -102,12 +103,16 @@ public class SmartSpaceComplication implements Complication {


        @Override
        @Override
        public View getView() {
        public View getView() {
            if (mView != null) {
                return mView;
            }
            final FrameLayout smartSpaceContainer = new FrameLayout(mContext);
            final FrameLayout smartSpaceContainer = new FrameLayout(mContext);
            smartSpaceContainer.addView(
            smartSpaceContainer.addView(
                    mSmartSpaceController.buildAndConnectView(smartSpaceContainer),
                    mSmartSpaceController.buildAndConnectView(smartSpaceContainer),
                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.WRAP_CONTENT));
                            ViewGroup.LayoutParams.WRAP_CONTENT));


            mView = smartSpaceContainer;
            return smartSpaceContainer;
            return smartSpaceContainer;
        }
        }


+1 −1
Original line number Original line Diff line number Diff line
@@ -44,7 +44,7 @@ import javax.inject.Named;
 * a {@link ComplicationLayoutEngine}.
 * a {@link ComplicationLayoutEngine}.
 */
 */
public class ComplicationHostViewController extends ViewController<ConstraintLayout> {
public class ComplicationHostViewController extends ViewController<ConstraintLayout> {
    public static final String TAG = "ComplicationHostViewController";
    public static final String TAG = "ComplicationHostVwCtrl";


    private final ComplicationLayoutEngine mLayoutEngine;
    private final ComplicationLayoutEngine mLayoutEngine;
    private final LifecycleOwner mLifecycleOwner;
    private final LifecycleOwner mLifecycleOwner;