android.graphics.drawable.AnimationDrawable Java Examples

The following examples show how to use android.graphics.drawable.AnimationDrawable. 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: LoadingLayout.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
public final void refreshing() {
	if (null != mHeaderText) {
		mHeaderText.setText(mRefreshingLabel);
	}

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).start();
	} else {
		// Now call the callback
		refreshingImpl();
	}

	if (null != mSubHeaderText) {
		mSubHeaderText.setVisibility(View.GONE);
	}
}
 
Example #2
Source File: BGANormalRefreshViewHolder.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View getRefreshHeaderView() {
    if (mRefreshHeaderView == null) {
        mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_normal, null);
        mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT);
        if (mRefreshViewBackgroundColorRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes);
        }
        if (mRefreshViewBackgroundDrawableRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes);
        }
        mHeaderStatusTv = (TextView) mRefreshHeaderView.findViewById(R.id.tv_normal_refresh_header_status);
        mHeaderArrowIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_arrow);
        mHeaderChrysanthemumIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_chrysanthemum);
        mHeaderChrysanthemumAd = (AnimationDrawable) mHeaderChrysanthemumIv.getDrawable();
        mHeaderStatusTv.setText(mPullDownRefreshText);
    }
    return mRefreshHeaderView;
}
 
Example #3
Source File: LoadingLayout.java    From iSCAU-Android with GNU General Public License v3.0 6 votes vote down vote up
public final void reset() {
	if (null != mHeaderText) {
		mHeaderText.setText(mPullLabel);
	}
	mHeaderImage.setVisibility(View.VISIBLE);

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).stop();
	} else {
		// Now call the callback
		resetImpl();
	}

	if (null != mSubHeaderText) {
		if (TextUtils.isEmpty(mSubHeaderText.getText())) {
			mSubHeaderText.setVisibility(View.GONE);
		} else {
			mSubHeaderText.setVisibility(View.VISIBLE);
		}
	}
}
 
Example #4
Source File: OnboardingFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPageChanged(final int newPage, int previousPage) {
    if (mContentAnimator != null) {
        mContentAnimator.end();
    }
    ArrayList<Animator> animators = new ArrayList<>();
    Animator fadeOut = createFadeOutAnimator(mContentView);

    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mContentView.setImageDrawable(getResources().getDrawable(pageImages[newPage]));
            ((AnimationDrawable) mContentView.getDrawable()).start();
        }
    });
    animators.add(fadeOut);
    animators.add(createFadeInAnimator(mContentView));
    AnimatorSet set = new AnimatorSet();
    set.playSequentially(animators);
    set.start();
    mContentAnimator = set;
}
 
Example #5
Source File: MainActivityDrawerLayout.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
/**
 * 自己去调整
 */
private void initAnimation() {
    // 获取ImageView上的动画背景
    AnimationDrawable spinnerLive = (AnimationDrawable) mIvLive.getBackground();

    // 开始动画
    spinnerLive.start();

    mIvImg = (ImageView) findViewById(R.id.img_img);

    // 获取ImageView上的动画背景
    AnimationDrawable spinnerImg = (AnimationDrawable) mIvImg.getBackground();
    // 开始动画
    spinnerImg.start();

}
 
Example #6
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 #7
Source File: ViewHolderController.java    From aurora-imui with MIT License 6 votes vote down vote up
public void notifyAnimStop() {
    ImageView imageView = mData.get(mLastPlayPosition);
    try {
        if (imageView != null) {
            AnimationDrawable anim = (AnimationDrawable) imageView.getDrawable();
            anim.stop();
            if (mIsSender) {
                imageView.setImageResource(mSendDrawable);
            } else {
                imageView.setImageResource(mReceiveDrawable);
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
Example #8
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 #9
Source File: RefreshView.java    From WidgetCase with Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
        mContext = context;

        DisplayMetrics dm = getResources().getDisplayMetrics();
        mScreenW = dm.widthPixels;
        mHeadBmp = BitmapFactory.decodeResource(getResources(), R.drawable.load_more_1);

//		mScrDistance = mScreenH / 3 - 46;
        mHeadW = mHeadBmp.getWidth();
        mHeadH = mHeadBmp.getHeight();
        mInitLeftPX = mScreenW / 2 - mHeadW;
        mInitRightPX = mScreenW / 2 + mHeadW;
        mBmpL = mScreenW / 2 - mHeadBmp.getWidth() / 2;
        mBmpT = 0;

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Style.FILL);//设置非填充
        mScroller = new Scroller(mContext, new DecelerateInterpolator());
        mScroller1 = new Scroller(mContext, new DecelerateInterpolator());

        mAniDraw = (AnimationDrawable) mAnimList.getDrawable();
    }
 
Example #10
Source File: WordDetailsAdapter.java    From allenglish with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ExampleSentenceContentAdapter.ViewHolder holder, int position) {
    final int pos = position;
    StringBuilder sb = new StringBuilder();
    sb.append(mDetailedWord.sentence.get(pos).Network_en).append("\n").append(mDetailedWord.sentence.get(pos).Network_cn);
    if (pos != getItemCount() - 1) {
        sb.append("\n");
    }
    holder.sentenceContent.setText(sb);
    ImageView horn = holder.horn;
    horn.setBackgroundResource(R.drawable.animation_horn_color);
    mSentenceHornAnimations.add((AnimationDrawable) horn.getBackground());
    horn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mSentenceHornAnimations.get(pos + 2).isRunning()) {
                return;
            }
            stopAnimation();
            mSentenceHornAnimations.get(pos + 2).start();
            mPlayAudio.play(BaseApplication.getInstance(), mDetailedWord.sentence.get(pos).tts_mp3, 3);
        }
    });
}
 
