Search in sources :

Example 21 with Animatable

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());
}
Also used : OnViewTapListener(me.relex.photodraweeview.OnViewTapListener) Animatable(android.graphics.drawable.Animatable) PhotoDraweeView(me.relex.photodraweeview.PhotoDraweeView) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) View(android.view.View) PhotoDraweeView(me.relex.photodraweeview.PhotoDraweeView) PipelineDraweeControllerBuilder(com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)

Example 22 with Animatable

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();
}
Also used : Transformation(android.view.animation.Transformation) LinearInterpolator(android.view.animation.LinearInterpolator) Animatable(android.graphics.drawable.Animatable) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 23 with Animatable

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;
}
Also used : Drawable(android.graphics.drawable.Drawable) Animatable(android.graphics.drawable.Animatable)

Example 24 with Animatable

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();
}
Also used : Transformation(android.view.animation.Transformation) LinearInterpolator(android.view.animation.LinearInterpolator) Animatable(android.graphics.drawable.Animatable) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 25 with Animatable

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;
        }
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) ClipDrawable(android.graphics.drawable.ClipDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Animatable(android.graphics.drawable.Animatable)

Aggregations

Animatable (android.graphics.drawable.Animatable)67 Drawable (android.graphics.drawable.Drawable)34 AnimationDrawable (android.graphics.drawable.AnimationDrawable)17 BitmapDrawable (android.graphics.drawable.BitmapDrawable)17 ClipDrawable (android.graphics.drawable.ClipDrawable)17 LayerDrawable (android.graphics.drawable.LayerDrawable)17 AlphaAnimation (android.view.animation.AlphaAnimation)17 LinearInterpolator (android.view.animation.LinearInterpolator)17 Transformation (android.view.animation.Transformation)17 ShapeDrawable (android.graphics.drawable.ShapeDrawable)12 StateListDrawable (android.graphics.drawable.StateListDrawable)9 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)8 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)7 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)6 DraweeController (com.facebook.drawee.interfaces.DraweeController)5 QualityInfo (com.facebook.imagepipeline.image.QualityInfo)4 Uri (android.net.Uri)3 Nullable (android.support.annotation.Nullable)3 ControllerListener (com.facebook.drawee.controller.ControllerListener)3 View (android.view.View)2