Search in sources :

Example 66 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project developmentDependencyLibrary by MatchlessBrother.

the class PromptBoxTools method showLoadingDialog.

/**
 **与服务器开始通讯时默认弹出的对话框1:代表的是圆圈旋转进度框,2:代表的是飞机飞行进度框****
 */
public static BaseProgressDialog showLoadingDialog(Context context, String msg, int themeStyleValue, boolean isCanceledOnTouchOutside, BaseProgressDialog.OnClickOutsideListener onClickOutsideListener) {
    BaseProgressDialog progressDialog = new BaseProgressDialog(context);
    progressDialog.setCanceledOnTouchOutside(isCanceledOnTouchOutside);
    progressDialog.setMessage(msg.trim());
    progressDialog.show();
    View contentView = null;
    ImageView imageView = null;
    AnimationDrawable animation = null;
    if (themeStyleValue == 1) {
        contentView = ResourceTools.generateView(context, R.layout.inflater_progressdialogdefault);
        imageView = (ImageView) contentView.findViewById(R.id.defaultthemeimg);
        animation = new AnimationDrawable();
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault1), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault2), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault3), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault4), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault5), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault6), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault7), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault8), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault9), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault10), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault11), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault12), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault13), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault14), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault15), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault16), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault17), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault18), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault19), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault20), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault21), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault22), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault23), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault24), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault25), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault26), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault27), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault28), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault29), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault30), 45);
        animation.setOneShot(false);
        imageView.setBackgroundDrawable(animation);
        if (animation != null && !animation.isRunning())
            animation.start();
    } else {
        contentView = ResourceTools.generateView(context, R.layout.inflater_progressdialogplane);
        imageView = (ImageView) contentView.findViewById(R.id.planethemeimg);
        animation = new AnimationDrawable();
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane1), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane2), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane3), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane4), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane5), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane6), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane7), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane8), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane9), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane10), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane11), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane12), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane13), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane14), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane15), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane16), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane17), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane18), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane19), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane20), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane21), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane22), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane23), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane24), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane25), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane26), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane27), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane28), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane29), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane30), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane31), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane32), 45);
        animation.setOneShot(false);
        imageView.setBackgroundDrawable(animation);
        if (animation != null && !animation.isRunning())
            animation.start();
    }
    progressDialog.setContentView(contentView);
    if (null != onClickOutsideListener)
        progressDialog.setOnClickOutsideListener(onClickOutsideListener);
    Window window = progressDialog.getWindow();
    window.getDecorView().setPadding(0, 0, 0, 0);
    window.getDecorView().setBackgroundResource(R.color.transparent);
    DisplayMetrics displayMetrics = new DisplayMetrics();
    ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(displayMetrics);
    WindowManager.LayoutParams params = window.getAttributes();
    params.width = PixelConvertedTools.dpTpx(context, 110);
    params.gravity = Gravity.CENTER;
    window.setAttributes(params);
    return progressDialog;
}
Also used : Window(android.view.Window) AnimationDrawable(android.graphics.drawable.AnimationDrawable) ImageView(android.widget.ImageView) BaseProgressDialog(com.yuan.dependonlibrary._11___Widget.promptBox.BaseProgressDialog) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Example 67 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project ultrasonic by ultrasonic.

the class SongView method update.

@Override
protected void update() {
    updateBackground();
    if (downloadService == null) {
        return;
    }
    downloadFile = downloadService.forSong(this.song);
    File partialFile = downloadFile.getPartialFile();
    if (downloadFile.isWorkDone()) {
        ImageType newLeftImageType = downloadFile.isSaved() ? ImageType.unpin : ImageType.downloaded;
        if (this.leftImageType != newLeftImageType) {
            this.leftImage = downloadFile.isSaved() ? unpinImage : downloadedImage;
            this.leftImageType = newLeftImageType;
        }
    } else {
        this.leftImageType = ImageType.none;
        this.leftImage = null;
    }
    if (downloadFile.isDownloading() && !downloadFile.isDownloadCancelled() && partialFile.exists()) {
        if (this.viewHolder.status != null) {
            this.viewHolder.status.setText(Util.formatLocalizedBytes(partialFile.length(), this.context));
        }
        this.rightImageType = ImageType.downloading;
        this.rightImage = downloadingImage;
    } else {
        this.rightImageType = ImageType.none;
        this.rightImage = null;
        if (this.viewHolder.status != null) {
            CharSequence statusText = this.viewHolder.status.getText();
            if (statusText != "" || statusText != null) {
                this.viewHolder.status.setText(null);
            }
        }
    }
    if (this.previousLeftImageType != leftImageType || this.previousRightImageType != rightImageType) {
        this.previousLeftImageType = leftImageType;
        this.previousRightImageType = rightImageType;
        if (this.viewHolder.status != null) {
            this.viewHolder.status.setCompoundDrawablesWithIntrinsicBounds(leftImage, null, rightImage, null);
            if (rightImage == downloadingImage) {
                AnimationDrawable frameAnimation = (AnimationDrawable) rightImage;
                frameAnimation.setVisible(true, true);
            }
        }
    }
    if (!song.getStarred()) {
        if (viewHolder.star != null) {
            if (viewHolder.star.getDrawable() != starHollowDrawable) {
                viewHolder.star.setImageDrawable(starHollowDrawable);
            }
        }
    } else {
        if (viewHolder.star != null) {
            if (viewHolder.star.getDrawable() != starDrawable) {
                viewHolder.star.setImageDrawable(starDrawable);
            }
        }
    }
    boolean playing = downloadService.getCurrentPlaying() == downloadFile;
    if (playing) {
        if (!this.playing) {
            this.playing = true;
            viewHolder.title.setCompoundDrawablesWithIntrinsicBounds(playingImage, null, null, null);
        }
    } else {
        if (this.playing) {
            this.playing = false;
            viewHolder.title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
        }
    }
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) DownloadFile(org.moire.ultrasonic.service.DownloadFile) File(java.io.File)

Example 68 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project Ushahidi_Android by ushahidi.

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

use of android.graphics.drawable.AnimationDrawable in project little-bear-dictionary by daimajia.

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) RotateDrawable(android.graphics.drawable.RotateDrawable) SuppressLint(android.annotation.SuppressLint)

Example 70 with AnimationDrawable

use of android.graphics.drawable.AnimationDrawable in project little-bear-dictionary by daimajia.

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)

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