Loading api/current.xml +286 −2 Original line number Diff line number Diff line Loading @@ -1361,6 +1361,39 @@ visibility="public" > </field> <field name="anticipate_interpolator" type="int" transient="false" volatile="false" value="17432583" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="anticipate_overshoot_interpolator" type="int" transient="false" volatile="false" value="17432585" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="bounce_interpolator" type="int" transient="false" volatile="false" value="17432586" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="decelerate_interpolator" type="int" transient="false" Loading Loading @@ -1394,6 +1427,17 @@ visibility="public" > </field> <field name="overshoot_interpolator" type="int" transient="false" volatile="false" value="17432584" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="slide_in_left" type="int" transient="false" Loading Loading @@ -1520,7 +1564,7 @@ type="int" transient="false" volatile="false" value="16843376" value="16843378" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -3155,6 +3199,17 @@ visibility="public" > </field> <field name="extraTension" type="int" transient="false" volatile="false" value="16843377" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="factor" type="int" transient="false" Loading Loading @@ -7170,6 +7225,17 @@ visibility="public" > </field> <field name="tension" type="int" transient="false" volatile="false" value="16843376" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="text" type="int" transient="false" Loading Loading @@ -60459,7 +60525,7 @@ type="float" transient="false" volatile="false" value="0.001f" value="0.0010f" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -136545,6 +136611,170 @@ </parameter> </method> </class> <class name="AnticipateInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="AnticipateInterpolator" type="android.view.animation.AnticipateInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="AnticipateInterpolator" type="android.view.animation.AnticipateInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> </constructor> <constructor name="AnticipateInterpolator" type="android.view.animation.AnticipateInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="AnticipateOvershootInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> </constructor> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> <parameter name="extraTension" type="float"> </parameter> </constructor> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="BounceInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="BounceInterpolator" type="android.view.animation.BounceInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="BounceInterpolator" type="android.view.animation.BounceInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="CycleInterpolator" extends="java.lang.Object" abstract="false" Loading Loading @@ -137348,6 +137578,60 @@ </parameter> </method> </class> <class name="OvershootInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="OvershootInterpolator" type="android.view.animation.OvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="OvershootInterpolator" type="android.view.animation.OvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> </constructor> <constructor name="OvershootInterpolator" type="android.view.animation.OvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="RotateAnimation" extends="android.view.animation.Animation" abstract="false" core/java/android/view/animation/AccelerateDecelerateInterpolator.java +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ public class AccelerateDecelerateInterpolator implements Interpolator { public AccelerateDecelerateInterpolator() { } @SuppressWarnings({"UnusedDeclaration"}) public AccelerateDecelerateInterpolator(Context context, AttributeSet attrs) { } Loading core/java/android/view/animation/AccelerateInterpolator.java +10 −5 Original line number Diff line number Diff line Loading @@ -26,7 +26,12 @@ import android.util.AttributeSet; * */ public class AccelerateInterpolator implements Interpolator { private final float mFactor; private final double mDoubleFactor; public AccelerateInterpolator() { mFactor = 1.0f; mDoubleFactor = 2.0; } /** Loading @@ -39,6 +44,7 @@ public class AccelerateInterpolator implements Interpolator { */ public AccelerateInterpolator(float factor) { mFactor = factor; mDoubleFactor = 2 * mFactor; } public AccelerateInterpolator(Context context, AttributeSet attrs) { Loading @@ -46,17 +52,16 @@ public class AccelerateInterpolator implements Interpolator { context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AccelerateInterpolator); mFactor = a.getFloat(com.android.internal.R.styleable.AccelerateInterpolator_factor, 1.0f); mDoubleFactor = 2 * mFactor; a.recycle(); } public float getInterpolation(float input) { if (mFactor == 1.0f) { return (float)(input * input); return input * input; } else { return (float)Math.pow(input, 2 * mFactor); return (float)Math.pow(input, mDoubleFactor); } } private float mFactor = 1.0f; } core/java/android/view/animation/AnimationUtils.java +40 −49 Original line number Diff line number Diff line Loading @@ -63,15 +63,13 @@ public class AnimationUtils { parser = context.getResources().getAnimation(id); return createAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { Loading @@ -81,16 +79,17 @@ public class AnimationUtils { private static Animation createAnimationFromXml(Context c, XmlPullParser parser) throws XmlPullParserException, IOException { return createAnimationFromXml(c, parser, null, Xml.asAttributeSet(parser)); } private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException { private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException { Animation anim = null; // Make sure we are on a start tag. int type = parser.getEventType(); int type; int depth = parser.getDepth(); while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) Loading Loading @@ -126,22 +125,20 @@ public class AnimationUtils { } public static LayoutAnimationController loadLayoutAnimation( Context context, int id) throws NotFoundException { public static LayoutAnimationController loadLayoutAnimation(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createLayoutAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; Loading @@ -150,24 +147,21 @@ public class AnimationUtils { } } private static LayoutAnimationController createLayoutAnimationFromXml( Context c, XmlPullParser parser) throws XmlPullParserException, IOException { return createLayoutAnimationFromXml(c, parser, Xml.asAttributeSet(parser)); private static LayoutAnimationController createLayoutAnimationFromXml(Context c, XmlPullParser parser) throws XmlPullParserException, IOException { return createLayoutAnimationFromXml(c, parser, Xml.asAttributeSet(parser)); } private static LayoutAnimationController createLayoutAnimationFromXml( Context c, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { private static LayoutAnimationController createLayoutAnimationFromXml(Context c, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { LayoutAnimationController controller = null; int type; int depth = parser.getDepth(); while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { if (type != XmlPullParser.START_TAG) { Loading @@ -181,8 +175,7 @@ public class AnimationUtils { } else if ("gridLayoutAnimation".equals(name)) { controller = new GridLayoutAnimationController(c, attrs); } else { throw new RuntimeException("Unknown layout animation name: " + name); throw new RuntimeException("Unknown layout animation name: " + name); } } Loading @@ -197,9 +190,7 @@ public class AnimationUtils { * @param fromLeft is the object to be animated coming from the left * @return The new animation */ public static Animation makeInAnimation(Context c, boolean fromLeft) { public static Animation makeInAnimation(Context c, boolean fromLeft) { Animation a; if (fromLeft) { a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_left); Loading @@ -220,9 +211,7 @@ public class AnimationUtils { * @param toRight is the object to be animated exiting to the right * @return The new animation */ public static Animation makeOutAnimation(Context c, boolean toRight) { public static Animation makeOutAnimation(Context c, boolean toRight) { Animation a; if (toRight) { a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_out_right); Loading @@ -243,9 +232,7 @@ public class AnimationUtils { * @param c Context for loading resources * @return The new animation */ public static Animation makeInChildBottomAnimation(Context c) { public static Animation makeInChildBottomAnimation(Context c) { Animation a; a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_child_bottom); a.setInterpolator(new AccelerateInterpolator()); Loading @@ -261,23 +248,19 @@ public class AnimationUtils { * @return The animation object reference by the specified id * @throws NotFoundException */ public static Interpolator loadInterpolator(Context context, int id) throws NotFoundException { public static Interpolator loadInterpolator(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createInterpolatorFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { Loading @@ -292,7 +275,7 @@ public class AnimationUtils { Interpolator interpolator = null; // Make sure we are on a start tag. int type = parser.getEventType(); int type; int depth = parser.getDepth(); while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) Loading @@ -317,6 +300,14 @@ public class AnimationUtils { interpolator = new AccelerateDecelerateInterpolator(c, attrs); } else if (name.equals("cycleInterpolator")) { interpolator = new CycleInterpolator(c, attrs); } else if (name.equals("anticipateInterpolator")) { interpolator = new AnticipateInterpolator(c, attrs); } else if (name.equals("overshootInterpolator")) { interpolator = new OvershootInterpolator(c, attrs); } else if (name.equals("anticipateOvershootInterpolator")) { interpolator = new AnticipateOvershootInterpolator(c, attrs); } else if (name.equals("bounceInterpolator")) { interpolator = new BounceInterpolator(c, attrs); } else { throw new RuntimeException("Unknown interpolator name: " + parser.getName()); } Loading core/java/android/view/animation/AnticipateInterpolator.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.animation; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; /** * An interpolator where the change starts backward then flings forward. */ public class AnticipateInterpolator implements Interpolator { private final float mTension; public AnticipateInterpolator() { mTension = 2.0f; } /** * @param tension Amount of anticipation. When tension equals 0.0f, there is * no anticipation and the interpolator becomes a simple * acceleration interpolator. */ public AnticipateInterpolator(float tension) { mTension = tension; } public AnticipateInterpolator(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AnticipateInterpolator); mTension = a.getFloat(com.android.internal.R.styleable.AnticipateInterpolator_tension, 2.0f); a.recycle(); } public float getInterpolation(float t) { // a(t) = t * t * ((tension + 1) * t - tension) return t * t * ((mTension + 1) * t - mTension); } } Loading
api/current.xml +286 −2 Original line number Diff line number Diff line Loading @@ -1361,6 +1361,39 @@ visibility="public" > </field> <field name="anticipate_interpolator" type="int" transient="false" volatile="false" value="17432583" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="anticipate_overshoot_interpolator" type="int" transient="false" volatile="false" value="17432585" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="bounce_interpolator" type="int" transient="false" volatile="false" value="17432586" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="decelerate_interpolator" type="int" transient="false" Loading Loading @@ -1394,6 +1427,17 @@ visibility="public" > </field> <field name="overshoot_interpolator" type="int" transient="false" volatile="false" value="17432584" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="slide_in_left" type="int" transient="false" Loading Loading @@ -1520,7 +1564,7 @@ type="int" transient="false" volatile="false" value="16843376" value="16843378" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -3155,6 +3199,17 @@ visibility="public" > </field> <field name="extraTension" type="int" transient="false" volatile="false" value="16843377" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="factor" type="int" transient="false" Loading Loading @@ -7170,6 +7225,17 @@ visibility="public" > </field> <field name="tension" type="int" transient="false" volatile="false" value="16843376" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="text" type="int" transient="false" Loading Loading @@ -60459,7 +60525,7 @@ type="float" transient="false" volatile="false" value="0.001f" value="0.0010f" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -136545,6 +136611,170 @@ </parameter> </method> </class> <class name="AnticipateInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="AnticipateInterpolator" type="android.view.animation.AnticipateInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="AnticipateInterpolator" type="android.view.animation.AnticipateInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> </constructor> <constructor name="AnticipateInterpolator" type="android.view.animation.AnticipateInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="AnticipateOvershootInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> </constructor> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> <parameter name="extraTension" type="float"> </parameter> </constructor> <constructor name="AnticipateOvershootInterpolator" type="android.view.animation.AnticipateOvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="BounceInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="BounceInterpolator" type="android.view.animation.BounceInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="BounceInterpolator" type="android.view.animation.BounceInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="CycleInterpolator" extends="java.lang.Object" abstract="false" Loading Loading @@ -137348,6 +137578,60 @@ </parameter> </method> </class> <class name="OvershootInterpolator" extends="java.lang.Object" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <implements name="android.view.animation.Interpolator"> </implements> <constructor name="OvershootInterpolator" type="android.view.animation.OvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > </constructor> <constructor name="OvershootInterpolator" type="android.view.animation.OvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="tension" type="float"> </parameter> </constructor> <constructor name="OvershootInterpolator" type="android.view.animation.OvershootInterpolator" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <method name="getInterpolation" return="float" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="t" type="float"> </parameter> </method> </class> <class name="RotateAnimation" extends="android.view.animation.Animation" abstract="false"
core/java/android/view/animation/AccelerateDecelerateInterpolator.java +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ public class AccelerateDecelerateInterpolator implements Interpolator { public AccelerateDecelerateInterpolator() { } @SuppressWarnings({"UnusedDeclaration"}) public AccelerateDecelerateInterpolator(Context context, AttributeSet attrs) { } Loading
core/java/android/view/animation/AccelerateInterpolator.java +10 −5 Original line number Diff line number Diff line Loading @@ -26,7 +26,12 @@ import android.util.AttributeSet; * */ public class AccelerateInterpolator implements Interpolator { private final float mFactor; private final double mDoubleFactor; public AccelerateInterpolator() { mFactor = 1.0f; mDoubleFactor = 2.0; } /** Loading @@ -39,6 +44,7 @@ public class AccelerateInterpolator implements Interpolator { */ public AccelerateInterpolator(float factor) { mFactor = factor; mDoubleFactor = 2 * mFactor; } public AccelerateInterpolator(Context context, AttributeSet attrs) { Loading @@ -46,17 +52,16 @@ public class AccelerateInterpolator implements Interpolator { context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AccelerateInterpolator); mFactor = a.getFloat(com.android.internal.R.styleable.AccelerateInterpolator_factor, 1.0f); mDoubleFactor = 2 * mFactor; a.recycle(); } public float getInterpolation(float input) { if (mFactor == 1.0f) { return (float)(input * input); return input * input; } else { return (float)Math.pow(input, 2 * mFactor); return (float)Math.pow(input, mDoubleFactor); } } private float mFactor = 1.0f; }
core/java/android/view/animation/AnimationUtils.java +40 −49 Original line number Diff line number Diff line Loading @@ -63,15 +63,13 @@ public class AnimationUtils { parser = context.getResources().getAnimation(id); return createAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { Loading @@ -81,16 +79,17 @@ public class AnimationUtils { private static Animation createAnimationFromXml(Context c, XmlPullParser parser) throws XmlPullParserException, IOException { return createAnimationFromXml(c, parser, null, Xml.asAttributeSet(parser)); } private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException { private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException { Animation anim = null; // Make sure we are on a start tag. int type = parser.getEventType(); int type; int depth = parser.getDepth(); while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) Loading Loading @@ -126,22 +125,20 @@ public class AnimationUtils { } public static LayoutAnimationController loadLayoutAnimation( Context context, int id) throws NotFoundException { public static LayoutAnimationController loadLayoutAnimation(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createLayoutAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; Loading @@ -150,24 +147,21 @@ public class AnimationUtils { } } private static LayoutAnimationController createLayoutAnimationFromXml( Context c, XmlPullParser parser) throws XmlPullParserException, IOException { return createLayoutAnimationFromXml(c, parser, Xml.asAttributeSet(parser)); private static LayoutAnimationController createLayoutAnimationFromXml(Context c, XmlPullParser parser) throws XmlPullParserException, IOException { return createLayoutAnimationFromXml(c, parser, Xml.asAttributeSet(parser)); } private static LayoutAnimationController createLayoutAnimationFromXml( Context c, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { private static LayoutAnimationController createLayoutAnimationFromXml(Context c, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { LayoutAnimationController controller = null; int type; int depth = parser.getDepth(); while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { if (type != XmlPullParser.START_TAG) { Loading @@ -181,8 +175,7 @@ public class AnimationUtils { } else if ("gridLayoutAnimation".equals(name)) { controller = new GridLayoutAnimationController(c, attrs); } else { throw new RuntimeException("Unknown layout animation name: " + name); throw new RuntimeException("Unknown layout animation name: " + name); } } Loading @@ -197,9 +190,7 @@ public class AnimationUtils { * @param fromLeft is the object to be animated coming from the left * @return The new animation */ public static Animation makeInAnimation(Context c, boolean fromLeft) { public static Animation makeInAnimation(Context c, boolean fromLeft) { Animation a; if (fromLeft) { a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_left); Loading @@ -220,9 +211,7 @@ public class AnimationUtils { * @param toRight is the object to be animated exiting to the right * @return The new animation */ public static Animation makeOutAnimation(Context c, boolean toRight) { public static Animation makeOutAnimation(Context c, boolean toRight) { Animation a; if (toRight) { a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_out_right); Loading @@ -243,9 +232,7 @@ public class AnimationUtils { * @param c Context for loading resources * @return The new animation */ public static Animation makeInChildBottomAnimation(Context c) { public static Animation makeInChildBottomAnimation(Context c) { Animation a; a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_child_bottom); a.setInterpolator(new AccelerateInterpolator()); Loading @@ -261,23 +248,19 @@ public class AnimationUtils { * @return The animation object reference by the specified id * @throws NotFoundException */ public static Interpolator loadInterpolator(Context context, int id) throws NotFoundException { public static Interpolator loadInterpolator(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createInterpolatorFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { Loading @@ -292,7 +275,7 @@ public class AnimationUtils { Interpolator interpolator = null; // Make sure we are on a start tag. int type = parser.getEventType(); int type; int depth = parser.getDepth(); while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) Loading @@ -317,6 +300,14 @@ public class AnimationUtils { interpolator = new AccelerateDecelerateInterpolator(c, attrs); } else if (name.equals("cycleInterpolator")) { interpolator = new CycleInterpolator(c, attrs); } else if (name.equals("anticipateInterpolator")) { interpolator = new AnticipateInterpolator(c, attrs); } else if (name.equals("overshootInterpolator")) { interpolator = new OvershootInterpolator(c, attrs); } else if (name.equals("anticipateOvershootInterpolator")) { interpolator = new AnticipateOvershootInterpolator(c, attrs); } else if (name.equals("bounceInterpolator")) { interpolator = new BounceInterpolator(c, attrs); } else { throw new RuntimeException("Unknown interpolator name: " + parser.getName()); } Loading
core/java/android/view/animation/AnticipateInterpolator.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.animation; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; /** * An interpolator where the change starts backward then flings forward. */ public class AnticipateInterpolator implements Interpolator { private final float mTension; public AnticipateInterpolator() { mTension = 2.0f; } /** * @param tension Amount of anticipation. When tension equals 0.0f, there is * no anticipation and the interpolator becomes a simple * acceleration interpolator. */ public AnticipateInterpolator(float tension) { mTension = tension; } public AnticipateInterpolator(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AnticipateInterpolator); mTension = a.getFloat(com.android.internal.R.styleable.AnticipateInterpolator_tension, 2.0f); a.recycle(); } public float getInterpolation(float t) { // a(t) = t * t * ((tension + 1) * t - tension) return t * t * ((mTension + 1) * t - mTension); } }