android.graphics.drawable.AnimationDrawable#addFrame()源码实例Demo

下面列出了android.graphics.drawable.AnimationDrawable#addFrame() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: ProgressBar.java
/**
 * 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;
}
 
源代码2 项目: CSipSimple   文件: IcsProgressBar.java
/**
 * 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;
}
 
/**
 * 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;
}
 
源代码4 项目: DragPointView   文件: SampleActivity.java
private void initAnim() {

        animationDrawable = new AnimationDrawable();
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode1), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode2), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode3), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode4), 100);
        animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode5), 100);
        animationDrawable.setOneShot(true);
        animationDrawable.setExitFadeDuration(300);
        animationDrawable.setEnterFadeDuration(100);

        ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(null, "scaleX", 1.f, 0.f);
        ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(null, "scaleY", 1.f, 0.f);
        animatorSet = new AnimatorSet();
        animatorSet.setDuration(300l);
        animatorSet.playTogether(objectAnimator1, objectAnimator2);

        objectAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.f, 0.f);
        objectAnimator.setDuration(2000l);
    }
 
/**
 * 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;
}
 
/**
 * 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;
}
 
/**
 * 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;
}
 
源代码8 项目: zhangshangwuda   文件: IcsProgressBar.java
/**
 * 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;
}
 
源代码9 项目: BlogDemo   文件: BossTransferView.java
private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.layout_boss_transfer, this);
        mImg = (ImageView) findViewById(R.id.img);
        mTemp = findViewById(R.id.line);
//        mPb = (ProgressBar) findViewById(R.id.progress);
        mPb = (ImageView) findViewById(R.id.progress);
        mHandleView.getLocationInWindow(mLocation);
        int sbh = Util.getStatusBarHeight(getContext());
        mImg.setTranslationY(mLocation[1] - sbh);
        mTemp.setTranslationY(mLocation[1] + mImg.getMeasuredHeight() / 2 + sbh);
        mPb.setVisibility(GONE);
        Bitmap bm = getViewImg(mHandleView);
        if (bm != null) {
            mImg.setImageBitmap(getViewImg(mHandleView));
        }
        AnimationDrawable ad = new AnimationDrawable();
        ad.addFrame(getDrawable(R.mipmap.icon_refresh_left), 200);
        ad.addFrame(getDrawable(R.mipmap.icon_refresh_center), 200);
        ad.addFrame(getDrawable(R.mipmap.icon_refresh_right), 200);
        mPb.setImageDrawable(ad);
        ad.setOneShot(false);
        ad.start();
    }
 
/**
 * 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;
}
 
源代码11 项目: zen4android   文件: IcsProgressBar.java
/**
 * 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;
}
 
源代码12 项目: VideoOS-Android-SDK   文件: UDImageView.java
/**
 * 开始帧动画(目前只支持本地动画)
 *
 * @param images
 * @param duration
 * @return
 */
public UDImageView startAnimationImages(String[] images, int duration, boolean repeat) {
    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) {
                }
                mFrameAnimation.setOneShot(!repeat);
                LuaViewUtil.setBackground(view, mFrameAnimation);
                mFrameAnimation.setVisible(true, true);
                mFrameAnimation.start();
            }
        }
    }
    return this;
}
 
源代码13 项目: DragPointView   文件: ItemConversationAdapter.java
public ItemConversationAdapter(Context context, List<ConversationEntity> objects) {
    this.context = context;
    this.layoutInflater = LayoutInflater.from(context);
    this.objects = objects;

    animationDrawable = new AnimationDrawable();
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode1), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode2), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode3), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode4), 100);
    animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode5), 100);
    animationDrawable.setOneShot(true);
    animationDrawable.setExitFadeDuration(300);
    animationDrawable.setEnterFadeDuration(100);
}
 
private void setupAnimationDrawable() {
    AnimationDrawable animationDrawable = new AnimationDrawable();
    for (int index = 0; index < bitmaps.size(); index++) {
        BitmapDrawable drawable = new BitmapDrawable(this.getResources(), bitmaps.get(index));
        animationDrawable.addFrame(drawable, 1000 / framesPerSecond);
    }

    animationDrawable.setOneShot(!this.loop);

    this.setImageDrawable(animationDrawable);
    animationDrawable.start();
}
 
源代码15 项目: AndroidStudyDemo   文件: AnimationUtils.java
public static AnimationDrawable initAnimationDrawable(Context context, int[] drawableIds,
        int durationTime, boolean isOneShot) {
    AnimationDrawable mAnimationDrawable = new AnimationDrawable();
    for (int i = 0; i < drawableIds.length; i++) {
        int id = drawableIds[i];
        mAnimationDrawable.addFrame(context.getResources().getDrawable(id), durationTime);
    }
    mAnimationDrawable.setOneShot(isOneShot);
    return mAnimationDrawable;
}
 
private void createFabFrameAnim() {
    frameAnim = new AnimationDrawable();
    frameAnim.setOneShot(true);
    Resources resources = getResources();
    for (int res : frameAnimRes) {
        frameAnim.addFrame(resources.getDrawable(res), frameDuration);
    }
}
 
private void createFabReverseFrameAnim() {
    frameReverseAnim = new AnimationDrawable();
    frameReverseAnim.setOneShot(true);
    Resources resources = getResources();
    for (int i = frameAnimRes.length - 1; i >= 0; i--) {
        frameReverseAnim.addFrame(resources.getDrawable(frameAnimRes[i]), frameDuration);
    }
}
 
private void createFabFrameAnim() {
    frameAnim = new AnimationDrawable();
    frameAnim.setOneShot(true);
    Resources resources = getResources();
    for (int res : frameAnimRes) {
        frameAnim.addFrame(resources.getDrawable(res), frameDuration);
    }
}
 
private void createFabReverseFrameAnim() {
    frameReverseAnim = new AnimationDrawable();
    frameReverseAnim.setOneShot(true);
    Resources resources = getResources();
    for (int i = frameAnimRes.length - 1; i >= 0; i--) {
        frameReverseAnim.addFrame(resources.getDrawable(frameAnimRes[i]), frameDuration);
    }
}
 
源代码20 项目: TextDrawable   文件: DrawableProvider.java
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;
}