Java Code Examples for android.graphics.drawable.AnimationDrawable#setOneShot()

The following examples show how to use android.graphics.drawable.AnimationDrawable#setOneShot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BossTransferView.java    From BlogDemo with Apache License 2.0 6 votes vote down vote up
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();
    }
 
Example 2
Source File: IcsProgressBar.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: SkinCompatProgressBarHelper.java    From AndroidSkinAnimator with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: WeekdaysDrawableProvider.java    From weekdays-buttons-bar with MIT License 6 votes vote down vote up
public static Drawable getRectWithAnimation(int count, String label, int delay) {
    TextDrawable.IBuilder builder = TextDrawable.builder()
            .rect();


    AnimationDrawable animationDrawable = new AnimationDrawable();
    for (int i = count; i > 0; i--) {
        TextDrawable frame = builder.build(label, ColorGenerator.MATERIAL.getRandomColor());
        animationDrawable.addFrame(frame, delay);
    }
    animationDrawable.setOneShot(false);
    animationDrawable.start();


    return animationDrawable;
}
 
Example 5
Source File: SampleActivity.java    From DragPointView with Apache License 2.0 6 votes vote down vote up
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);
    }
 
Example 6
Source File: SkinCompatProgressBarHelper.java    From Android-skin-support with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: SkinCompatProgressBarHelper.java    From Android-skin-support with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: IcsProgressBar.java    From zen4android with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 9
Source File: ProgressBar.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: IcsProgressBar.java    From Libraries-for-Android-Developers with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: IcsProgressBar.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: RCTImageSequenceView.java    From react-native-image-sequence with MIT License 5 votes vote down vote up
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();
}
 
Example 13
Source File: DrawableProvider.java    From TextDrawable with MIT License 5 votes vote down vote up
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;
}
 
Example 14
Source File: BloomStyleActivity.java    From SpringFloatingActionMenu with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 15
Source File: TumblrStyleActivity.java    From SpringFloatingActionMenu with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 16
Source File: TumblrStyleActivity.java    From SpringFloatingActionMenu with Apache License 2.0 5 votes vote down vote up
private void createFabFrameAnim() {
    frameAnim = new AnimationDrawable();
    frameAnim.setOneShot(true);
    Resources resources = getResources();
    for (int res : frameAnimRes) {
        frameAnim.addFrame(resources.getDrawable(res), frameDuration);
    }
}
 
Example 17
Source File: AnimationUtils.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 18
Source File: ItemConversationAdapter.java    From DragPointView with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 19
Source File: UDImageView.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 开始帧动画(目前只支持本地动画)
 *
 * @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;
}
 
Example 20
Source File: CustomRefreshHeader.java    From FastWaiMai with MIT License 5 votes vote down vote up
@Override
public void onMoving(boolean isDragging, float percent, int offset, int height, int maxDragHeight) {

	// 下拉的百分比小于100%时,不断调用 setScale 方法改变图片大小
	float v = Float.parseFloat("2.5");
	if (percent < 1) {
		mImage.setScaleX(percent * v);
		mImage.setScaleY(percent * v);

		//是否执行过翻跟头动画的标记
		if (hasSetPullDownAnim) {
			hasSetPullDownAnim = false;
		}
	}

	//当下拉的高度达到Header高度100%时,开始加载正在下拉的初始动画,即翻跟头
	if (percent >= 1.0) {
		mImage.setScaleX(percent * v);
		mImage.setScaleY(percent * v);

		//因为这个方法是不停调用的,防止重复
		if (!hasSetPullDownAnim) {
			mImage.setImageResource(R.drawable.anim_pull_end);
			pullDownAnim = (AnimationDrawable) mImage.getDrawable();
			pullDownAnim.setOneShot(false);
			pullDownAnim.start();

			hasSetPullDownAnim = true;
		}
	}
}