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

Commit 276fb35b authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Avoiding new view creation and additional layout during app launch

Change-Id: Ia9589b70bcdc64a2174b52aabaa1ab392800a081
parent 238f324e
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -443,7 +443,16 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
    private void playIconAnimators(AnimatorSet appOpenAnimator, View v, Rect windowTargetBounds,
            boolean toggleVisibility) {
        final boolean isBubbleTextView = v instanceof BubbleTextView;
        if (mFloatingView == null) {
            mFloatingView = new View(mLauncher);
        } else {
            mFloatingView.setTranslationX(0);
            mFloatingView.setTranslationY(0);
            mFloatingView.setScaleX(1);
            mFloatingView.setScaleY(1);
            mFloatingView.setAlpha(1);
            mFloatingView.setBackground(null);
        }
        if (isBubbleTextView && v.getTag() instanceof ItemInfoWithIcon ) {
            // Create a copy of the app icon
            mFloatingView.setBackground(DrawableFactory.INSTANCE.get(mLauncher)
@@ -481,19 +490,17 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
                : viewLocationLeft;
        LayoutParams lp = new LayoutParams(rect.width(), rect.height());
        lp.ignoreInsets = true;
        lp.setMarginStart(viewLocationStart);
        lp.leftMargin = viewLocationStart;
        lp.topMargin = viewLocationTop;
        mFloatingView.setLayoutParams(lp);

        // Set the properties here already to make sure they'are available when running the first
        // animation frame.
        mFloatingView.setLeft(viewLocationLeft);
        mFloatingView.setTop(viewLocationTop);
        mFloatingView.setRight(viewLocationLeft + rect.width());
        mFloatingView.setBottom(viewLocationTop + rect.height());
        mFloatingView.layout(viewLocationLeft, viewLocationTop,
                viewLocationLeft + rect.width(), viewLocationTop + rect.height());

        // Swap the two views in place.
        ((ViewGroup) mDragLayer.getParent()).addView(mFloatingView);
        ((ViewGroup) mDragLayer.getParent()).getOverlay().add(mFloatingView);
        if (toggleVisibility) {
            v.setVisibility(View.INVISIBLE);
        }
@@ -562,7 +569,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
                    ((BubbleTextView) v).setStayPressed(false);
                }
                v.setVisibility(View.VISIBLE);
                ((ViewGroup) mDragLayer.getParent()).removeView(mFloatingView);
                ((ViewGroup) mDragLayer.getParent()).getOverlay().remove(mFloatingView);
            }
        });
    }