Example #11
Source File: SplashActivity.java    From BloodBank with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    imageView = findViewById(R.id.load_image);

    AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
    animationDrawable.start();

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
            startActivity(intent);
            finish();
        }
    }, 2000);
}
 
Example #12
Source File: Eyebrows.java    From Eyebrows with MIT License 6 votes vote down vote up
/**
 * start the gradient anim
 */
public void startGradientAnimation(){
    if(mView!=null){
        mView.setBackgroundResource(mGradientAnimation);
        mAnimationDrawable = (AnimationDrawable) mView.getBackground();
        if(mAnimationDrawable!=null){
            mView.setBackground(mAnimationDrawable);
            mAnimationDrawable.setEnterFadeDuration(mDuration);
            mAnimationDrawable.setExitFadeDuration(mDuration);
            mView.post(new Runnable() {
                @Override
                public void run() {
                    mAnimationDrawable.start();
                }
            });
        }
    }
}
 
Example #13
Source File: LoadingDialog.java    From fitness_Android with Apache License 2.0 6 votes vote down vote up
private void initViews() {
	this.txt=(TextView)findViewById(R.id.loading_content_text);
	this.progressBar=(RoundProgressBar)findViewById(R.id.roundProgressBar);
	this.normal_loading_bar=(ImageView)findViewById(R.id.normal_loading);
	this.txt.setText(msg);
	
	this.normal_loading_bar.setBackgroundResource(R.drawable.loading_animation);
	// 通过ImageView对象拿到背景显示的AnimationDrawable
	mAnimation = (AnimationDrawable) normal_loading_bar.getBackground();
	// 为了防止在onCreate方法中只显示第一帧的解决方案之一
	this.normal_loading_bar.post(new Runnable() {
		@Override
		public void run() {
			mAnimation.start();
		}
	});
	
	this.normal_loading_bar.setVisibility(View.VISIBLE);
	this.progressBar.setVisibility(View.GONE);
}
 
Example #14
Source File: LoadingLayout.java    From Social with Apache License 2.0 6 votes vote down vote up
public final void reset() {
	if (null != mHeaderText) {
		mHeaderText.setText(mPullLabel);
	}
	mHeaderImage.setVisibility(View.VISIBLE);

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).stop();
	} else {
		// Now call the callback
		resetImpl();
	}

	if (null != mSubHeaderText) {
		if (TextUtils.isEmpty(mSubHeaderText.getText())) {
			mSubHeaderText.setVisibility(View.GONE);
		} else {
			mSubHeaderText.setVisibility(View.VISIBLE);
		}
	}
}
 
Example #15
Source File: LoadingLayout.java    From handmarkPulltorefreshLibrary with Apache License 2.0 6 votes vote down vote up
public final void refreshing() {
	if (null != mHeaderText) {
		mHeaderText.setText(mRefreshingLabel);
	}

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).start();
	} else {
		// Now call the callback
		refreshingImpl();
	}

	if (null != mSubHeaderText) {
		mSubHeaderText.setVisibility(View.GONE);
	}
}
 
Example #16
Source File: LoadingLayout.java    From sctalk with Apache License 2.0 6 votes vote down vote up
public final void refreshing() {
    if (null != mHeaderText) {
        mHeaderText.setText(mRefreshingLabel);
        // mSubHeaderText.setText(mLastRefresh+sdf.format(date));
    }

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).start();
    } else {
        // Now call the callback
        refreshingImpl();
    }

    // if (null != mSubHeaderText) {
    // mSubHeaderText.setVisibility(View.GONE);
    // }
}
 
Example #17
Source File: LoadingLayout.java    From PullToRefresh-PinnedSection-ListView with MIT License 6 votes vote down vote up
public final void reset() {
	if (null != mHeaderText) {
		mHeaderText.setText(mPullLabel);
	}
	mHeaderImage.setVisibility(View.VISIBLE);

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).stop();
	} else {
		// Now call the callback
		resetImpl();
	}

	if (null != mSubHeaderText) {
		if (TextUtils.isEmpty(mSubHeaderText.getText())) {
			mSubHeaderText.setVisibility(View.GONE);
		} else {
			mSubHeaderText.setVisibility(View.VISIBLE);
		}
	}
}
 
