Java Code Examples for android.graphics.drawable.TransitionDrawable#getNumberOfLayers()
The following examples show how to use
android.graphics.drawable.TransitionDrawable#getNumberOfLayers() .
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: LoadImageView.java From MHViewer with Apache License 2.0 | 6 votes |
private ImageDrawable getImageDrawable() { Drawable drawable = getDrawable(); if (drawable instanceof TransitionDrawable) { TransitionDrawable transitionDrawable = (TransitionDrawable) drawable; if (transitionDrawable.getNumberOfLayers() == 2) { drawable = transitionDrawable.getDrawable(1); } } if (drawable instanceof PreciselyClipDrawable) { drawable = ((PreciselyClipDrawable) drawable).getWrappedDrawable(); } if (drawable instanceof ImageDrawable) { return (ImageDrawable) drawable; } else { return null; } }
Example 2
Source File: LoadImageView.java From EhViewer with Apache License 2.0 | 6 votes |
private ImageDrawable getImageDrawable() { Drawable drawable = getDrawable(); if (drawable instanceof TransitionDrawable) { TransitionDrawable transitionDrawable = (TransitionDrawable) drawable; if (transitionDrawable.getNumberOfLayers() == 2) { drawable = transitionDrawable.getDrawable(1); } } if (drawable instanceof PreciselyClipDrawable) { drawable = ((PreciselyClipDrawable) drawable).getWrappedDrawable(); } if (drawable instanceof ImageDrawable) { return (ImageDrawable) drawable; } else { return null; } }
Example 3
Source File: RecyclingImageView.java From Audinaut with GNU General Public License v3.0 | 5 votes |
@Override public void onDraw(Canvas canvas) { Drawable drawable = this.getDrawable(); if (drawable != null) { if (drawable instanceof BitmapDrawable) { if (isBitmapRecycled(drawable)) { this.setImageDrawable(null); this.invalidated = true; } } else if (drawable instanceof TransitionDrawable) { TransitionDrawable transitionDrawable = (TransitionDrawable) drawable; // If last bitmap in chain is recycled, just blank this out since it would be invalid anyways Drawable lastDrawable = transitionDrawable.getDrawable(transitionDrawable.getNumberOfLayers() - 1); if (isBitmapRecycled(lastDrawable)) { this.setImageDrawable(null); setInvalidated(true); } else { // Go through earlier bitmaps and make sure that they are not recycled for (int i = 0; i < transitionDrawable.getNumberOfLayers(); i++) { Drawable layerDrawable = transitionDrawable.getDrawable(i); if (isBitmapRecycled(layerDrawable)) { // If anything in the chain is broken, just get rid of transition and go to last drawable this.setImageDrawable(lastDrawable); break; } } } } } super.onDraw(canvas); }
Example 4
Source File: LoadImageView.java From Nimingban with Apache License 2.0 | 5 votes |
private void removeDrawableAndHolder() { // Remove drawable Drawable drawable = getDrawable(); if (drawable instanceof TransitionDrawable) { TransitionDrawable tDrawable = (TransitionDrawable) drawable; int number = tDrawable.getNumberOfLayers(); if (number > 0) { drawable = tDrawable.getDrawable(number - 1); } } if (drawable instanceof ImageDrawable) { ((ImageDrawable) drawable).recycle(); } setImageDrawable(null); // Remove holder if (mHolder != null) { mHolder.release(this); ImageWrapper imageWrapper = mHolder.getValue(); if (mHolder.isFree()) { // ImageWrapper is free, stop animate imageWrapper.stop(); if (!mHolder.isInMemoryCache()) { // ImageWrapper is not needed any more, recycle it imageWrapper.recycle(); } } mHolder = null; } }
Example 5
Source File: LoadImageView.java From Nimingban with Apache License 2.0 | 5 votes |
public void start() { Drawable drawable = getDrawable(); if (drawable instanceof TransitionDrawable) { TransitionDrawable tDrawable = (TransitionDrawable) drawable; int number = tDrawable.getNumberOfLayers(); if (number > 0) { drawable = tDrawable.getDrawable(number - 1); } } if (drawable instanceof ImageDrawable) { ((ImageDrawable) drawable).start(); } }
Example 6
Source File: LoadImageView.java From Nimingban with Apache License 2.0 | 5 votes |
public void stop() { Drawable drawable = getDrawable(); if (drawable instanceof TransitionDrawable) { TransitionDrawable tDrawable = (TransitionDrawable) drawable; int number = tDrawable.getNumberOfLayers(); if (number > 0) { drawable = tDrawable.getDrawable(number - 1); } } if (drawable instanceof ImageDrawable) { ((ImageDrawable) drawable).stop(); } }
Example 7
Source File: RecyclingImageView.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
@Override public void onDraw(Canvas canvas) { Drawable drawable = this.getDrawable(); if(drawable != null) { if(drawable instanceof BitmapDrawable) { if (isBitmapRecycled(drawable)) { this.setImageDrawable(null); setInvalidated(true); } } else if(drawable instanceof TransitionDrawable) { TransitionDrawable transitionDrawable = (TransitionDrawable) drawable; // If last bitmap in chain is recycled, just blank this out since it would be invalid anyways Drawable lastDrawable = transitionDrawable.getDrawable(transitionDrawable.getNumberOfLayers() - 1); if(isBitmapRecycled(lastDrawable)) { this.setImageDrawable(null); setInvalidated(true); } else { // Go through earlier bitmaps and make sure that they are not recycled for (int i = 0; i < transitionDrawable.getNumberOfLayers(); i++) { Drawable layerDrawable = transitionDrawable.getDrawable(i); if (isBitmapRecycled(layerDrawable)) { // If anything in the chain is broken, just get rid of transition and go to last drawable this.setImageDrawable(lastDrawable); break; } } } } } super.onDraw(canvas); }