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

Commit 8492edb1 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing new object creating during scroll/draw

Change-Id: I627832c1659ac332d0ea3279dffba9d3c71ec2af
parent 9662eb8d
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -813,23 +813,14 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        if (getPageCount() == 0 || getPageAt(0).getMeasuredWidth() == 0) {
            return;
        }
        CurveProperties curveProperties = mOrientationHandler
            .getCurveProperties(this, mInsets);
        int scroll = curveProperties.scroll;
        final int halfPageSize = curveProperties.halfPageSize;
        final int screenCenter = curveProperties.screenCenter;
        final int halfScreenSize = curveProperties.halfScreenSize;
        final int pageSpacing = mPageSpacing;
        mScrollState.scrollFromEdge = mIsRtl ? scroll : (mMaxScroll - scroll);
        mOrientationHandler.getCurveProperties(this, mInsets, mScrollState);
        mScrollState.scrollFromEdge =
                mIsRtl ? mScrollState.scroll : (mMaxScroll - mScrollState.scroll);

        final int pageCount = getPageCount();
        for (int i = 0; i < pageCount; i++) {
            View page = getPageAt(i);
            float pageCenter = mOrientationHandler.getViewCenterPosition(page) + halfPageSize;
            float distanceFromScreenCenter = screenCenter - pageCenter;
            float distanceToReachEdge = halfScreenSize + halfPageSize + pageSpacing;
            mScrollState.linearInterpolation = Math.min(1,
                    Math.abs(distanceFromScreenCenter) / distanceToReachEdge);
            mScrollState.updateInterpolation(mOrientationHandler.getChildStart(page), mPageSpacing);
            ((PageCallbacks) page).onPageScroll(mScrollState);
        }
    }
@@ -1201,7 +1192,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        default void onPageScroll(ScrollState scrollState) {}
    }

    public static class ScrollState {
    public static class ScrollState extends CurveProperties {

        /**
         * The progress from 0 to 1, where 0 is the center
@@ -1213,6 +1204,17 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
         * The amount by which all the content is scrolled relative to the end of the list.
         */
        public float scrollFromEdge;

        /**
         * Updates linearInterpolation for the provided child position
         */
        public void updateInterpolation(int childStart, int pageSpacing) {
            float pageCenter = childStart + halfPageSize;
            float distanceFromScreenCenter = screenCenter - pageCenter;
            float distanceToReachEdge = halfScreenSize + halfPageSize + pageSpacing;
            linearInterpolation = Math.min(1,
                    Math.abs(distanceFromScreenCenter) / distanceToReachEdge);
        }
    }

    public void setIgnoreResetTask(int taskId) {
+9 −12
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.launcher3.touch;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;

import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -32,13 +35,8 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.PagedView;
import com.android.launcher3.Utilities;
import com.android.launcher3.states.RotationHelper;
import com.android.launcher3.util.OverScroller;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;

public class LandscapePagedViewHandler implements PagedOrientationHandler {

    @Override
@@ -67,12 +65,11 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
    }

    @Override
    public CurveProperties getCurveProperties(PagedView pagedView, Rect mInsets) {
        int scroll = pagedView.getScrollY();
        final int halfPageSize = pagedView.getNormalChildHeight() / 2;
        final int screenCenter = mInsets.top + pagedView.getPaddingTop() + scroll + halfPageSize;
        final int halfScreenSize = pagedView.getMeasuredHeight() / 2;
        return new CurveProperties(scroll, halfPageSize, screenCenter, halfScreenSize);
    public void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out) {
        out.scroll = view.getScrollY();
        out.halfPageSize = view.getNormalChildHeight() / 2;
        out.halfScreenSize = view.getMeasuredHeight() / 2;
        out.screenCenter = mInsets.top + view.getPaddingTop() + out.scroll + out.halfPageSize;
    }

    @Override
+6 −12
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public interface PagedOrientationHandler {
    void delegateScrollTo(PagedView pagedView, int primaryScroll);
    void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y);
    void scrollerStartScroll(OverScroller scroller, int newPosition);
    CurveProperties getCurveProperties(PagedView pagedView, Rect insets);
    void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out);
    boolean isGoingUp(float displacement);

    /**
@@ -92,18 +92,12 @@ public interface PagedOrientationHandler {
     */
    void adjustFloatingIconStartVelocity(PointF velocity);

    class CurveProperties {
        public final int scroll;
        public final int halfPageSize;
        public final int screenCenter;
        public final int halfScreenSize;

        public CurveProperties(int scroll, int halfPageSize, int screenCenter, int halfScreenSize) {
            this.scroll = scroll;
            this.halfPageSize = halfPageSize;
            this.screenCenter = screenCenter;
            this.halfScreenSize = halfScreenSize;
        }
    class CurveProperties {
        public int scroll;
        public int halfPageSize;
        public int screenCenter;
        public int halfScreenSize;
    }

    class ChildBounds {
+9 −12
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.launcher3.touch;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;

import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -32,13 +35,8 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherState.ScaleAndTranslation;
import com.android.launcher3.PagedView;
import com.android.launcher3.Utilities;
import com.android.launcher3.states.RotationHelper;
import com.android.launcher3.util.OverScroller;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;

public class PortraitPagedViewHandler implements PagedOrientationHandler {

    @Override
@@ -67,12 +65,11 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
    }

    @Override
    public CurveProperties getCurveProperties(PagedView pagedView, Rect mInsets) {
        int scroll = pagedView.getScrollX();
        final int halfPageSize = pagedView.getNormalChildWidth() / 2;
        final int screenCenter = mInsets.left + pagedView.getPaddingLeft() + scroll + halfPageSize;
        final int halfScreenSize = pagedView.getMeasuredWidth() / 2;
        return new CurveProperties(scroll, halfPageSize, screenCenter, halfScreenSize);
    public void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out) {
        out.scroll = view.getScrollX();
        out.halfPageSize = view.getNormalChildWidth() / 2;
        out.halfScreenSize = view.getMeasuredWidth() / 2;
        out.screenCenter = mInsets.left + view.getPaddingLeft() + out.scroll + out.halfPageSize;
    }

    @Override