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

Commit 2c0f9885 authored by George Mount's avatar George Mount
Browse files

Simplify KeyframeSet to avoid caching.

Bug 27367940


Change-Id: I76426def5d4b46c0a0ba534fd952f6c41725c74a
parent e4a5c47f
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -31,11 +31,6 @@ import java.util.List;
 * Object equivalents of these primitive types.</p>
 */
class FloatKeyframeSet extends KeyframeSet implements Keyframes.FloatKeyframes {
    private float firstValue;
    private float lastValue;
    private float deltaValue;
    private boolean firstTime = true;

    public FloatKeyframeSet(FloatKeyframe... keyframes) {
        super(keyframes);
    }
@@ -57,29 +52,8 @@ class FloatKeyframeSet extends KeyframeSet implements Keyframes.FloatKeyframes {
        return newSet;
    }

    @Override
    public void invalidateCache() {
        firstTime = true;
    }

    @Override
    public float getFloatValue(float fraction) {
        if (mNumKeyframes == 2) {
            if (firstTime) {
                firstTime = false;
                firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue();
                lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue();
                deltaValue = lastValue - firstValue;
            }
            if (mInterpolator != null) {
                fraction = mInterpolator.getInterpolation(fraction);
            }
            if (mEvaluator == null) {
                return firstValue + fraction * deltaValue;
            } else {
                return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue();
            }
        }
        if (fraction <= 0f) {
            final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0);
            final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1);
+0 −26
Original line number Diff line number Diff line
@@ -31,11 +31,6 @@ import java.util.List;
 * Object equivalents of these primitive types.</p>
 */
class IntKeyframeSet extends KeyframeSet implements Keyframes.IntKeyframes {
    private int firstValue;
    private int lastValue;
    private int deltaValue;
    private boolean firstTime = true;

    public IntKeyframeSet(IntKeyframe... keyframes) {
        super(keyframes);
    }
@@ -57,29 +52,8 @@ class IntKeyframeSet extends KeyframeSet implements Keyframes.IntKeyframes {
        return newSet;
    }

    @Override
    public void invalidateCache() {
        firstTime = true;
    }

    @Override
    public int getIntValue(float fraction) {
        if (mNumKeyframes == 2) {
            if (firstTime) {
                firstTime = false;
                firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue();
                lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue();
                deltaValue = lastValue - firstValue;
            }
            if (mInterpolator != null) {
                fraction = mInterpolator.getInterpolation(fraction);
            }
            if (mEvaluator == null) {
                return firstValue + (int)(fraction * deltaValue);
            } else {
                return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue();
            }
        }
        if (fraction <= 0f) {
            final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0);
            final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1);
+0 −8
Original line number Diff line number Diff line
@@ -51,14 +51,6 @@ public class KeyframeSet implements Keyframes {
        mInterpolator = mLastKeyframe.getInterpolator();
    }

    /**
     * If subclass has variables that it calculates based on the Keyframes, it should reset them
     * when this method is called because Keyframe contents might have changed.
     */
    @Override
    public void invalidateCache() {
    }

    public List<Keyframe> getKeyframes() {
        return mKeyframes;
    }
+0 −6
Original line number Diff line number Diff line
@@ -53,12 +53,6 @@ public interface Keyframes extends Cloneable {
     */
    Object getValue(float fraction);

    /**
     * If subclass has variables that it calculates based on the Keyframes, it should reset them
     * when this method is called because Keyframe contents might have changed.
     */
    void invalidateCache();

    /**
     * @return A list of all Keyframes contained by this. This may return null if this is
     * not made up of Keyframes.
+0 −8
Original line number Diff line number Diff line
@@ -117,10 +117,6 @@ public class PathKeyframes implements Keyframes {
        return mTempPointF;
    }

    @Override
    public void invalidateCache() {
    }

    @Override
    public void setEvaluator(TypeEvaluator evaluator) {
    }
@@ -213,10 +209,6 @@ public class PathKeyframes implements Keyframes {
        public void setEvaluator(TypeEvaluator evaluator) {
        }

        @Override
        public void invalidateCache() {
        }

        @Override
        public ArrayList<Keyframe> getKeyframes() {
            return EMPTY_KEYFRAMES;
Loading