use of android.graphics.drawable.AnimatedVectorDrawable in project android_frameworks_base by crdroidandroid.
the class PageIndicator method playAnimation.
private void playAnimation(ImageView imageView, int res) {
final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getContext().getDrawable(res);
imageView.setImageDrawable(avd);
avd.forceAnimationOnUI();
avd.start();
// TODO: Figure out how to user an AVD animation callback instead, which doesn't
// seem to be working right now...
postDelayed(mAnimationDone, ANIMATION_DURATION);
}
use of android.graphics.drawable.AnimatedVectorDrawable in project android_frameworks_base by crdroidandroid.
the class BatteryMeterDrawable method checkBatteryMeterDrawableValid.
private void checkBatteryMeterDrawableValid(Resources res, int style) {
final int resId = getBatteryDrawableResourceForStyle(style);
final Drawable batteryDrawable;
try {
batteryDrawable = mContext.getDrawable(resId);
} catch (Resources.NotFoundException e) {
throw new BatteryMeterDrawableException(res.getResourceName(resId) + " is an " + "invalid drawable", e);
}
// Check that the drawable is a LayerDrawable
if (!(batteryDrawable instanceof LayerDrawable)) {
throw new BatteryMeterDrawableException("Expected a LayerDrawable but received a " + batteryDrawable.getClass().getSimpleName());
}
final LayerDrawable layerDrawable = (LayerDrawable) batteryDrawable;
final Drawable frame = layerDrawable.findDrawableByLayerId(R.id.battery_frame);
final Drawable level = layerDrawable.findDrawableByLayerId(R.id.battery_fill);
// Now, check that the required layers exist and are of the correct type
if (frame == null) {
throw new BatteryMeterDrawableException("Missing battery_frame drawble");
}
if (level != null) {
// Check that the level drawable is an AnimatedVectorDrawable
if (!(level instanceof AnimatedVectorDrawable)) {
throw new BatteryMeterDrawableException("Expected a AnimatedVectorDrawable " + "but received a " + level.getClass().getSimpleName());
}
// Make sure we can stop-motion animate the level drawable
try {
StopMotionVectorDrawable smvd = new StopMotionVectorDrawable(level);
smvd.setCurrentFraction(0.5f);
} catch (Exception e) {
throw new BatteryMeterDrawableException("Unable to perform stop motion on " + "battery_fill drawable", e);
}
} else {
throw new BatteryMeterDrawableException("Missing battery_fill drawable");
}
}
use of android.graphics.drawable.AnimatedVectorDrawable in project platform_frameworks_base by android.
the class AnimatedVectorDrawableAttr method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animated_vector_drawable_attr);
ImageView avdIv = (ImageView) findViewById(R.id.avd);
AnimatedVectorDrawable avd = (AnimatedVectorDrawable) avdIv.getDrawable();
avd.start();
}
use of android.graphics.drawable.AnimatedVectorDrawable in project platform_frameworks_base by android.
the class AnimatedVectorDrawableDupPerf method create.
/** @hide */
public static AnimatedVectorDrawable create(Resources resources, int rid) {
try {
final XmlPullParser parser = resources.getXml(rid);
final AttributeSet attrs = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
// Empty loop
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException("No start tag found");
}
final AnimatedVectorDrawable drawable = new AnimatedVectorDrawable();
drawable.inflate(resources, parser, attrs);
return drawable;
} catch (XmlPullParserException e) {
Log.e(LOGTAG, "parser error", e);
} catch (IOException e) {
Log.e(LOGTAG, "parser error", e);
}
return null;
}
use of android.graphics.drawable.AnimatedVectorDrawable in project platform_frameworks_base by android.
the class AnimatedVectorDrawableTest method onClick.
@Override
public void onClick(View v) {
AnimatedVectorDrawable d = (AnimatedVectorDrawable) v.getBackground();
d.start();
}
Aggregations