use of android.graphics.drawable.Animatable in project ride-read-android by Ride-Read.
the class ImageActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
imageUrl = getIntent().getStringExtra(IMAGE);
if (imageUrl.startsWith("/")) {
imageUrl = "file://" + imageUrl;
}
final PhotoDraweeView photoDraweeView = (PhotoDraweeView) findViewById(R.id.iv_image_activity);
photoDraweeView.setOnViewTapListener(new OnViewTapListener() {
@Override
public void onViewTap(View view, float x, float y) {
onBackPressed();
}
});
PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
controller.setUri(Uri.parse(imageUrl));
controller.setOldController(photoDraweeView.getController());
controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
super.onFinalImageSet(id, imageInfo, animatable);
if (imageInfo == null) {
return;
}
photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
}
});
photoDraweeView.setController(controller.build());
}
use of android.graphics.drawable.Animatable in project android_frameworks_base by ResurrectionRemix.
the class ProgressBar method startAnimation.
/**
* <p>Start the indeterminate progress animation.</p>
*/
void startAnimation() {
if (getVisibility() != VISIBLE || getWindowVisibility() != VISIBLE) {
return;
}
if (mIndeterminateDrawable instanceof Animatable) {
mShouldStartAnimationDrawable = true;
mHasAnimation = false;
} else {
mHasAnimation = true;
if (mInterpolator == null) {
mInterpolator = new LinearInterpolator();
}
if (mTransformation == null) {
mTransformation = new Transformation();
} else {
mTransformation.clear();
}
if (mAnimation == null) {
mAnimation = new AlphaAnimation(0.0f, 1.0f);
} else {
mAnimation.reset();
}
mAnimation.setRepeatMode(mBehavior);
mAnimation.setRepeatCount(Animation.INFINITE);
mAnimation.setDuration(mDuration);
mAnimation.setInterpolator(mInterpolator);
mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
}
postInvalidate();
}
use of android.graphics.drawable.Animatable in project android_frameworks_base by ResurrectionRemix.
the class AnimationScaleListDrawable method isRunning.
@Override
public boolean isRunning() {
boolean result = false;
Drawable dr = getCurrent();
if (dr != null && dr instanceof Animatable) {
result = ((Animatable) dr).isRunning();
}
return result;
}
use of android.graphics.drawable.Animatable in project ActionBarSherlock by JakeWharton.
the class IcsProgressBar method startAnimation.
/**
* <p>Start the indeterminate progress animation.</p>
*/
void startAnimation() {
if (getVisibility() != VISIBLE) {
return;
}
if (mIndeterminateDrawable instanceof Animatable) {
mShouldStartAnimationDrawable = true;
mAnimation = null;
} else {
if (mInterpolator == null) {
mInterpolator = new LinearInterpolator();
}
mTransformation = new Transformation();
mAnimation = new AlphaAnimation(0.0f, 1.0f);
mAnimation.setRepeatMode(mBehavior);
mAnimation.setRepeatCount(Animation.INFINITE);
mAnimation.setDuration(mDuration);
mAnimation.setInterpolator(mInterpolator);
mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
}
postInvalidate();
}
use of android.graphics.drawable.Animatable in project ActionBarSherlock by JakeWharton.
the class IcsProgressBar method onDraw.
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
Drawable d = mCurrentDrawable;
if (d != null) {
// Translate canvas so a indeterminate circular progress bar with padding
// rotates properly in its animation
canvas.save();
canvas.translate(getPaddingLeft() + mIndeterminateRealLeft, getPaddingTop() + mIndeterminateRealTop);
long time = getDrawingTime();
if (mAnimation != null) {
mAnimation.getTransformation(time, mTransformation);
float scale = mTransformation.getAlpha();
try {
mInDrawing = true;
d.setLevel((int) (scale * MAX_LEVEL));
} finally {
mInDrawing = false;
}
if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) {
mLastDrawTime = SystemClock.uptimeMillis();
postInvalidateDelayed(mAnimationResolution);
}
}
d.draw(canvas);
canvas.restore();
if (mShouldStartAnimationDrawable && d instanceof Animatable) {
((Animatable) d).start();
mShouldStartAnimationDrawable = false;
}
}
}
Aggregations