Search in sources :

Example 56 with Animatable

use of android.graphics.drawable.Animatable in project android_frameworks_base by ResurrectionRemix.

the class ProgressBar method drawTrack.

/**
     * Draws the progress bar track.
     */
void drawTrack(Canvas canvas) {
    final Drawable d = mCurrentDrawable;
    if (d != null) {
        // Translate canvas so a indeterminate circular progress bar with padding
        // rotates properly in its animation
        final int saveCount = canvas.save();
        if (isLayoutRtl() && mMirrorForRtl) {
            canvas.translate(getWidth() - mPaddingRight, mPaddingTop);
            canvas.scale(-1.0f, 1.0f);
        } else {
            canvas.translate(mPaddingLeft, mPaddingTop);
        }
        final long time = getDrawingTime();
        if (mHasAnimation) {
            mAnimation.getTransformation(time, mTransformation);
            final float scale = mTransformation.getAlpha();
            try {
                mInDrawing = true;
                d.setLevel((int) (scale * MAX_LEVEL));
            } finally {
                mInDrawing = false;
            }
            postInvalidateOnAnimation();
        }
        d.draw(canvas);
        canvas.restoreToCount(saveCount);
        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) StateListDrawable(android.graphics.drawable.StateListDrawable) ClipDrawable(android.graphics.drawable.ClipDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Animatable(android.graphics.drawable.Animatable)

Example 57 with Animatable

use of android.graphics.drawable.Animatable in project android_frameworks_base by ResurrectionRemix.

the class QSDetail method handleScanStateChanged.

private void handleScanStateChanged(boolean state) {
    if (mScanState == state)
        return;
    mScanState = state;
    final Animatable anim = (Animatable) mQsDetailHeaderProgress.getDrawable();
    if (state) {
        mQsDetailHeaderProgress.animate().alpha(1f);
        anim.start();
    } else {
        mQsDetailHeaderProgress.animate().alpha(0f);
        anim.stop();
    }
}
Also used : Animatable(android.graphics.drawable.Animatable)

Example 58 with Animatable

use of android.graphics.drawable.Animatable in project android_frameworks_base by DirtyUnicorns.

the class QSDetail method handleScanStateChanged.

private void handleScanStateChanged(boolean state) {
    if (mScanState == state)
        return;
    mScanState = state;
    final Animatable anim = (Animatable) mQsDetailHeaderProgress.getDrawable();
    if (state) {
        mQsDetailHeaderProgress.animate().alpha(1f);
        anim.start();
    } else {
        mQsDetailHeaderProgress.animate().alpha(0f);
        anim.stop();
    }
}
Also used : Animatable(android.graphics.drawable.Animatable)

Example 59 with Animatable

use of android.graphics.drawable.Animatable in project android_frameworks_base by DirtyUnicorns.

the class QSIconView method setIcon.

protected void setIcon(ImageView iv, QSTile.State state) {
    if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
        Drawable d = state.icon != null ? iv.isShown() && mAnimationEnabled ? state.icon.getDrawable(mContext) : state.icon.getInvisibleDrawable(mContext) : null;
        int padding = state.icon != null ? state.icon.getPadding() : 0;
        if (d != null && state.autoMirrorDrawable) {
            d.setAutoMirrored(true);
        }
        iv.setImageDrawable(d);
        iv.setTag(R.id.qs_icon_tag, state.icon);
        iv.setPadding(0, padding, 0, padding);
        if (d instanceof Animatable && iv.isShown()) {
            Animatable a = (Animatable) d;
            a.start();
            if (!iv.isShown()) {
                // skip directly to end state
                a.stop();
            }
        }
    }
    if (state.disabledByPolicy) {
        iv.setColorFilter(getContext().getColor(R.color.qs_tile_disabled_color));
    } else {
        iv.clearColorFilter();
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) Animatable(android.graphics.drawable.Animatable)

Example 60 with Animatable

use of android.graphics.drawable.Animatable in project android_frameworks_base by DirtyUnicorns.

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)

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