Search in sources :

Example 61 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project TextDrawable by amulyakhare.

the class DrawableProvider method getRectWithAnimation.

public Drawable getRectWithAnimation() {
    TextDrawable.IBuilder builder = TextDrawable.builder().rect();
    AnimationDrawable animationDrawable = new AnimationDrawable();
    for (int i = 10; i > 0; i--) {
        TextDrawable frame = builder.build(String.valueOf(i), mGenerator.getRandomColor());
        animationDrawable.addFrame(frame, 1200);
    }
    animationDrawable.setOneShot(false);
    animationDrawable.start();
    return animationDrawable;
}
Also used : TextDrawable(com.amulyakhare.textdrawable.TextDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable)

Example 62 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project ignition by mttkay.

the class RemoteImageView method buildProgressSpinnerView.

protected View buildProgressSpinnerView(Context context) {
    ProgressBar loadingSpinner = new ProgressBar(context);
    loadingSpinner.setIndeterminate(true);
    if (this.progressDrawable == null) {
        this.progressDrawable = loadingSpinner.getIndeterminateDrawable();
    } else {
        loadingSpinner.setIndeterminateDrawable(progressDrawable);
        if (progressDrawable instanceof AnimationDrawable) {
            ((AnimationDrawable) progressDrawable).start();
        }
    }
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(progressDrawable.getIntrinsicWidth(), progressDrawable.getIntrinsicHeight(), Gravity.CENTER);
    loadingSpinner.setLayoutParams(lp);
    return loadingSpinner;
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) FrameLayout(android.widget.FrameLayout) ProgressBar(android.widget.ProgressBar)

Example 63 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project httpclient by pixmob.

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 64 with AnimationDrawable

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

the class ProgressBar method updateDrawableBounds.

private void updateDrawableBounds(int w, int h) {
    int right = w - getPaddingRight() - getPaddingLeft();
    int bottom = h - getPaddingBottom() - getPaddingTop();
    int top = 0;
    int left = 0;
    if (mIndeterminateDrawable != null) {
        if (mOnlyIndeterminate && !(mIndeterminateDrawable instanceof AnimationDrawable)) {
            final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth();
            final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight();
            final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight;
            final float boundAspect = (float) w / h;
            if (intrinsicAspect != boundAspect) {
                if (boundAspect > intrinsicAspect) {
                    final int width = (int) (h * intrinsicAspect);
                    left = (w - width) / 2;
                    right = left + width;
                } else {
                    final int height = (int) (w * (1 / intrinsicAspect));
                    top = (h - height) / 2;
                    bottom = top + height;
                }
            }
        }
        mIndeterminateDrawable.setBounds(left, top, right, bottom);
    }
    if (mProgressDrawable != null) {
        mProgressDrawable.setBounds(0, 0, right, bottom);
    }
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) SuppressLint(android.annotation.SuppressLint)

Example 65 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project u2020 by JakeWharton.

the class TrendingView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    ButterKnife.bind(this);
    AnimationDrawable ellipsis = (AnimationDrawable) ContextCompat.getDrawable(getContext(), R.drawable.dancing_ellipsis);
    loadingMessageView.setCompoundDrawablesWithIntrinsicBounds(null, null, ellipsis, null);
    ellipsis.start();
    toolbarView.setNavigationIcon(R.drawable.menu_icon);
    toolbarView.setNavigationOnClickListener(v -> drawerLayout.openDrawer(GravityCompat.START));
    timespanView.setAdapter(timespanAdapter);
    timespanView.setSelection(TrendingTimespan.WEEK.ordinal());
    swipeRefreshView.setColorSchemeResources(R.color.accent);
    swipeRefreshView.setOnRefreshListener(this);
    trendingAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onChanged() {
            animatorView.setDisplayedChildId(// 
            trendingAdapter.getItemCount() == 0 ? // 
            R.id.trending_empty : R.id.trending_swipe_refresh);
            swipeRefreshView.setRefreshing(false);
        }
    });
    trendingView.setLayoutManager(new LinearLayoutManager(getContext()));
    trendingView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL_LIST, dividerPaddingStart, isRtl()));
    trendingView.setAdapter(trendingAdapter);
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.jakewharton.u2020.ui.misc.DividerItemDecoration)

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