Methods Summary |
---|
private static Animation | createAnimationFromXml(android.content.Context c, org.xmlpull.v1.XmlPullParser parser)
return createAnimationFromXml(c, parser, null, Xml.asAttributeSet(parser));
|
private static Animation | createAnimationFromXml(android.content.Context c, org.xmlpull.v1.XmlPullParser parser, AnimationSet parent, android.util.AttributeSet attrs)
Animation anim = null;
// Make sure we are on a start tag.
int type;
int depth = parser.getDepth();
while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
&& type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("set")) {
anim = new AnimationSet(c, attrs);
createAnimationFromXml(c, parser, (AnimationSet)anim, attrs);
} else if (name.equals("alpha")) {
anim = new AlphaAnimation(c, attrs);
} else if (name.equals("scale")) {
anim = new ScaleAnimation(c, attrs);
} else if (name.equals("rotate")) {
anim = new RotateAnimation(c, attrs);
} else if (name.equals("translate")) {
anim = new TranslateAnimation(c, attrs);
} else {
throw new RuntimeException("Unknown animation name: " + parser.getName());
}
if (parent != null) {
parent.addAnimation(anim);
}
}
return anim;
|
private static Interpolator | createInterpolatorFromXml(android.content.res.Resources res, android.content.res.Resources.Theme theme, org.xmlpull.v1.XmlPullParser parser)
BaseInterpolator interpolator = null;
// Make sure we are on a start tag.
int type;
int depth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
&& type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
AttributeSet attrs = Xml.asAttributeSet(parser);
String name = parser.getName();
if (name.equals("linearInterpolator")) {
interpolator = new LinearInterpolator();
} else if (name.equals("accelerateInterpolator")) {
interpolator = new AccelerateInterpolator(res, theme, attrs);
} else if (name.equals("decelerateInterpolator")) {
interpolator = new DecelerateInterpolator(res, theme, attrs);
} else if (name.equals("accelerateDecelerateInterpolator")) {
interpolator = new AccelerateDecelerateInterpolator();
} else if (name.equals("cycleInterpolator")) {
interpolator = new CycleInterpolator(res, theme, attrs);
} else if (name.equals("anticipateInterpolator")) {
interpolator = new AnticipateInterpolator(res, theme, attrs);
} else if (name.equals("overshootInterpolator")) {
interpolator = new OvershootInterpolator(res, theme, attrs);
} else if (name.equals("anticipateOvershootInterpolator")) {
interpolator = new AnticipateOvershootInterpolator(res, theme, attrs);
} else if (name.equals("bounceInterpolator")) {
interpolator = new BounceInterpolator();
} else if (name.equals("pathInterpolator")) {
interpolator = new PathInterpolator(res, theme, attrs);
} else {
throw new RuntimeException("Unknown interpolator name: " + parser.getName());
}
}
return interpolator;
|
private static LayoutAnimationController | createLayoutAnimationFromXml(android.content.Context c, org.xmlpull.v1.XmlPullParser parser)
return createLayoutAnimationFromXml(c, parser, Xml.asAttributeSet(parser));
|
private static LayoutAnimationController | createLayoutAnimationFromXml(android.content.Context c, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
LayoutAnimationController controller = null;
int type;
int depth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
&& type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if ("layoutAnimation".equals(name)) {
controller = new LayoutAnimationController(c, attrs);
} else if ("gridLayoutAnimation".equals(name)) {
controller = new GridLayoutAnimationController(c, attrs);
} else {
throw new RuntimeException("Unknown layout animation name: " + name);
}
}
return controller;
|
public static long | currentAnimationTimeMillis()Returns the current animation time in milliseconds. This time should be used when invoking
{@link Animation#setStartTime(long)}. Refer to {@link android.os.SystemClock} for more
information about the different available clocks. The clock used by this method is
not the "wall" clock (it is not {@link System#currentTimeMillis}).
return SystemClock.uptimeMillis();
|
public static Animation | loadAnimation(android.content.Context context, int id)Loads an {@link Animation} object from a resource
XmlResourceParser parser = null;
try {
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));
rnf.initCause(ex);
throw rnf;
} catch (IOException ex) {
NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" +
Integer.toHexString(id));
rnf.initCause(ex);
throw rnf;
} finally {
if (parser != null) parser.close();
}
|
public static Interpolator | loadInterpolator(android.content.Context context, int id)Loads an {@link Interpolator} object from a resource
XmlResourceParser parser = null;
try {
parser = context.getResources().getAnimation(id);
return createInterpolatorFromXml(context.getResources(), context.getTheme(), parser);
} catch (XmlPullParserException ex) {
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));
rnf.initCause(ex);
throw rnf;
} finally {
if (parser != null) parser.close();
}
|
public static Interpolator | loadInterpolator(android.content.res.Resources res, android.content.res.Resources.Theme theme, int id)Loads an {@link Interpolator} object from a resource
XmlResourceParser parser = null;
try {
parser = res.getAnimation(id);
return createInterpolatorFromXml(res, theme, parser);
} catch (XmlPullParserException ex) {
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));
rnf.initCause(ex);
throw rnf;
} finally {
if (parser != null)
parser.close();
}
|
public static LayoutAnimationController | loadLayoutAnimation(android.content.Context context, int id)Loads a {@link LayoutAnimationController} object from a resource
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" +
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));
rnf.initCause(ex);
throw rnf;
} finally {
if (parser != null) parser.close();
}
|
public static Animation | makeInAnimation(android.content.Context c, boolean fromLeft)Make an animation for objects becoming visible. Uses a slide and fade
effect.
Animation a;
if (fromLeft) {
a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_left);
} else {
a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_right);
}
a.setInterpolator(new DecelerateInterpolator());
a.setStartTime(currentAnimationTimeMillis());
return a;
|
public static Animation | makeInChildBottomAnimation(android.content.Context c)Make an animation for objects becoming visible. Uses a slide up and fade
effect.
Animation a;
a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_child_bottom);
a.setInterpolator(new AccelerateInterpolator());
a.setStartTime(currentAnimationTimeMillis());
return a;
|
public static Animation | makeOutAnimation(android.content.Context c, boolean toRight)Make an animation for objects becoming invisible. Uses a slide and fade
effect.
Animation a;
if (toRight) {
a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_out_right);
} else {
a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_out_left);
}
a.setInterpolator(new AccelerateInterpolator());
a.setStartTime(currentAnimationTimeMillis());
return a;
|