Search in sources :

Example 1 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project cw-omnibus by commonsguy.

the class IcsProgressBar method tileifyIndeterminate.

/**
     * Convert a AnimationDrawable for use as a barberpole animation.
     * Each frame of the animation is wrapped in a ClipDrawable and
     * given a tiling BitmapShader.
     */
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (drawable instanceof AnimationDrawable) {
        AnimationDrawable background = (AnimationDrawable) drawable;
        final int N = background.getNumberOfFrames();
        AnimationDrawable newBg = new AnimationDrawable();
        newBg.setOneShot(background.isOneShot());
        for (int i = 0; i < N; i++) {
            Drawable frame = tileify(background.getFrame(i), true);
            frame.setLevel(10000);
            newBg.addFrame(frame, background.getDuration(i));
        }
        newBg.setLevel(10000);
        drawable = newBg;
    }
    return drawable;
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) 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)

Example 2 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project AndroidTraining by mixi-inc.

the class IcsProgressBar method tileifyIndeterminate.

/**
     * Convert a AnimationDrawable for use as a barberpole animation.
     * Each frame of the animation is wrapped in a ClipDrawable and
     * given a tiling BitmapShader.
     */
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (drawable instanceof AnimationDrawable) {
        AnimationDrawable background = (AnimationDrawable) drawable;
        final int N = background.getNumberOfFrames();
        AnimationDrawable newBg = new AnimationDrawable();
        newBg.setOneShot(background.isOneShot());
        for (int i = 0; i < N; i++) {
            Drawable frame = tileify(background.getFrame(i), true);
            frame.setLevel(10000);
            newBg.addFrame(frame, background.getDuration(i));
        }
        newBg.setLevel(10000);
        drawable = newBg;
    }
    return drawable;
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) 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)

Example 3 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project qksms by moezbhatti.

the class ComposeView method updateButtonState.

private void updateButtonState(SendButtonState buttonState) {
    if (mButtonState != buttonState) {
        // Check if we need to switch animations
        AnimationDrawable animation = null;
        if (buttonState == SendButtonState.SEND) {
            animation = (AnimationDrawable) ContextCompat.getDrawable(mContext, R.drawable.plus_to_arrow);
        } else if (mButtonState == SendButtonState.SEND) {
            animation = (AnimationDrawable) ContextCompat.getDrawable(mContext, R.drawable.arrow_to_plus);
        }
        if (animation != null) {
            mComposeIcon.setImageDrawable(animation);
            animation.start();
        }
        // Handle any necessary rotation
        float rotation = mComposeIcon.getRotation();
        float target = buttonState == SendButtonState.ATTACH || buttonState == SendButtonState.SEND ? 0 : 45;
        ObjectAnimator.ofFloat(mComposeIcon, "rotation", rotation, target).setDuration(ANIMATION_DURATION).start();
        mButtonState = buttonState;
    }
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable)

Example 4 with AnimationDrawable

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

the class VectorDrawableAnimation method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Button button = new Button(this);
    button.setBackgroundResource(R.drawable.animation_drawable_vector);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AnimationDrawable frameAnimation = (AnimationDrawable) v.getBackground();
            // Start the animation (looped playback by default).
            frameAnimation.start();
        }
    });
    setContentView(button);
}
Also used : Button(android.widget.Button) AnimationDrawable(android.graphics.drawable.AnimationDrawable) View(android.view.View)

Example 5 with AnimationDrawable

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

the class VectorDrawableAnimation method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Button button = new Button(this);
    button.setBackgroundResource(R.drawable.animation_drawable_vector);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AnimationDrawable frameAnimation = (AnimationDrawable) v.getBackground();
            // Start the animation (looped playback by default).
            frameAnimation.start();
        }
    });
    setContentView(button);
}
Also used : Button(android.widget.Button) AnimationDrawable(android.graphics.drawable.AnimationDrawable) View(android.view.View)

Aggregations

AnimationDrawable (android.graphics.drawable.AnimationDrawable)70 BitmapDrawable (android.graphics.drawable.BitmapDrawable)32 Drawable (android.graphics.drawable.Drawable)31 ClipDrawable (android.graphics.drawable.ClipDrawable)19 LayerDrawable (android.graphics.drawable.LayerDrawable)19 ShapeDrawable (android.graphics.drawable.ShapeDrawable)14 View (android.view.View)11 StateListDrawable (android.graphics.drawable.StateListDrawable)9 ImageView (android.widget.ImageView)9 SuppressLint (android.annotation.SuppressLint)5 TypedArray (android.content.res.TypedArray)5 XmlResourceParser (android.content.res.XmlResourceParser)5 VectorDrawable (android.graphics.drawable.VectorDrawable)5 Button (android.widget.Button)5 TextView (android.widget.TextView)5 Intent (android.content.Intent)3 Paint (android.graphics.Paint)3 RecyclerView (android.support.v7.widget.RecyclerView)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 DividerItemDecoration (com.jakewharton.u2020.ui.misc.DividerItemDecoration)2