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

Commit dbcc63ed authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing some autoboxing during property animation

Change-Id: Ibd6f20c565a4d66dc6d606b3f0bbc96fec66fe56
parent add17009
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.launcher3.appprediction;

import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherState.ALL_APPS;

import android.annotation.TargetApi;
@@ -291,7 +292,7 @@ public class AppsDividerView extends View implements LauncherStateManager.StateL
    public void setContentVisibility(boolean hasHeaderExtra, boolean hasAllAppsContent,
            PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade) {
        // Don't use setViewAlpha as we want to control the visibility ourselves.
        setter.setFloat(this, ALPHA, hasAllAppsContent ? 1 : 0, allAppsFade);
        setter.setFloat(this, VIEW_ALPHA, hasAllAppsContent ? 1 : 0, allAppsFade);
    }

    @Override
+5 −5
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.quickstep.views;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Property;
import android.util.FloatProperty;
import android.widget.Button;

import com.android.launcher3.touch.PagedOrientationHandler;
@@ -27,16 +27,16 @@ import com.android.quickstep.views.RecentsView.ScrollState;

public class ClearAllButton extends Button implements PageCallbacks {

    public static final Property<ClearAllButton, Float> VISIBILITY_ALPHA =
            new Property<ClearAllButton, Float>(Float.class, "visibilityAlpha") {
    public static final FloatProperty<ClearAllButton> VISIBILITY_ALPHA =
            new FloatProperty<ClearAllButton>("visibilityAlpha") {
                @Override
                public Float get(ClearAllButton view) {
                    return view.mVisibilityAlpha;
                }

                @Override
                public void set(ClearAllButton view, Float visibilityAlpha) {
                    view.setVisibilityAlpha(visibilityAlpha);
                public void setValue(ClearAllButton view, float v) {
                    view.setVisibilityAlpha(v);
                }
            };

+7 −4
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCRIM_FADE;
@@ -116,8 +119,8 @@ public abstract class BaseRecentsViewStateController<T extends View>
        if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
            translationX = -translationX;
        }
        setter.setFloat(mRecentsView, View.TRANSLATION_X, translationX, translateXInterpolator);
        setter.setFloat(mRecentsView, View.TRANSLATION_Y, scaleAndTranslation.translationY,
        setter.setFloat(mRecentsView, VIEW_TRANSLATE_X, translationX, translateXInterpolator);
        setter.setFloat(mRecentsView, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY,
                translateYInterpolator);
        setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0,
                builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
@@ -125,8 +128,8 @@ public abstract class BaseRecentsViewStateController<T extends View>
        setter.setFloat(scrim, SCRIM_PROGRESS, toState.getOverviewScrimAlpha(mLauncher),
                builder.getInterpolator(ANIM_OVERVIEW_SCRIM_FADE, LINEAR));
        if (mActionsView != null) {
            setter.setFloat(mActionsView, View.TRANSLATION_X, translationX, translateXInterpolator);
            setter.setFloat(mActionsView, View.ALPHA, toState.overviewUi ? 1 : 0,
            setter.setFloat(mActionsView, VIEW_TRANSLATE_X, translationX, translateXInterpolator);
            setter.setFloat(mActionsView, VIEW_ALPHA, toState.overviewUi ? 1 : 0,
                    builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
        }
    }
+24 −10
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.launcher3;

import android.graphics.drawable.Drawable;
import android.util.FloatProperty;
import android.util.Property;
import android.util.IntProperty;
import android.view.View;
import android.view.ViewGroup.LayoutParams;

@@ -32,15 +32,15 @@ public class LauncherAnimUtils {
    // The progress of an animation to all apps must be at least this far along to snap to all apps.
    public static final float MIN_PROGRESS_TO_ALL_APPS = 0.5f;

    public static final Property<Drawable, Integer> DRAWABLE_ALPHA =
            new Property<Drawable, Integer>(Integer.TYPE, "drawableAlpha") {
    public static final IntProperty<Drawable> DRAWABLE_ALPHA =
            new IntProperty<Drawable>("drawableAlpha") {
                @Override
                public Integer get(Drawable drawable) {
                    return drawable.getAlpha();
                }

                @Override
                public void set(Drawable drawable, Integer alpha) {
                public void setValue(Drawable drawable, int alpha) {
                    drawable.setAlpha(alpha);
                }
            };
@@ -64,28 +64,28 @@ public class LauncherAnimUtils {
        return (int) Utilities.boundToRange(Math.abs(velocity) / 2, 2f, 6f);
    }

    public static final Property<LayoutParams, Integer> LAYOUT_WIDTH =
            new Property<LayoutParams, Integer>(Integer.TYPE, "width") {
    public static final IntProperty<LayoutParams> LAYOUT_WIDTH =
            new IntProperty<LayoutParams>("width") {
                @Override
                public Integer get(LayoutParams lp) {
                    return lp.width;
                }

                @Override
                public void set(LayoutParams lp, Integer width) {
                public void setValue(LayoutParams lp, int width) {
                    lp.width = width;
                }
            };

    public static final Property<LayoutParams, Integer> LAYOUT_HEIGHT =
            new Property<LayoutParams, Integer>(Integer.TYPE, "height") {
    public static final IntProperty<LayoutParams> LAYOUT_HEIGHT =
            new IntProperty<LayoutParams>("height") {
                @Override
                public Integer get(LayoutParams lp) {
                    return lp.height;
                }

                @Override
                public void set(LayoutParams lp, Integer height) {
                public void setValue(LayoutParams lp, int height) {
                    lp.height = height;
                }
            };
@@ -117,4 +117,18 @@ public class LauncherAnimUtils {
                            return view.getTranslationY();
                        }
                    };

    public static final FloatProperty<View> VIEW_ALPHA =
            View.ALPHA instanceof FloatProperty ? (FloatProperty) View.ALPHA
                    : new FloatProperty<View>("alpha") {
                        @Override
                        public void setValue(View view, float v) {
                            view.setAlpha(v);
                        }

                        @Override
                        public Float get(View view) {
                            return view.getAlpha();
                        }
                    };
}
+9 −6
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ package com.android.launcher3;

import static com.android.launcher3.LauncherAnimUtils.DRAWABLE_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_HOTSEAT_SCALE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_HOTSEAT_TRANSLATE;
@@ -125,18 +128,18 @@ public class WorkspaceStateTransitionAnimation {
        Interpolator translationInterpolator = !playAtomicComponent
                ? LINEAR
                : builder.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
        propertySetter.setFloat(mWorkspace, View.TRANSLATION_X,
        propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_X,
                scaleAndTranslation.translationX, translationInterpolator);
        propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
        propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y,
                scaleAndTranslation.translationY, translationInterpolator);

        Interpolator hotseatTranslationInterpolator = builder.getInterpolator(
                ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
        propertySetter.setFloat(hotseat, View.TRANSLATION_Y,
        propertySetter.setFloat(hotseat, VIEW_TRANSLATE_Y,
                hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
        propertySetter.setFloat(mWorkspace.getPageIndicator(), View.TRANSLATION_Y,
        propertySetter.setFloat(mWorkspace.getPageIndicator(), VIEW_TRANSLATE_Y,
                hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
        propertySetter.setFloat(qsbView, View.TRANSLATION_Y,
        propertySetter.setFloat(qsbView, VIEW_TRANSLATE_Y,
                qsbScaleAndTranslation.translationY, hotseatTranslationInterpolator);

        setScrim(propertySetter, state);
@@ -179,7 +182,7 @@ public class WorkspaceStateTransitionAnimation {
        if (config.playAtomicOverviewScaleComponent()) {
            Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE,
                    pageAlphaProvider.interpolator);
            propertySetter.setFloat(cl.getShortcutsAndWidgets(), View.ALPHA,
            propertySetter.setFloat(cl.getShortcutsAndWidgets(), VIEW_ALPHA,
                    pageAlpha, fadeInterpolator);
        }
    }
Loading