Search in sources :

Example 31 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project HoloEverywhere by Prototik.

the class ProgressBar method tileifyIndeterminate.

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) StateListDrawable(android.graphics.drawable.StateListDrawable) ClipDrawable(android.graphics.drawable.ClipDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) SuppressLint(android.annotation.SuppressLint)

Example 32 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project LuaViewSDK by alibaba.

the class UDImageView method startAnimationImages.

/**
 * 开始帧动画(目前只支持本地动画)
 *
 * @param images
 * @param duration
 * @return
 */
public UDImageView startAnimationImages(String[] images, int duration, boolean repeat) {
    final T view = getView();
    if (view != null) {
        Drawable[] frames = null;
        if (images != null && images.length > 0) {
            if (getLuaResourceFinder() != null) {
                frames = new Drawable[images.length];
                for (int i = 0; i < images.length; i++) {
                    frames[i] = getLuaResourceFinder().findDrawable(images[i]);
                }
            }
            if (frames != null && frames.length > 0) {
                mFrameAnimation = new AnimationDrawable();
                try {
                    for (Drawable frame : frames) {
                        mFrameAnimation.addFrame(frame, duration);
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    LogUtil.e("[LuaView-Error] UDImageView.startAnimationImages failed!");
                }
                mFrameAnimation.setOneShot(!repeat);
                LuaViewUtil.setBackground(view, mFrameAnimation);
                mFrameAnimation.setVisible(true, true);
                mFrameAnimation.start();
            }
        }
    }
    return this;
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable)

Example 33 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project Android-skin-support by ximsfei.

the class SkinCompatProgressBarHelper 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) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) ClipDrawable(android.graphics.drawable.ClipDrawable)

Example 34 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project RecyclerRefreshLayout by dinuscxj.

the class RefreshViewEg method refreshing.

@Override
public void refreshing() {
    clearAnimation();
    AnimationDrawable drawable = (AnimationDrawable) getResources().getDrawable(R.drawable.spinner);
    this.setImageDrawable(drawable);
    drawable.start();
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable)

Example 35 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project RecyclerRefreshLayout by dinuscxj.

the class DefaultTipsHelper method showLoading.

@Override
public void showLoading(boolean firstPage) {
    hideEmpty();
    hideError();
    if (firstPage) {
        View tipsView = TipsUtils.showTips(mRecyclerView, TipsType.LOADING);
        AnimationDrawable drawable = (AnimationDrawable) ((ImageView) tipsView).getDrawable();
        drawable.start();
        return;
    }
// maybe you like this mode
// mRefreshLayout.post(new Runnable() {
// @Override
// public void run() {
// mRefreshLayout.setRefreshing(true);
// }
// });
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) 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