Java Code Examples for android.graphics.drawable.AnimationDrawable#stop()
The following examples show how to use
android.graphics.drawable.AnimationDrawable#stop() .
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: ParallaxContainer.java From ParallaxSplash with Apache License 2.0 | 6 votes |
@Override public void onPageScrollStateChanged(int state) { final AnimationDrawable animationDrawable = (AnimationDrawable) iv.getBackground(); switch (state) { case ViewPager.SCROLL_STATE_IDLE: animationDrawable.stop(); break; case ViewPager.SCROLL_STATE_DRAGGING: animationDrawable.start(); break; default: break; } }
Example 2
Source File: ViewHolderController.java From aurora-imui with MIT License | 6 votes |
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 3
Source File: DrawableAnimationActivity.java From Android-Animation-Set with Apache License 2.0 | 5 votes |
private void doAnimation(AnimationDrawable animationDrawable, boolean doIt) { if (animationDrawable.isRunning()) { animationDrawable.stop(); } //When you want to restart the animation, stop the animation first. if (doIt) { animationDrawable.start(); } }
Example 4
Source File: MainActivity.java From android_maskable_layout with Apache License 2.0 | 5 votes |
private void animate() { Drawable drawable = mMaskableFrameLayout.getDrawableMask(); if (drawable instanceof AnimationDrawable) { AnimationDrawable animDrawable = (AnimationDrawable) drawable; animDrawable.selectDrawable(0); animDrawable.stop(); animDrawable.start(); } }
Example 5
Source File: MsgViewHolderAudio.java From NIM_Android_UIKit with MIT License | 5 votes |
private void stop() { if (animationView.getBackground() instanceof AnimationDrawable) { AnimationDrawable animation = (AnimationDrawable) animationView.getBackground(); animation.stop(); endPlayAnim(); } }
Example 6
Source File: PlayerLoadingControl.java From android-jungle-mediaplayer with Apache License 2.0 | 5 votes |
public void showError(boolean show) { AnimationDrawable drawable = (AnimationDrawable) mLoadingIcon.getBackground(); drawable.stop(); mLoadingContainer.setVisibility(View.GONE); mLoadingErrorContainer.setVisibility(show ? View.VISIBLE : View.GONE); }
Example 7
Source File: UIUtils.java From Pano360 with MIT License | 5 votes |
public static void stopImageAnim(ImageView Img) { try { AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); animationDrawable.stop(); } catch (ClassCastException e) { e.printStackTrace(); } Img.setVisibility(View.GONE); }
Example 8
Source File: DrawableAnimationActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void doAnimation(AnimationDrawable animationDrawable, boolean doIt) { if (animationDrawable.isRunning()) { animationDrawable.stop(); } //When you want to restart the animation, stop the animation first. if (doIt) { animationDrawable.start(); } }
Example 9
Source File: AudioRenderView.java From sctalk with Apache License 2.0 | 5 votes |
public void stopAnimation(){ AnimationDrawable animationDrawable = (AnimationDrawable) audioAnttView.getBackground(); if (animationDrawable.isRunning()) { animationDrawable.stop(); animationDrawable.selectDrawable(0); } }
Example 10
Source File: WordDetailsAdapter.java From allenglish with Apache License 2.0 | 5 votes |
public void stopAnimation() { for (AnimationDrawable animation : mSentenceHornAnimations) { if (animation.isRunning()) { animation.selectDrawable(0); // 选择当前动画的第一帧,然后停止 animation.stop(); } } }
Example 11
Source File: PointViewAnimObject.java From DragPointView with Apache License 2.0 | 5 votes |
private void start(AnimationDrawable object, final OnPointDragListener removeListener) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { int duration = 0; for (int i = 0; i < object.getNumberOfFrames(); i++) { duration += object.getDuration(i); } view.postDelayed(new Runnable() { @Override public void run() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(background); } end(removeListener); } }, duration + 5); view.setText(""); int drawableL = (view.getWidth() + view.getHeight()) / 2; ViewGroup.LayoutParams lp = view.getLayoutParams(); lp.height = lp.width = drawableL; view.setLayoutParams(lp); view.setBackground(object); if (object.isRunning()) object.stop(); object.start(); } else { end(removeListener); } }
Example 12
Source File: XinxinRefreshLayout.java From Ticket-Analysis with MIT License | 5 votes |
public RefreshHeader(Context context) { super(context); View header = LayoutInflater.from(context).inflate(R.layout.header_refresh_common, this); imageMoneyDown = (ImageView) header.findViewById(R.id.imageDown); animationDrawable = (AnimationDrawable) imageMoneyDown.getBackground(); animationDrawable.stop(); }
Example 13
Source File: MediaRouteButton.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void refreshRoute() { final MediaRouter.RouteInfo route = mRouter.getSelectedRoute(); final boolean isRemote = !route.isDefault() && route.matchesTypes(mRouteTypes); final boolean isConnecting = isRemote && route.isConnecting(); boolean needsRefresh = false; if (mRemoteActive != isRemote) { mRemoteActive = isRemote; needsRefresh = true; } if (mIsConnecting != isConnecting) { mIsConnecting = isConnecting; needsRefresh = true; } if (needsRefresh) { refreshDrawableState(); } if (mAttachedToWindow) { setEnabled(mRouter.isRouteAvailable(mRouteTypes, MediaRouter.AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE)); } if (mRemoteIndicator != null && mRemoteIndicator.getCurrent() instanceof AnimationDrawable) { AnimationDrawable curDrawable = (AnimationDrawable) mRemoteIndicator.getCurrent(); if (mAttachedToWindow) { if ((needsRefresh || isConnecting) && !curDrawable.isRunning()) { curDrawable.start(); } } else if (isRemote && !isConnecting) { // When the route is already connected before the view is attached, show the last // frame of the connected animation immediately. if (curDrawable.isRunning()) { curDrawable.stop(); } curDrawable.selectDrawable(curDrawable.getNumberOfFrames() - 1); } } }
Example 14
Source File: ListViewAdapter.java From mobile-manager-tool with MIT License | 4 votes |
@Override public View getView(final int position, View convertView, ViewGroup parent) { final View view = super.getView(position, convertView, parent); Cursor mCursor = (Cursor) getItem(position); setupViewData(mCursor); final ViewHolderList viewholder; if ( view != null ) { viewholder = new ViewHolderList(view); holderReference = new WeakReference<ViewHolderList>(viewholder); view.setTag(holderReference.get()); } else { viewholder = (ViewHolderList)convertView.getTag(); } if( mLineOneText != null ){ holderReference.get().mViewHolderLineOne.setText(mLineOneText); } else{ holderReference.get().mViewHolderLineOne.setVisibility(View.GONE); } if( mLineTwoText != null ){ holderReference.get().mViewHolderLineTwo.setText(mLineTwoText); } else{ holderReference.get().mViewHolderLineOne.setPadding(left, top, 0, 0); holderReference.get().mViewHolderLineTwo.setVisibility(View.GONE); } if( mImageData != null ){ ImageInfo mInfo = new ImageInfo(); mInfo.type = mListType; mInfo.size = SIZE_THUMB; mInfo.source = SRC_FIRST_AVAILABLE; mInfo.data = mImageData; mImageProvider.loadImage( viewholder.mViewHolderImage, mInfo ); } else{ holderReference.get().mViewHolderImage.setVisibility(View.GONE); } if( showContextEnabled ){ holderReference.get().mQuickContext.setOnClickListener(showContextMenu); } else{ holderReference.get().mQuickContext.setVisibility(View.GONE); } if ( ( mPlayingId !=0 && mCurrentId !=0 ) && mPlayingId == mCurrentId ) { holderReference.get().mPeakOne.setImageResource(R.anim.music_peak_meter_1); holderReference.get().mPeakTwo.setImageResource(R.anim.music_peak_meter_2); mPeakOneAnimation = (AnimationDrawable)holderReference.get().mPeakOne.getDrawable(); mPeakTwoAnimation = (AnimationDrawable)holderReference.get().mPeakTwo.getDrawable(); try { if ( MusicUtils.mService.isPlaying() ) { mPeakOneAnimation.start(); mPeakTwoAnimation.start(); } else { mPeakOneAnimation.stop(); mPeakTwoAnimation.stop(); } } catch ( RemoteException e ) { e.printStackTrace(); } } else { holderReference.get().mPeakOne.setImageResource(0); holderReference.get().mPeakTwo.setImageResource(0); } return view; }
Example 15
Source File: DragSortListViewAdapter.java From mobile-manager-tool with MIT License | 4 votes |
@Override public View getView(final int position, View convertView, ViewGroup parent) { final View view = super.getView(position, convertView, parent); Cursor mCursor = (Cursor) getItem(position); setupViewData(mCursor); final ViewHolderList viewholder; if ( view != null ) { viewholder = new ViewHolderList(view); holderReference = new WeakReference<ViewHolderList>(viewholder); view.setTag(holderReference.get()); } else { viewholder = (ViewHolderList)convertView.getTag(); } holderReference.get().mViewHolderLineOne.setText(mLineOneText); holderReference.get().mViewHolderLineTwo.setText(mLineTwoText); ImageInfo mInfo = new ImageInfo(); mInfo.type = TYPE_ARTIST; mInfo.size = SIZE_THUMB; mInfo.source = SRC_FIRST_AVAILABLE; mInfo.data = mImageData; mImageProvider.loadImage( viewholder.mViewHolderImage, mInfo ); holderReference.get().mQuickContext.setOnClickListener(showContextMenu); if ( mPlayingId == mCurrentId ) { holderReference.get().mPeakOne.setImageResource(R.anim.music_peak_meter_1); holderReference.get().mPeakTwo.setImageResource(R.anim.music_peak_meter_2); mPeakOneAnimation = (AnimationDrawable)holderReference.get().mPeakOne.getDrawable(); mPeakTwoAnimation = (AnimationDrawable)holderReference.get().mPeakTwo.getDrawable(); try { if ( MusicUtils.mService.isPlaying() ) { mPeakOneAnimation.start(); mPeakTwoAnimation.start(); } else { mPeakOneAnimation.stop(); mPeakTwoAnimation.stop(); } } catch ( RemoteException e ) { e.printStackTrace(); } } else { holderReference.get().mPeakOne.setImageResource(0); holderReference.get().mPeakTwo.setImageResource(0); } return view; }
Example 16
Source File: GridViewAdapter.java From mobile-manager-tool with MIT License | 4 votes |
@Override public View getView(final int position, View convertView, ViewGroup parent) { final View view = super.getView(position, convertView, parent); Cursor mCursor = (Cursor) getItem(position); setupViewData(mCursor); // ViewHolderGrid final ViewHolderGrid viewholder; if ( view != null ) { viewholder = new ViewHolderGrid(view); holderReference = new WeakReference<ViewHolderGrid>(viewholder); view.setTag(holderReference.get()); } else { viewholder = (ViewHolderGrid)convertView.getTag(); } holderReference.get().mViewHolderLineOne.setText(mLineOneText); holderReference.get().mViewHolderLineTwo.setText(mLineTwoText); ImageInfo mInfo = new ImageInfo(); mInfo.type = mGridType; mInfo.size = SIZE_THUMB; mInfo.source = SRC_FIRST_AVAILABLE; mInfo.data = mImageData; mImageProvider.loadImage( viewholder.mViewHolderImage, mInfo ); if ( mPlayingId == mCurrentId ) { holderReference.get().mPeakOne.setImageResource(R.anim.music_peak_meter_1); holderReference.get().mPeakTwo.setImageResource(R.anim.music_peak_meter_2); mPeakOneAnimation = (AnimationDrawable)holderReference.get().mPeakOne.getDrawable(); mPeakTwoAnimation = (AnimationDrawable)holderReference.get().mPeakTwo.getDrawable(); try { if ( MusicUtils.mService.isPlaying() ) { mPeakOneAnimation.start(); mPeakTwoAnimation.start(); } else { mPeakOneAnimation.stop(); mPeakTwoAnimation.stop(); } } catch ( RemoteException e ) { e.printStackTrace(); } } else { holderReference.get().mPeakOne.setImageResource(0); holderReference.get().mPeakTwo.setImageResource(0); } return view; }
Example 17
Source File: MusicListAdapter.java From mobile-manager-tool with MIT License | 4 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolderList viewHolder; if (convertView == null) { convertView = View.inflate(context, R.layout.music_listview_items, null); viewHolder = new ViewHolderList(convertView); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolderList) convertView.getTag(); } final Song m = list.get(position); viewHolder.mViewHolderLineOne.setText(m.getName()); String desc = "<unknown>".equals(m.getArtist()) ? m.getAlbumName() : m.getArtist() ; if(m.getMDuration()>0){ viewHolder.mViewHolderLineTwo.setText(desc + " " + MediaUtil.formatTime(m.getMDuration())); }else{ viewHolder.mViewHolderLineTwo.setText(desc); } viewHolder.mQuickContext.setOnClickListener(showContextMenu); viewHolder.mViewHolderImage.setImageResource(R.drawable.music_default); Song currentPlayMusic = MusicService.MUSIC.getPlayMusic(); if (currentPlayMusic != null && currentPlayMusic.getId().equals(m.getId())) { viewHolder.mPeakOne.setImageResource(R.anim.music_peak_meter_1); viewHolder.mPeakTwo.setImageResource(R.anim.music_peak_meter_2); mPeakOneAnimation = (AnimationDrawable) viewHolder.mPeakOne.getDrawable(); mPeakTwoAnimation = (AnimationDrawable) viewHolder.mPeakTwo.getDrawable(); if (MusicService.getInstance() != null && MusicService.getInstance().isPlaying()) { mPeakOneAnimation.start(); mPeakTwoAnimation.start(); } else { mPeakOneAnimation.stop(); mPeakTwoAnimation.stop(); } } else { viewHolder.mPeakOne.setImageResource(0); viewHolder.mPeakTwo.setImageResource(0); } return convertView; }