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

Commit 5ff99b87 authored by Jared Duke's avatar Jared Duke Committed by Android (Google) Code Review
Browse files

Merge "Avoid reflection with ObjectAnimator"

parents 15ceb0bb 912b87ab
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.os.SystemClock;
import android.util.FloatProperty;
import android.util.Log;
import android.view.MotionEvent;
import android.view.Surface;
@@ -46,6 +47,20 @@ final class DeadZone {
    public static final int VERTICAL = 1;  // Consume taps along the left edge.

    private static final boolean CHATTY = true; // print to logcat when we eat a click

    private static final FloatProperty<DeadZone> FLASH_PROPERTY =
            new FloatProperty<DeadZone>("DeadZoneFlash") {
        @Override
        public void setValue(DeadZone object, float value) {
            object.setFlash(value);
        }

        @Override
        public Float get(DeadZone object) {
            return object.getFlash();
        }
    };

    private final NavigationBarView mNavigationBarView;

    private boolean mShouldFlash;
@@ -63,7 +78,7 @@ final class DeadZone {
    private final Runnable mDebugFlash = new Runnable() {
        @Override
        public void run() {
            ObjectAnimator.ofFloat(DeadZone.this, "flash", 1f, 0f).setDuration(150).start();
            ObjectAnimator.ofFloat(DeadZone.this, FLASH_PROPERTY, 1f, 0f).setDuration(150).start();
        }
    };

+16 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.util.FloatProperty;
import android.util.Log;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
@@ -69,6 +70,19 @@ public class ExpandHelper implements Gefingerpoken {
    // 2f: maximum brightness is stretching a 1U to 3U, or a 4U to 6U
    private static final float STRETCH_INTERVAL = 2f;

    private static final FloatProperty<ViewScaler> VIEW_SCALER_HEIGHT_PROPERTY =
            new FloatProperty<ViewScaler>("ViewScalerHeight") {
        @Override
        public void setValue(ViewScaler object, float value) {
            object.setHeight(value);
        }

        @Override
        public Float get(ViewScaler object) {
            return object.getHeight();
        }
    };

    @SuppressWarnings("unused")
    private Context mContext;

@@ -147,6 +161,7 @@ public class ExpandHelper implements Gefingerpoken {
        public void setView(ExpandableView v) {
            mView = v;
        }

        public void setHeight(float h) {
            if (DEBUG_SCALE) Log.v(TAG, "SetHeight: setting to " + h);
            mView.setActualHeight((int) h);
@@ -176,7 +191,7 @@ public class ExpandHelper implements Gefingerpoken {
        mCallback = callback;
        mScaler = new ViewScaler();
        mGravity = Gravity.TOP;
        mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f);
        mScaleAnimation = ObjectAnimator.ofFloat(mScaler, VIEW_SCALER_HEIGHT_PROPERTY, 0f);
        mPullGestureMinXSpan = mContext.getResources().getDimension(R.dimen.pull_span_min);

        final ViewConfiguration configuration = ViewConfiguration.get(mContext);
+16 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.animation.ObjectAnimator;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.os.SystemClock;
import android.util.FloatProperty;
import android.util.Slog;
import android.view.MotionEvent;
import android.view.Surface;
@@ -44,6 +45,20 @@ public class DeadZone {
    public static final int VERTICAL = 1;  // Consume taps along the left edge.

    private static final boolean CHATTY = true; // print to logcat when we eat a click

    private static final FloatProperty<DeadZone> FLASH_PROPERTY =
            new FloatProperty<DeadZone>("DeadZoneFlash") {
        @Override
        public void setValue(DeadZone object, float value) {
            object.setFlash(value);
        }

        @Override
        public Float get(DeadZone object) {
            return object.getFlash();
        }
    };

    private final NavigationBarController mNavBarController;
    private final NavigationBarView mNavigationBarView;

@@ -63,7 +78,7 @@ public class DeadZone {
    private final Runnable mDebugFlash = new Runnable() {
        @Override
        public void run() {
            ObjectAnimator.ofFloat(DeadZone.this, "flash", 1f, 0f).setDuration(150).start();
            ObjectAnimator.ofFloat(DeadZone.this, FLASH_PROPERTY, 1f, 0f).setDuration(150).start();
        }
    };