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

Commit f50acd3e authored by Fedor Kudasov's avatar Fedor Kudasov
Browse files

Move FloatingTaskInit set up into init method

This makes the code more tidy and consistent with
other classes. Additionally, this allows for easier
annotation of the initialization code.

Bug: 205828770
Test: m LauncherGoResLib
Change-Id: Ib7ecf32cffd5c6af67a4c2095d7cb3e3a2f387e4
parent c62bc172
Loading
Loading
Loading
Loading
+27 −22
Original line number Diff line number Diff line
@@ -74,35 +74,40 @@ public class FloatingTaskView extends FrameLayout {
        mSplitPlaceholderView.setBackgroundColor(getResources().getColor(android.R.color.white));
    }

    public static FloatingTaskView getFloatingTaskView(StatefulActivity launcher,
            TaskView originalView, RectF positionOut) {
        final BaseDragLayer dragLayer = launcher.getDragLayer();
        ViewGroup parent = (ViewGroup) dragLayer.getParent();
        final FloatingTaskView floatingView = (FloatingTaskView) launcher.getLayoutInflater()
                .inflate(R.layout.floating_split_select_view, parent, false);

        floatingView.mStartingPosition = positionOut;
        floatingView.updateInitialPositionForView(originalView);
    private void init(StatefulActivity launcher, TaskView originalView, RectF positionOut) {
        mStartingPosition = positionOut;
        updateInitialPositionForView(originalView);
        final InsettableFrameLayout.LayoutParams lp =
                (InsettableFrameLayout.LayoutParams) floatingView.getLayoutParams();
                (InsettableFrameLayout.LayoutParams) getLayoutParams();

        floatingView.mSplitPlaceholderView.setLayoutParams(
                new FrameLayout.LayoutParams(lp.width, lp.height));
        positionOut.round(floatingView.mOutline);
        floatingView.setPivotX(0);
        floatingView.setPivotY(0);
        mSplitPlaceholderView.setLayoutParams(new FrameLayout.LayoutParams(lp.width, lp.height));
        positionOut.round(mOutline);
        setPivotX(0);
        setPivotY(0);

        // Copy bounds of exiting thumbnail into ImageView
        TaskThumbnailView thumbnail = originalView.getThumbnail();
        floatingView.mImageView.setImageBitmap(thumbnail.getThumbnail());
        floatingView.mImageView.setVisibility(VISIBLE);
        mImageView.setImageBitmap(thumbnail.getThumbnail());
        mImageView.setVisibility(VISIBLE);

        floatingView.mOrientationHandler =
                originalView.getRecentsView().getPagedOrientationHandler();
        floatingView.mSplitPlaceholderView.setIconView(originalView.getIconView(),
        mOrientationHandler = originalView.getRecentsView().getPagedOrientationHandler();
        mSplitPlaceholderView.setIconView(originalView.getIconView(),
                launcher.getDeviceProfile().overviewTaskIconDrawableSizePx);
        floatingView.mSplitPlaceholderView.getIconView()
                .setRotation(floatingView.mOrientationHandler.getDegreesRotated());
        mSplitPlaceholderView.getIconView().setRotation(mOrientationHandler.getDegreesRotated());
    }

    /**
     * Configures and returns a an instance of {@link FloatingTaskView} initially matching the
     * appearance of {@code originalView}.
     */
    public static FloatingTaskView getFloatingTaskView(StatefulActivity launcher,
            TaskView originalView, RectF positionOut) {
        final BaseDragLayer dragLayer = launcher.getDragLayer();
        ViewGroup parent = (ViewGroup) dragLayer.getParent();
        final FloatingTaskView floatingView = (FloatingTaskView) launcher.getLayoutInflater()
                .inflate(R.layout.floating_split_select_view, parent, false);

        floatingView.init(launcher, originalView, positionOut);
        parent.addView(floatingView);
        return floatingView;
    }