Example #18
Source File: LoadingLayout.java    From letv with Apache License 2.0 6 votes vote down vote up
public final void reset() {
    if (this.mHeaderText != null) {
        this.mHeaderText.setText(this.mPullLabel);
    }
    this.mHeaderImage.setVisibility(0);
    if (this.mUseIntrinsicAnimation) {
        ((AnimationDrawable) this.mHeaderImage.getDrawable()).stop();
    } else {
        resetImpl();
    }
    if (this.mSubHeaderText == null) {
        return;
    }
    if (TextUtils.isEmpty(this.mSubHeaderText.getText())) {
        this.mSubHeaderText.setVisibility(8);
    } else {
        this.mSubHeaderText.setVisibility(0);
    }
}
 
Example #19
Source File: LoadingLayout.java    From Roid-Library with Apache License 2.0 6 votes vote down vote up
public final void refreshing() {
    if (null != mHeaderText) {
        mHeaderText.setText(mRefreshingLabel);
    }

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).start();
    } else {
        // Now call the callback
        refreshingImpl();
    }

    if (null != mSubHeaderText) {
        mSubHeaderText.setVisibility(View.GONE);
    }
}
 
Example #20
Source File: FloatBallActivity.java    From AndroidDemo with MIT License 6 votes vote down vote up
public void onClick(View v) {
    int id = v.getId();
    if (R.id.open == id) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
            Toast.makeText(this, "请在设置中开启弹窗权限", Toast.LENGTH_LONG).show();
            return;
        }
        if (!Tools.isServiceRunning(this, FloatBallService.class.getName())) {
            startService(new Intent(this, FloatBallService.class));
        }
    } else if (R.id.close == id) {
        if (Tools.isServiceRunning(this, FloatBallService.class.getName())) {
            stopService(new Intent(this, FloatBallService.class));
        }
    } else if (R.id.startAnim == id) {

        wifi.setBackgroundResource(R.drawable.wifi_anim);
        AnimationDrawable animation = (AnimationDrawable) wifi.getBackground();
        animation.start();

    } else if (R.id.stopAnim == id) {
        stopAnimation();
    }
}
 
Example #21
Source File: AdapterMusic.java    From DMAudioStreamer with Apache License 2.0 6 votes vote down vote up
private Drawable getDrawableByState(Context context, int state) {
    switch (state) {
        case PlaybackStateCompat.STATE_NONE:
            Drawable pauseDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(pauseDrawable, colorPlay);
            return pauseDrawable;
        case PlaybackStateCompat.STATE_PLAYING:
            AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(animation, colorPlay);
            animation.start();
            return animation;
        case PlaybackStateCompat.STATE_PAUSED:
            Drawable playDrawable = ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(playDrawable, colorPause);
            return playDrawable;
        default:
            Drawable noneDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(noneDrawable, colorPlay);
            return noneDrawable;
    }
}
 
Example #22
Source File: PopupNotificationActivity.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
private void setTypingAnimation(boolean start) {
    if (actionBarLayer == null) {
        return;
    }
    if (start) {
        try {
            actionBarLayer.setSubTitleIcon(R.drawable.typing_dots, OSUtilities.dp(4));
            AnimationDrawable mAnim = (AnimationDrawable) actionBarLayer.getSubTitleIcon();
            mAnim.setAlpha(200);
            mAnim.start();
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    } else {
        actionBarLayer.setSubTitleIcon(0, 0);
    }
}
 
Example #23
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 #24
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 #25
Source File: LoadingLayout.java    From SweetMusicPlayer with Apache License 2.0 6 votes vote down vote up
public final void refreshing() {
	if (null != mHeaderText) {
		mHeaderText.setText(mRefreshingLabel);
	}

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).start();
	} else {
		// Now call the callback
		refreshingImpl();
	}

	if (null != mSubHeaderText) {
		mSubHeaderText.setVisibility(View.GONE);
	}
}
 
Example #26
Source File: LoadingLayout.java    From MagicHeaderViewPager with Apache License 2.0 5 votes vote down vote up
public final void setLoadingDrawable(Drawable imageDrawable) {
    // Set Drawable
    mHeaderImage.setImageDrawable(imageDrawable);
    mUseIntrinsicAnimation=(imageDrawable instanceof AnimationDrawable);

    // Now call the callback
    onLoadingDrawableSet(imageDrawable);
}
 
Example #27
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 #28
Source File: LoadingLayout.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
public final void setLoadingDrawable(Drawable imageDrawable) {
	// Set Drawable
	mHeaderImage.setImageDrawable(imageDrawable);
	mUseIntrinsicAnimation = (imageDrawable instanceof AnimationDrawable);

	// Now call the callback
	onLoadingDrawableSet(imageDrawable);
}
 
Example #29
Source File: ImageViewAware.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
protected void setImageDrawableInto(Drawable drawable, View view) {
	((ImageView) view).setImageDrawable(drawable);
	if (drawable instanceof AnimationDrawable) {
		((AnimationDrawable)drawable).start();
	}
}
 
Example #30
Source File: RspMsgItemView.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
public void startAnimation() {
    try {
        if (mListDrawable.getLevel() == 0) {
            mListDrawable.setLevel(1);
            animation = (AnimationDrawable) mListDrawable.getCurrent();
            if (!animation.isRunning())
                animation.start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}